-
Data Grid
- Overview
-
Data Binding
-
Paging and Scrolling
-
Editing
-
Grouping
-
Filtering and Sorting
- Focused Row
-
Row Drag & Drop
-
Selection
-
Columns
- State Persistence
-
Appearance
-
Templates
-
Data Summaries
-
Master-Detail
-
Export to PDF
-
Export to Excel
-
Adaptability
- Keyboard Navigation
-
Pivot Grid
- Overview
-
Data Binding
-
Field Chooser
-
Features
-
Export to Excel
-
Tree List
- Overview
-
Data Binding
- Sorting
- Paging
-
Editing
- Node Drag & Drop
- Focused Row
-
Selection
-
Filtering
-
Column Customization
- State Persistence
- Adaptability
- Keyboard Navigation
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Features
- Virtual Scrolling
-
Grouping
-
Customization
- Adaptability
-
Html Editor
-
Chat
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
Charts
- Overview
-
Data Binding
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Line Charts
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
-
Sparkline Charts
-
Tree Map
-
Funnel and Pyramid Charts
- Sankey Chart
-
Combinations
-
More Features
-
Export
-
Selection
-
Tooltips
-
Zooming
-
-
Gantt
- Overview
-
Data
-
UI Customization
- Strip Lines
- Export to PDF
- Sorting
-
Filtering
-
Gauges
- Overview
-
Data Binding
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Navigation
- Overview
- Accordion
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
- Pagination
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Resizable
-
-
Editors
- Overview
- Autocomplete
-
Calendar
- Check Box
- Color Box
- Date Box
-
Date Range Box
-
Drop Down Box
-
Number Box
-
Select Box
- Switch
-
Tag Box
- Text Area
- Text Box
- Validation
- Custom Text Editor Buttons
- Right-to-Left Support
- Editor Appearance Variants
-
Forms and Multi-Purpose
- Overview
- Button Group
- Field Set
-
Filter Builder
-
Form
- Radio Group
-
Range Selector
- Numeric Scale (Lightweight)
- Numeric Scale
- Date-Time Scale (Lightweight)
- Date-Time Scale
- Logarithmic Scale
- Discrete scale
- Custom Formatting
- Use Range Selection for Calculation
- Use Range Selection for Filtering
- Image on Background
- Chart on Background
- Customized Chart on Background
- Chart on Background with Series Template
- Range Slider
- Slider
-
Sortable
-
File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Actions and Lists
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
Related Demos:
Your search did not match any results.
Charts - Export Custom Markup
The DevExpress.viz.exportFromMarkup(markup, options) method allows you to export SVG content, including SVG-based DevExtreme components, to an image or document.
The markup parameter accepts valid SVG markup (see the prepareMarkup()
function in the code). To get the markup of a component, call its svg() method. The options parameter accepts an object whose fields configure export properties. In this demo, we specify the width
, height
, format
, and svgToCanvas
fields. Refer to the method description for more information on these and other available fields.
Was this demo helpful?
Feel free to share demo-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Backend API
<div class="chart_environment">
<div id="custom_markup_container">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
width="820px" height="420px">
<path d="M 13 407 L 128 407 L 232 39 L 13 39" fill="#6D39C3"></path>
<path d="M 46 381 L 161 381 L 265 13 L 46 13" opacity="0.5" fill="#6D39C3"></path>
<text transform="translate(30,89)"
style="fill: #FFFFFF; font-family: 'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana, sans-serif; font-size: 36px; font-weight: bold;">
<tspan x="0" y="0">Export </tspan>
<tspan x="0" y="38">Custom</tspan>
<tspan x="0" y="76">Markup</tspan>
</text>
<text transform="translate(32,199)"
style="opacity: 0.8; fill: #FFFFFF;font-family: 'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana, sans-serif;font-size: 14px;">
<tspan x="0" y="0">Export a chart with</tspan>
<tspan x="0" y="19.2">custom elements</tspan>
</text>
<path opacity="0.8" d="M 0 0 L 820 0 L 820 420 L 0 420 L 0 0" stroke="#999999" stroke-width="1"
stroke-linecap="butt" fill="none" stroke-linejoin="miter"></path>
</svg>
</div>
@section ExternalDependencies {
<script src="https://cdn.jsdelivr.net/npm/canvg/dist/browser/canvg.min.js"></script>
}
@(Html.DevExtreme().Chart()
.ID("chart")
.Palette(VizPalette.Violet)
.CommonSeriesSettings(s => s
.ArgumentField("State")
.Type(SeriesType.Bar)
.BarPadding(0.3)
)
.Series(s => {
s.Add().ValueField("Year1990").Name("1990");
s.Add().ValueField("Year2000").Name("2000");
s.Add().ValueField("Year2010").Name("2010");
s.Add().ValueField("Year2016").Name("2016");
s.Add().ValueField("Year2017").Name("2017");
})
.Legend(l => l
.VerticalAlignment(VerticalEdge.Bottom)
.HorizontalAlignment(HorizontalAlignment.Center)
)
.Title(t => t
.Text("Oil Production")
.Subtitle(s => s.Text("(in millions tonnes)"))
)
.DataSource(new object[] {
new { State = "Saudi Arabia", Year1990 = 319.6, Year2000 = 408.4, Year2010 = 407, Year2016 = 523, Year2017 = 496.6 },
new { State = "USA", Year1990 = 362.8, Year2000 = 287.9, Year2010 = 270.2, Year2016 = 438, Year2017 = 461.4 },
new { State = "China", Year1990 = 138.3, Year2000 = 163, Year2010 = 203, Year2016 = 199.7, Year2017 = 191.5 }
})
)
</div>
<div class="controls-pane">
@(Html.DevExtreme().Button()
.Icon("export")
.Text("Export")
.OnClick("exportChart")
.Type(ButtonType.Default)
.Width(145)
)
</div>
<script>
function exportChart() {
DevExpress.viz.exportFromMarkup(prepareMarkup(), {
width: 820,
height: 420,
margin: 0,
format: "png",
svgToCanvas: function(svg, canvas) {
var deferred = $.Deferred();
canvas.getContext('2d')
.drawSvg(new XMLSerializer().serializeToString(svg), 0, 0, null, null, {
renderCallback: deferred.resolve
});
return deferred.promise();
}
});
}
function prepareMarkup() {
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
svg.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
svg.setAttribute('version', '1.1');
svg.setAttribute('width', '820px');
svg.setAttribute('height', '420px');
svg.innerHTML = $("#custom_markup_container").html();
const group = document.createElementNS("http://www.w3.org/2000/svg", "g");
group.setAttribute('transform', 'translate(305,12)');
group.innerHTML = $('#chart').dxChart("instance").svg();
svg.appendChild(group);
return svg;
}
</script>
using DevExtreme.AspNet.Data;
using DevExtreme.AspNet.Mvc;
using DevExtreme.MVC.Demos.Models.SampleData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Web.Mvc;
namespace DevExtreme.MVC.Demos.Controllers {
public class ChartsController : Controller {
public ActionResult ExportCustomMarkup() {
return View();
}
}
}
#chart-demo {
height: 460px;
}
#chart {
position: absolute;
top: 12px;
right: 35px;
width: 480px;
height: 347px;
}
.chart_environment {
width: 820px;
position: relative;
margin: 0 auto;
}
.controls-pane {
text-align: center;
}