Your search did not match any results.
Charts

Export and Printing API

Documentation

DevExtreme HTML5 Data Visualization Widgets fulfill their purpose even outside the browser, thanks to the client-side export and printing features. This demo illustrates the exportTo and print API methods used for exporting and printing from code. Below the Chart, you see the «Print» and «Export» buttons. A click on the «Print» button calls the Print Dialog Window with a document ready to be printed. In this window, you can change printing options and send the document to your printer. A click on the «Export» button saves a PNG file with the widget in your local storage. PDF, JPEG, SVG, and GIF formats are supported as well.

en.wikipedia.org
Copy to CodeSandBox
Apply
Reset
import React from 'react'; import { dataSource } from './data.js'; import Chart, { Series, Legend, Tooltip, ArgumentAxis, Label, ValueAxis, VisualRange } from 'devextreme-react/chart'; import PrintButton, { } from 'devextreme-react/button'; import ExportButton, { } from 'devextreme-react/button'; class App extends React.Component { constructor(props) { super(props); this.chartRef = React.createRef(); this.printChart = () => { this.chart.print(); }; this.exportChart = () => { this.chart.exportTo('Example', 'png'); }; this.CustomizeTooltipText = this.CustomizeTooltipText.bind(this); } render() { return ( <React.Fragment> <Chart id={'chart'} ref={this.chartRef} dataSource={dataSource} title={'The Highest Mountains'} > <Series argumentField={'name'} valueField={'height'} type={'bar'} color={'#E55253'} /> <Tooltip enabled={true} customizeTooltip={this.CustomizeTooltipText}> </Tooltip> <Legend visible={false} /> <ArgumentAxis visible={true} /> <ValueAxis> <VisualRange startValue={8000} /> <Label customizeText={this.CustomizeLabelText} /> </ValueAxis> </Chart> <div className={'row'} id={'buttonGroup'}> <PrintButton className={'row-element'} icon={'print'} text={'Print'} onClick={this.printChart}> </PrintButton> &nbsp; <ExportButton className={'row-element'} icon={'export'} text={'Export'} onClick={this.exportChart} /> </div> </React.Fragment> ); } get chart() { return this.chartRef.current.instance; } CustomizeTooltipText(arg) { return { text: `<span class='title'>${arg.argumentText}</span><br />&nbsp;<br />` + `System: ${arg.point.data.system}<br />` + `Height: ${ arg.valueText} m` }; } CustomizeLabelText() { return `${this.value} m`; } } 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.7/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.7/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>
#chart { height: 440px; width: 100%; margin-bottom:30px; } #buttonGroup { text-align: center; margin-bottom: 20px; } .row-element { margin: 0 20px; } .title { font-size: 15px; font-weight: 500; }
var dataSource = [{ name: 'Everest', height: 8848, system: 'Mahalangur Himalaya' }, { name: 'Godwin Austen', height: 8611, system: 'Baltoro Karakoram' }, { name: 'Kangchenjunga', height: 8586, system: 'Kangchenjunga Himalaya' }, { name: 'Lhotse', height: 8516, system: 'Mahalangur Himalaya' }, { name: 'Makalu', height: 8485, system: 'Mahalangur Himalaya' }, { name: 'Cho Oyu', height: 8188, system: 'Mahalangur Himalaya' }]; export { dataSource };
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.7/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram', 'devexpress-gantt': 'npm:devexpress-gantt', // 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 } });