/
ex5.js
executable file
·94 lines (87 loc) · 2.77 KB
/
ex5.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import React from 'react';
import ReactDOM from 'react-dom';
import react_fc from 'react-fusioncharts';
import FusionCharts from 'fusioncharts';
import charts from 'fusioncharts/fusioncharts.charts';
import TM from 'fusioncharts/themes/fusioncharts.theme.ocean';
// Load the charts module pass FusionCharts as dependency
charts(FusionCharts);
FusionCharts.ready(function () {
var myDataSource = {
chart: {
caption: "Harry's SuperMart",
subCaption: "Top 5 stores in last month by revenue",
numberPrefix: "$",
theme: "ocean"
},
data:[
{
label: "Bakersfield Central",
value: "880000"
},
{
label: "Garden Groove harbour",
value: "730000"
},
{
label: "Los Angeles Topanga",
value: "590000"
},
{
label: "Compton-Rancho Dom",
value: "520000"
},
{
label: "Daly City Serramonte",
value: "330000"
}]
};
var FCDashboard = React.createClass({
getInitialState: function () {
return {
filterSource: ''
};
},
handleCLick: function () {
this.setState({
filterSource: 'btn_update_data'
});
},
render: function () {
var props_col_chart = {
id: "column_chart",
renderAt: "column_chart_container",
type: "column2d",
width:600,
height: 400,
dataFormat: "json",
dataSource: myDataSource,
eventSource: this.state.filterSource,
impactedBy: ['btn_update_data']
};
// Filter the column chart's data
if (this.state.filterSource && this.state.filterSource.length != 0) {
props_col_chart.dataSource.data[2].label = "Art Supply Store";
props_col_chart.dataSource.data[2].value = "420000";
props_col_chart.dataSource.data[3].label = "P.C. Richard & Son";
props_col_chart.dataSource.data[3].value = "210000";
}
else {
props_col_chart.dataSource = myDataSource;
}
return (
<div>
<react_fc.FusionCharts {...props_col_chart} />
<a id='btn_update_data'
onClick={this.handleCLick}
className="btn btn-default"
href="#">{'Click me to change data'}</a>
</div>
);
}
})
ReactDOM.render(
<FCDashboard />,
document.getElementById('fc_react_app')
);
});