Skip to content

Commit fd6a182

Browse files
committed
Merge branch 'release/3.1.1'
2 parents 7af687a + 7f59385 commit fd6a182

File tree

8 files changed

+66
-215
lines changed

8 files changed

+66
-215
lines changed

dist/drill-down.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ function (_React$Component) {
16551655
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactFC).call(this, props));
16561656
_this.containerId = (0, _v["default"])();
16571657
_this.oldOptions = null;
1658-
_this.FusionCharts = props.fcLibrary || ReactFC.fusionChartsCore;
1658+
_this.FusionCharts = props.fcLibrary || ReactFC.fusionChartsCore || window.FusionCharts;
16591659
return _this;
16601660
}
16611661

@@ -1665,13 +1665,11 @@ function (_React$Component) {
16651665
this.renderChart();
16661666
}
16671667
}, {
1668-
key: "componentWillReceiveProps",
1669-
value: function componentWillReceiveProps(nextProps) {
1670-
if (!this.oldOptions) {
1671-
return;
1668+
key: "componentDidUpdate",
1669+
value: function componentDidUpdate(prevProps) {
1670+
if (prevProps !== this.props) {
1671+
this.detectChanges(this.props);
16721672
}
1673-
1674-
this.detectChanges(nextProps);
16751673
}
16761674
}, {
16771675
key: "componentWillUnmount",

dist/drill-down.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-fusioncharts.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
134134

135135
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
136136

137-
// import FusionCharts from 'fusioncharts/core';
138137

139138

140139

@@ -171,7 +170,7 @@ function (_React$Component) {
171170
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactFC).call(this, props));
172171
_this.containerId = uuid_v4__WEBPACK_IMPORTED_MODULE_1___default()();
173172
_this.oldOptions = null;
174-
_this.FusionCharts = props.fcLibrary || ReactFC.fusionChartsCore;
173+
_this.FusionCharts = props.fcLibrary || ReactFC.fusionChartsCore || window.FusionCharts;
175174
return _this;
176175
}
177176

@@ -181,13 +180,11 @@ function (_React$Component) {
181180
this.renderChart();
182181
}
183182
}, {
184-
key: "componentWillReceiveProps",
185-
value: function componentWillReceiveProps(nextProps) {
186-
if (!this.oldOptions) {
187-
return;
183+
key: "componentDidUpdate",
184+
value: function componentDidUpdate(prevProps) {
185+
if (prevProps !== this.props) {
186+
this.detectChanges(this.props);
188187
}
189-
190-
this.detectChanges(nextProps);
191188
}
192189
}, {
193190
key: "componentWillUnmount",

dist/react-fusioncharts.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/ChartViewer.js

Lines changed: 37 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -1,207 +1,65 @@
11
import React from 'react';
22
import FusionCharts from 'fusioncharts';
33
import Charts from 'fusioncharts/fusioncharts.charts';
4-
import Column2d from 'fusioncharts/viz/column2d';
54
import TimeSeries from 'fusioncharts/fusioncharts.timeseries';
65
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';
76
import ReactFC from '../lib/ReactFC';
87

9-
// Charts(FusionCharts);
10-
// TimeSeries(FusionCharts);
11-
// OceanTheme(FusionCharts);
128
ReactFC.fcRoot(FusionCharts, Charts, TimeSeries, FusionTheme);
139

14-
const myDataSource = {
15-
chart: {
16-
caption: "Harry's ss",
17-
subCaption: 'Top 5 stores in last month by revenue',
18-
numberPrefix: '$',
19-
theme: 'ocean'
20-
},
21-
data: [
22-
{
23-
label: 'Bakersfield Central',
24-
value: '880000'
25-
},
26-
{
27-
label: 'Garden Groove harbour',
28-
value: '730000'
29-
},
30-
{
31-
label: 'Los Angeles Topanga',
32-
value: '590000'
33-
},
34-
{
35-
label: 'Compton-Rancho Dom',
36-
value: '520000'
37-
},
38-
{
39-
label: 'Daly City Serramonte',
40-
value: '330000'
41-
}
42-
]
43-
};
44-
45-
// const jsonify = res => res.json();
46-
// const dataFetch = fetch(
47-
// 'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/data.json'
48-
// ).then(jsonify);
49-
// const schemaFetch = fetch(
50-
// 'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/schema.json'
51-
// ).then(jsonify);
10+
const BAR = 'bar2d';
5211

5312
class ChartViewer extends React.Component {
5413
constructor(props) {
5514
super(props);
5615

5716
this.state = {
58-
timeseriesDs: {
59-
type: 'column2d',
60-
renderAt: 'container',
61-
width: '90%',
62-
height: 350,
63-
dataSource: {
64-
chart: {
65-
caption: "Harry's ss",
66-
subCaption: 'Top 5 stores in last month by revenue',
67-
numberPrefix: '$'
68-
},
69-
data: [
70-
{
71-
label: 'Bakersfield Central',
72-
value: '880000'
73-
},
74-
{
75-
label: 'Garden Groove harbour',
76-
value: '730000'
77-
},
78-
{
79-
label: 'Los Angeles Topanga',
80-
value: '590000'
81-
},
82-
{
83-
label: 'Compton-Rancho Dom',
84-
value: '520000'
85-
},
86-
{
87-
label: 'Daly City Serramonte',
88-
value: '330000'
89-
}
90-
]
91-
}
17+
inverted: false,
18+
type: BAR,
19+
dataSource: {
20+
chart: {
21+
caption: 'Countries With Most Oil Reserves [2017-18]',
22+
subCaption: 'In MMbbl = One Million barrels',
23+
xAxisName: 'Country',
24+
yAxisName: 'Reserves (MMbbl)',
25+
numberSuffix: 'K',
26+
theme: 'fusion'
27+
},
28+
data: [
29+
{ label: 'Venezuela', value: '290' },
30+
{ label: 'Saudi', value: '260' },
31+
{ label: 'Canada', value: '180' },
32+
{ label: 'Iran', value: '140' },
33+
{ label: 'Russia', value: '115' },
34+
{ label: 'UAE', value: '100' },
35+
{ label: 'US', value: '30' },
36+
{ label: 'China', value: '300' }
37+
]
9238
}
9339
};
94-
95-
this.onChangeSize = this.onChangeSize.bind(this);
96-
this.onFetchData = this.onFetchData.bind(this);
97-
this.onChangeCaption = this.onChangeCaption.bind(this);
40+
this.onChange = this.onChange.bind(this);
9841
}
9942

100-
componentDidMount() {
101-
// this.onFetchData();
102-
}
103-
104-
onChangeSize() {
105-
const timeseriesDs = { ...this.state.timeseriesDs };
106-
timeseriesDs.height = 600;
107-
timeseriesDs.width = 600;
108-
this.setState({ timeseriesDs }, () => {
109-
console.log(this.state.timeseriesDs);
110-
});
111-
}
112-
113-
onFetchData() {
114-
// Promise.all([dataFetch, schemaFetch]).then(res => {
115-
// const data = res[0];
116-
// const schema = res[1];
117-
// const fusionTable = new FusionCharts.DataStore().createDataTable(
118-
// data,
119-
// schema
120-
// );
121-
// const timeseriesDs = Object.assign({}, this.state.timeseriesDs);
122-
// timeseriesDs.dataSource.data = fusionTable;
123-
// this.setState({
124-
// timeseriesDs
125-
// });
126-
// });
127-
}
128-
129-
onChangeCaption() {
130-
// console.log(this.state.timeseriesDs);
131-
const timeseriesDs = { ...this.state.timeseriesDs };
132-
timeseriesDs.dataSource.caption.text = 'Random';
133-
this.setState(
134-
{
135-
timeseriesDs
136-
},
137-
() => {
138-
// this.onChangeSize();
43+
onChange() {
44+
this.setState(({ dataSource }) => ({
45+
dataSource: {
46+
...dataSource,
47+
chart: { ...dataSource.chart, caption: 'CHANGED IT!!!!!!!' }
13948
}
140-
);
49+
}));
14150
}
14251

14352
render() {
14453
return (
14554
<div>
146-
{/* <ReactFC {...this.state} /> */}
147-
{this.state.timeseriesDs.dataSource.data ? (
148-
<ReactFC
149-
type="line"
150-
width="600"
151-
height="400"
152-
dataSource={{
153-
chart: {
154-
theme: 'fusion',
155-
caption: 'Total footfall in Bakersfield Central',
156-
subCaption: 'Last week',
157-
xAxisName: 'Day',
158-
yAxisName: 'No. of Visitors',
159-
lineThickness: '2',
160-
showXAxisLine: 1,
161-
showYAxisLine: 1,
162-
numDivLines: 7,
163-
numVDivLines: 7,
164-
showToolTip: 1
165-
},
166-
data: [
167-
{
168-
label: 'Mon',
169-
value: '15123'
170-
},
171-
{
172-
label: 'Tue',
173-
value: '14233'
174-
},
175-
{
176-
label: 'Wed',
177-
value: '23507'
178-
},
179-
{
180-
label: 'Thu',
181-
value: '9110'
182-
},
183-
{
184-
label: 'Fri',
185-
value: '15529'
186-
},
187-
{
188-
label: 'Sat',
189-
value: '20803'
190-
},
191-
{
192-
label: 'Sun',
193-
value: '19202'
194-
}
195-
]
196-
}}
197-
/>
198-
) : (
199-
'loading'
200-
)}
201-
<div>
202-
<button onClick={this.onChangeSize}>Change Size</button>
203-
<button onClick={this.onChangeCaption}>Change Caption</button>
204-
</div>
55+
<ReactFC
56+
type={this.state.type}
57+
width={this.state.inverted ? '400' : '600'}
58+
height={this.state.inverted ? '600' : '400'}
59+
dataFormat="json"
60+
dataSource={this.state.dataSource}
61+
/>
62+
<button onClick={this.onChange}>CHANGE</button>
20563
</div>
20664
);
20765
}

lib/ReactFC.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function (_React$Component) {
6666
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactFC).call(this, props));
6767
_this.containerId = (0, _v["default"])();
6868
_this.oldOptions = null;
69-
_this.FusionCharts = props.fcLibrary || ReactFC.fusionChartsCore;
69+
_this.FusionCharts = props.fcLibrary || ReactFC.fusionChartsCore || window.FusionCharts;
7070
return _this;
7171
}
7272

@@ -76,13 +76,11 @@ function (_React$Component) {
7676
this.renderChart();
7777
}
7878
}, {
79-
key: "componentWillReceiveProps",
80-
value: function componentWillReceiveProps(nextProps) {
81-
if (!this.oldOptions) {
82-
return;
79+
key: "componentDidUpdate",
80+
value: function componentDidUpdate(prevProps) {
81+
if (prevProps !== this.props) {
82+
this.detectChanges(this.props);
8383
}
84-
85-
this.detectChanges(nextProps);
8684
}
8785
}, {
8886
key: "componentWillUnmount",

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-fusioncharts",
3-
"version": "3.0.1",
3+
"version": "3.1.1",
44
"description": "Simple and Lightweight React component for FusionCharts JavaScript Charting Library",
55
"main": "lib/ReactFC.js",
66
"author": {
@@ -55,15 +55,15 @@
5555
"eslint-plugin-import": "^2.9.0",
5656
"eslint-plugin-jsx-a11y": "^6.0.3",
5757
"eslint-plugin-react": "^7.7.0",
58-
"fusioncharts": "^3.13.3",
58+
"fusioncharts": "^3.13.5-sr.1",
5959
"jest": "^22.4.2",
6060
"lodash": "^4.17.11",
61+
"nodemon": "^2.0.2",
6162
"prop-types": "^15.6.2",
62-
"react": "^16.2.0",
63+
"react": "^16.12.0",
6364
"react-addons-test-utils": "15.3.0",
6465
"react-component-gulp-tasks": "^0.7.6",
65-
"react-dom": "^16.2.0",
66-
"react-native": "^0.54.2",
66+
"react-dom": "^16.12.0",
6767
"react-test-renderer": "^16.2.0",
6868
"serve": "^10.0.1",
6969
"webpack": "^4.20.2",
@@ -79,7 +79,8 @@
7979
"build:example": "npm run build:lib && webpack --config webpack.config.example.js",
8080
"start": "npm run build:example && serve example/",
8181
"test": "jest --coverage --verbose",
82-
"test:report": "npm test && serve coverage/lcov-report -o"
82+
"test:report": "npm test && serve coverage/lcov-report -o",
83+
"watch": "nodemon --ignore example/dist --watch example --watch src --exec \"npm run start\""
8384
},
8485
"keywords": [
8586
"react",

0 commit comments

Comments
 (0)