|
| 1 | +import React from 'react'; |
| 2 | +import FusionCharts from 'fusioncharts'; |
| 3 | +import Charts from 'fusioncharts/fusioncharts.charts'; |
| 4 | +import OceanTheme from 'fusioncharts/themes/fusioncharts.theme.ocean'; |
| 5 | +import ReactFC from '../lib/ReactFC'; |
| 6 | + |
| 7 | +Charts(FusionCharts); |
| 8 | +OceanTheme(FusionCharts); |
| 9 | + |
| 10 | +const myDataSource = { |
| 11 | + chart: { |
| 12 | + caption: 'Harry\'s SuperMart', |
| 13 | + subCaption: 'Top 5 stores in last month by revenue', |
| 14 | + numberPrefix: '$', |
| 15 | + theme: 'ocean', |
| 16 | + }, |
| 17 | + data: [ |
| 18 | + { |
| 19 | + label: 'Bakersfield Central', |
| 20 | + value: '880000', |
| 21 | + }, |
| 22 | + { |
| 23 | + label: 'Garden Groove harbour', |
| 24 | + value: '730000', |
| 25 | + }, |
| 26 | + { |
| 27 | + label: 'Los Angeles Topanga', |
| 28 | + value: '590000', |
| 29 | + }, |
| 30 | + { |
| 31 | + label: 'Compton-Rancho Dom', |
| 32 | + value: '520000', |
| 33 | + }, |
| 34 | + { |
| 35 | + label: 'Daly City Serramonte', |
| 36 | + value: '330000', |
| 37 | + }, |
| 38 | + ], |
| 39 | +}; |
| 40 | + |
| 41 | +class ChartViewer extends React.Component { |
| 42 | + constructor(props) { |
| 43 | + super(props); |
| 44 | + |
| 45 | + this.state = { |
| 46 | + type: 'column2d', |
| 47 | + width: 600, |
| 48 | + height: 400, |
| 49 | + dataFormat: 'json', |
| 50 | + dataSource: myDataSource, |
| 51 | + }; |
| 52 | + |
| 53 | + this.onClick = this.onClick.bind(this); |
| 54 | + } |
| 55 | + |
| 56 | + onClick() { |
| 57 | + this.setState({ |
| 58 | + dataFormat: 'xml', |
| 59 | + dataSource: `<chart caption="Top 10 Most Popular Sports in the World" subcaption="Based on number of viewers" yaxisname="Number of Viewers" plotgradientcolor="" bgcolor="FFFFFF" showplotborder="0" divlinecolor="CCCCCC" showvalues="1" showcanvasborder="0" canvasbordercolor="CCCCCC" canvasborderthickness="1" showyaxisvalues="0" showlegend="1" showshadow="0" labelsepchar=": " basefontcolor="000000" labeldisplay="AUTO" numberscalevalue="1000,1000,1000" numberscaleunit="K,M,B" palettecolors="#008ee4,#9b59b6,#6baa01,#e44a00,#f8bd19,#d35400,#bdc3c7,#95a5a6,#34495e,#1abc9c" showborder="0" rotateValues="0" placevaluesInside="0" valueFontColor="#909090" theme="ocean"> |
| 60 | + <set label="Football" value="3500000000" tooltext="Popular in: {br}Europe{br}Africa{br}Asia{br}Americas" /> |
| 61 | + <set label="Cricket" value="3000000000" tooltext="Popular in: {br}India{br}UK{br}Pakistan{br}Australia" /> |
| 62 | + <set label="Field Hockey" value="2200000000" tooltext="Popular in: {br}Asia{br}Europe{br}Africa{br}Australia" /> |
| 63 | + <set label="Tennis" value="1000000000" color="e44a00" tooltext="Popular in: {br}Europe{br}Americas{br}Asia" /> |
| 64 | + <set label="Volleyball" value="900000000" tooltext="Popular in: {br}Asia{br}Europe{br}Americas{br}Australia" /> |
| 65 | + <set label="Table Tennis" value="900000000" tooltext="Popular in: {br}Asia{br}Europe{br}Africa{br}Americas" /> |
| 66 | + <set label="Baseball" value="500000000" tooltext="Popular in: {br}US{br}Japan{br}Cuba{br}Dominican Republic" /> |
| 67 | + <set label="Golf" value="400000000" tooltext="Popular in: {br}US{br}Canada{br}Europe" /> |
| 68 | + <set label="Basketball" value="400000000" tooltext="Popular in: {br}US{br}Canada" /> |
| 69 | + <set label="American football" value="390000000" tooltext="Popular in:{br}US" /> |
| 70 | + </chart>`, |
| 71 | + }); |
| 72 | + } |
| 73 | + |
| 74 | + render() { |
| 75 | + return ( |
| 76 | + <div> |
| 77 | + <ReactFC {...this.state} /> |
| 78 | + <div> |
| 79 | + <button onClick={this.onClick}>Click</button> |
| 80 | + </div> |
| 81 | + </div> |
| 82 | + ); |
| 83 | + } |
| 84 | +} |
| 85 | + |
| 86 | +export default ChartViewer; |
0 commit comments