import * as React from 'react'; import * as ReactDOM from "react-dom"; import JqxChart, { IChartProps } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxchart'; import JqxGrid, { IGridProps, jqx } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxgrid'; import JqxTabs from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxtabs'; class App extends React.PureComponent<{}, IChartProps> { private myTabs = React.createRef(); private gridElement = React.createRef(); private chartElement = React.createRef(); constructor(props: {}) { super(props); const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; this.state = { colorScheme: 'scheme04', description: 'NASDAQ Composite compared to S&P 500', enableAnimations: true, padding: { left: 10, top: 5, right: 10, bottom: 5 }, seriesGroups: [ { series: [ { dataField: 'S&P 500', displayText: 'S&P 500' }, { dataField: 'NASDAQ', displayText: 'NASDAQ' } ], type: 'line', valueAxis: { axisSize: 'auto', tickMarks: { color: '#888888', visible: true }, title: { text: 'Daily Closing Price' }, visible: true } } ], showLegend: true, title: 'U.S. Stock Market Index Performance (2011)', titlePadding: { left: 90, top: 0, right: 0, bottom: 10 }, xAxis: { baseUnit: 'month', dataField: 'Date', formatFunction: (value: any) => { return (months[value.getMonth()]).toString(); }, gridLines: { color: '#888888', interval: 3, visible: true }, tickMarks: { color: '#888888', interval: 1, visible: true }, toolTipFormatFunction: (value: any) => { return (value.getDate() + '-' + months[value.getMonth()]).toString(); }, type: 'date', unitInterval: 1, valuesOnTicks: false } } } public render() { return (
  • US Indexes
  • NASDAQ compared to S&P 500
The S&P 500 index finished 2011 less than a point away from where it ended 2010 -- 0.04 points down to be exact. That's the smallest annual change in history. At its peak in April, the S&P had climbed more than 8%. But by October, at the lowest levels of the year, it was down more than 12%. The Nasdaq, meanwhile, lost 1.8% for the year.
); } private initGrid = () => { const source = { datafields: [ { name: 'Date' }, { name: 'S&P 500' }, { name: 'NASDAQ' } ], datatype: 'csv', url: 'nasdaq_vs_sp500.txt' }; const dataAdapter = new jqx.dataAdapter(source, { async: false, loadError: (xhr: any, status: any, error: any) => { alert('Error loading "' + source.url + '" : ' + error); } }); const columns: IGridProps["columns"] = [ { cellsformat: 'd', datafield: 'Date', text: 'Date', width: 250 }, { datafield: 'S&P 500', text: 'S&P 500', width: 150 }, { datafield: 'NASDAQ', text: 'NASDAQ' } ]; const grid = ; ReactDOM.render( grid, this.gridElement.current! ); }; private initChart = () => { // prepare the data const sourceChart = { datafields: [ { name: 'Date' }, { name: 'S&P 500' }, { name: 'NASDAQ' } ], datatype: 'csv', url: './../sampledata/nasdaq_vs_sp500.txt' }; const dataAdapterChart = new jqx.dataAdapter(sourceChart); // setup the chart const chart = ; ReactDOM.render( chart, this.chartElement.current! ); }; private initWidgets = (tab: any) => { switch (tab) { case 0: this.initGrid(); break; case 1: this.initChart(); break; } }; } export default App;