import * as React from 'react'; import JqxChart, { IChartProps, jqx } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxchart'; import JqxDropDownList, { IDropDownListProps } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxdropdownlist'; import JqxSlider from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxslider'; export interface IState extends IChartProps { colorsSchemesList: IDropDownListProps['source']; schemeSelectedIndex: IDropDownListProps['selectedIndex']; seriesList: IDropDownListProps['source']; seriesSelectedIndex: IDropDownListProps['selectedIndex'] } class App extends React.PureComponent<{}, IState> { private myChart = React.createRef(); constructor(props: {}) { super(props); this.sliderStartAngle = this.sliderStartAngle.bind(this); this.sliderRadius = this.sliderRadius.bind(this); this.dropDownListColor = this.dropDownListColor.bind(this); this.dropDownListSeries = this.dropDownListSeries.bind(this); const source: any = { datafields: [ { name: 'Year' }, { name: 'HPI' }, { name: 'BuildCost' }, { name: 'Population' }, { name: 'Rate' } ], datatype: 'tab', url: 'homeprices.txt' }; this.state = { colorScheme: 'scheme01', colorsSchemesList: ['scheme01', 'scheme02', 'scheme03', 'scheme04', 'scheme05', 'scheme06', 'scheme07', 'scheme08'], description: 'Source: http://www.econ.yale.edu/~shiller/data.htm', padding: { left: 5, top: 5, right: 5, bottom: 5 }, schemeSelectedIndex: 0, seriesGroups: [ { polar: true, radius: 120, series: [ { dataField: 'HPI', displayText: 'Real Home Price Index', opacity: 0.7, lineWidth: 1, radius: 2 }, { dataField: 'BuildCost', displayText: 'Building Cost Index', opacity: 0.7, lineWidth: 1, radius: 2 } ], type: 'splinearea', valueAxis: { labels: { autoRotate: true, formatSettings: { decimalPlaces: 0 } } } } ], seriesList: ['splinearea', 'spline', 'column', 'scatter', 'stackedcolumn', 'stackedsplinearea', 'stackedspline'], seriesSelectedIndex: 0, source: new jqx.dataAdapter(source, { async: false, autoBind: true, loadError: (xhr: any, status: any, error: any) => { alert('Error loading "' + source.url + '" : ' + error); } }), title: 'U.S. Real Home Price vs Building Cost Indeces (1950-2019)', titlePadding: { left: 0, top: 0, right: 0, bottom: 5 }, xAxis: { dataField: 'Year', labels: { autoRotate: true }, maxValue: 2010, unitInterval: 10, valuesOnTicks: true } }; } public render() { return (

Move the slider to rotate:

Select the series type:

Move the slider to change the radius:

Select color scheme:

); } private sliderStartAngle(event: any): void { const value = event.args.value; const newSeriesGroups = this.state.seriesGroups; newSeriesGroups![0].startAngle = value; newSeriesGroups![0].endAngle = value + 360; this.setState({ seriesGroups: newSeriesGroups }, () => { this.myChart.current!.update(); }); } private sliderRadius(event: any): void { const value = event.args.value; const newSeriesGroups = this.state.seriesGroups; newSeriesGroups![0].radius = value; this.setState({ seriesGroups: newSeriesGroups }, () => { this.myChart.current!.update(); }); } private dropDownListColor(event: any): void { const value = event.args.item.value; const index = event.args.index; this.setState({ colorScheme: value, schemeSelectedIndex: index }); } private dropDownListSeries(event: any): void { const value = event.args.item.value; const index = event.args.index; const newSeriesGroups = this.state.seriesGroups; newSeriesGroups![0].type = value; this.setState({ seriesGroups: newSeriesGroups, seriesSelectedIndex: index }, () => { this.myChart.current!.update(); }); } } export default App;