Skip to main content

How to: Export a Chart to HTML and MHT

  • 2 minutes to read

The following example demonstrates how to export a chart to HTML and MHT files.

To export the chart, use the appropriate ExportTo~ method (e.g., ChartControlBase.ExportToHtml, ChartControlBase.ExportToPdf, ChartControlBase.ExportToMht etc.).

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" x:Class="Export.MainWindow"
        Title="MainWindow" Height="350" Width="525">

    <Grid>
        <dxc:ChartControl x:Name="chartControl" >
            <dxc:ChartControl.Legend>
                <dxc:Legend/>
            </dxc:ChartControl.Legend>
            <dxc:XYDiagram2D>
                <dxc:BarSideBySideSeries2D DisplayName="Series 1">
                    <dxc:SeriesPoint Argument="A" Value="2"/>
                    <dxc:SeriesPoint Argument="B" Value="13"/>
                    <dxc:SeriesPoint Argument="C" Value="15"/>
                    <dxc:SeriesPoint Argument="D" Value="17"/>
                </dxc:BarSideBySideSeries2D>
            </dxc:XYDiagram2D>
        </dxc:ChartControl>
        <StackPanel Orientation="Horizontal">
            <Button Content="Export To HTML"   VerticalAlignment="Top" Width="95" Click="Button_Click"/>
            <Button Content="Export To MHT"   VerticalAlignment="Top"  Width="95" Click="Button_Click_1"/>
        </StackPanel>
    </Grid>
</Window>