Your search did not match any results.
Charts

Client-Side Data Processing

Documentation

The DevExtreme HTML5 Widgets can get data from a remote storage and process it on the client. This demo shows the Chart widget whose data source loads all data from a remote JSON file in one query. Afterwards, different filters are applied to this data depending on a value of the drop-down menu under the chart.

weatherbase.com
Copy to CodeSandBox
Apply
Reset
import React from 'react'; import DataSource from 'devextreme/data/data_source'; import CustomStore from 'devextreme/data/custom_store'; import Chart, { ValueAxis, Label, Legend, Series, Size, Export, LoadingIndicator } from 'devextreme-react/chart'; import SelectBox from 'devextreme-react/select-box'; class App extends React.Component { constructor(props) { super(props); this.state = { loading: true }; this.temperature = [6, 7, 8, 9, 10, 11, 12]; this.palette = ['#c3a2cc', '#b7b5e0', '#e48cba']; this.paletteIndex = 0; this.monthWeather = new DataSource({ store: new CustomStore({ load: () => { return fetch('../../../../data/monthWeather.json') .then((e) => { this.setState({ loading: false }); return e.json(); }) .catch(() => { throw 'Data Loading Error'; }); }, loadMode: 'raw' }), filter: ['t', '>', '6'], paginate: false }); this.customizePoint = () => { const color = this.palette[this.paletteIndex]; this.paletteIndex = this.paletteIndex === 2 ? 0 : this.paletteIndex + 1; return { color }; }; this.changeTemperature = (e) => { this.setState({ loading: true }); this.monthWeather.filter(['t', '>', e.value]); this.monthWeather.load(); this.setState({ loading: false }); }; } customizeLabel(e) { return `${e.valueText}${'&#176C'}`; } render() { return ( <div id={'chart-demo'}> <Chart title={'Temperature in Barcelona: January 2012'} dataSource={this.monthWeather} customizePoint={this.customizePoint}> <Size height={420} /> <ValueAxis> <Label customizeText={this.customizeLabel} /> </ValueAxis> <Series argumentField={'day'} valueField={'t'} type={'bar'} /> <Legend visible={false} /> <Export enabled={true} /> <LoadingIndicator show={this.state.loading} /> </Chart> <div className={'action'}> <SelectBox id={'choose-temperature'} dataSource={this.temperature} width={70} defaultValue={6} onValueChanged={this.changeTemperature} /> <div className={'label'}>Choose a temperature threshold, &deg;C: </div> </div> </div> ); } } export default App;
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App.js'; ReactDOM.render( <App />, document.getElementById('app') );
<!DOCTYPE html> <html> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.3/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/19.1.3/css/dx.light.css" /> <link rel="stylesheet" type ="text/css" href ="styles.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></script> <script type="text/javascript" src="config.js"></script> <script type="text/javascript"> System.import('./index.js'); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"></div> </div> </body> </html>
#choose-temperature { float: right; } .action { width: 320px; margin-top: 20px; } .label { padding-top: 9px; }
System.config({ transpiler: 'plugin-babel', paths: { 'npm:': 'https://unpkg.com/' }, defaultExtension: 'js', map: { 'react': 'npm:react@16/umd/react.development.js', 'react-dom': 'npm:react-dom@16/umd/react-dom.development.js', 'prop-types': 'npm:prop-types/prop-types.js', 'devextreme': 'npm:devextreme@19.1', 'devextreme-react': 'npm:devextreme-react@19.1', 'jszip': 'npm:jszip@3.1.3/dist/jszip.min.js', 'quill': 'npm:quill@1.3.6/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram', // SystemJS plugins 'plugin-babel': 'npm:systemjs-plugin-babel@0/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel@0/systemjs-babel-browser.js' }, packages: { 'devextreme': { defaultExtension: 'js' }, 'devextreme-react': { main: 'index.js' } }, babelOptions: { sourceMaps: false, stage0: true, react: true } });