Your search did not match any results.

Charts - Export and Printing API

You can use two approaches to print and export the Chart: call methods, or add a built-in button with drop-down options. The supported export formats are PNG, PDF, JPEG, SVG, and GIF.

en.wikipedia.org
Backend API
@(Html.DevExtreme().Chart() .ID("chart") .DataSource(new[] { new { name = "Everest", height = 8848, system = "Mahalangur Himalaya" }, new { name = "Godwin Austen", height = 8611, system = "Baltoro Karakoram" }, new { name = "Kangchenjunga", height = 8586, system = "Kangchenjunga Himalaya" }, new { name = "Lhotse", height = 8516, system = "Mahalangur Himalaya" }, new { name = "Makalu", height = 8485, system = "Mahalangur Himalaya" }, new { name = "Cho Oyu", height = 8188, system = "Mahalangur Himalaya" } }) .Series(s => s.Add() .ArgumentField("name") .ValueField("height") .Type(SeriesType.Bar) .Color("#E55253") ) .Tooltip(t => t .Enabled(true) .CustomizeTooltip(@<text> function(arg) { return { text: "<span class='title'>" + arg.argumentText + "</span><br />&nbsp;<br />" + "System: " + arg.point.data.system + "<br />" + "Height: " + arg.valueText + " m" }; } </text>)) .Title("The Highest Mountains") .Legend(l => l.Visible(false)) .ArgumentAxis(a => a.Visible(true)) .ValueAxis(a => a.Add() .VisualRange(range => range.StartValue(8000)) .Label(l => l.CustomizeText(@<text> function() { return this.value + " m"; } </text>))) ) <div id="buttonGroup"> @(Html.DevExtreme().Button() .Icon("print") .Text("Print") .OnClick("print") ) @(Html.DevExtreme().Button() .Icon("export") .Text("Export") .OnClick("exportChart") ) </div> <script> function getChartInstance() { return $("#chart").dxChart("instance"); } function print() { getChartInstance().print(); } function exportChart() { getChartInstance().exportTo("Example", "png"); } </script>
using DevExtreme.AspNet.Data; using DevExtreme.AspNet.Mvc; using DevExtreme.NETCore.Demos.Models; using DevExtreme.NETCore.Demos.Models.SampleData; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; namespace DevExtreme.NETCore.Demos.Controllers { public class ChartsController : Controller { public ActionResult ExportAndPrintingAPI() { return View(); } } }
#chart { height: 440px; margin-bottom:30px; } #buttonGroup { text-align: center; margin-bottom: 20px; } #buttonGroup > .dx-button { margin: 0 20px; } .title { font-size: 15px; font-weight: 500; }

Use Methods to Export and Print Chart

Use the exportTo(fileName, format) and print() methods to export and print the Chart. In this demo, two buttons below the chart implement the print and export functionality. A click on the "Print" button calls the Print dialog window, and a click on the "Export" button saves a file with the component to your local storage. You can specify the file name and format in the exportTo(fileName, format) method.

Export and Print Chart with a Built-in Menu

To automatically create a button with export and print options, use the export object and set its enabled property to true. If you want to disable printing, set the printingEnabled property to false.

Set the formats property to specify an array of available export formats. The fileName property allows you to specify the name of the exported file.

You can see how this approach works in the following demo: JSON Data.

Handle Export Events

Use the following events to handle export:

NOTE

Need to create printable documents simply? Try our .NET-based DevExpress Reports: they ship with an intuitive Visual Studio Report Designer, Web Report Designer for end-user ad-hoc reporting, and a rich set of report controls, including cross tabs and charts.

You can generate a variety of report types — from simple mail-merge, table, and vertical reports to master-detail (hierarchical) and cross-tab reports, print or export them to PDF, Excel, and other formats.

Develop using VS Code? Leverage the capabilities of a brand new VS Code Report Designer extension to create and edit reports/documents on any platform, be it Windows, macOS, or Linux.

Get Started with DevExpress Reports | Explore Demos