import * as React from 'react'; import JqxChart, { IChartProps, jqx } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxchart'; import JqxRangeSelector, { IRangeSelectorProps } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxrangeselector'; export interface IState extends IChartProps { labelsFormatFunction: IRangeSelectorProps['labelsFormatFunction']; markersFormatFunction: IRangeSelectorProps['markersFormatFunction']; } class App extends React.PureComponent<{}, IState> { constructor(props: {}) { super(props); let recordsArray: any[] = []; const source: any = { datafields: [ { name: 'month' }, { name: 'min' }, { name: 'max' }, ], datatype: 'json', url: 'weather_geneva.txt' }; this.state = { labelsFormatFunction: (data: any): string => { if (recordsArray[data]) { return "1 " + recordsArray[data].month; } else { return "31 " + recordsArray[data - 1].month; } }, markersFormatFunction: (data: any): string => { if (recordsArray[data]) { return "1 " + recordsArray[data].month; } else { return "31 " + recordsArray[data - 1].month; } }, padding: { left: 5, top: 0, right: 0, bottom: 0 }, seriesGroups: [ { series: [ { dataField: 'max', lineColor: 'green', displayText: 'Max Temperature' }, { dataField: 'min', lineColor: 'red', displayText: 'Min Temperature' } ], showLabels: false, type: 'line', valueAxis: { visible: false } } ], source: new jqx.dataAdapter(source, { async: false, autoBind: true, loadComplete: (data: any, status: any, xhr: any, records: any[]): void => { recordsArray = records; }, loadError: (xhr: any, status: any, error: any) => { alert('Error loading "' + source.url + '" : ' + error); } } ), titlePadding: { left: 0, top: 0, right: 0, bottom: 0 }, xAxis: { visible: false } } } public render() { return (