Skip to main content
All docs
V26.1
  • DevExpress Presentation API: Get Started with ChartEx (Office 2016 and later)

    • 4 minutes to read

    This topic describes how to create a ChartEx, add it to a presentation, and customize its settings.

    Add a ChartEx with a Data Series to a Presentation

    • Add a ChartEx object to a slide’s Shapes collection.

    • Specify the chart’s Width and Height properties.

    • Specify the chart’s Data property to define the data source for the chart. For more information on how to load data to a chart, refer to the following help topic: Load Data to Charts.

    • Create a series of the required type and add it to the chart’s Series collection.

    • Specify the series Arguments and Values properties to define the series data points.

    The following code snippet creates a chart with a title, adds a series, and specifies the series data:

    using DevExpress.Docs.Office;
    using DevExpress.Docs.Presentation;
    using System.Drawing;
    
    namespace PresentationApiSample;
    
    public class Program {
        public static async Task Main(string[] _) {
    
            // Create a presentation.
            Presentation presentation = new Presentation();
    
            // Reset the slide collection.
            presentation.Slides.Clear();
    
            // Add a blank slide.
            Slide slide = new Slide(SlideLayoutType.Blank);
            presentation.Slides.Add(slide);
    
            // Insert a chart on the slide.
            ChartEx chart = new ChartEx();
            slide.Shapes.Add(chart);
    
            // Set chart size to match the slide.
            chart.Width = presentation.SlideSize.Width;
            chart.Height = presentation.SlideSize.Height;
    
            // Create a waterfall series and specify data.
            WaterfallSeries series = new WaterfallSeries();
            series.Text = "Cash Flow";
            series.Arguments = new ChartStringData(new[] { "Start", "Jan", "Feb", "Mar", "End" });
            series.Values = new ChartNumericData(new[] { 0.0, 12.0, -5.0, 8.0, 15.0 });
    
            // Add the series to the chart.
            chart.Series.Add(series);
    
            // Set chart title formatting.
            chart.Title = new ChartTitleEx(new TextArea {
                Text = "Waterfall chart",
                Level1ParagraphProperties = new TextParagraphProperties {
                    TextProperties = new TextProperties { FontSize = 30, Fill = new SolidFill(Color.DarkBlue) }
                }
            });
        }
    }
    

    Supported Series Types

    The ChartExType enumeration lists chart types available for the ChartEx class:

    Chart type Series type
    Box and Whisker
    DevExpress Presentation API - Charts - Box and Whisker
    BoxAndWhiskerSeries
    Funnel
    DevExpress Presentation API - Charts - Funnel
    FunnelSeries
    Histogram
    DevExpress Presentation API - Charts - Histogram
    HistogramSeries
    Pareto
    DevExpress Presentation API - Charts - Pareto
    ParetoSeries
    Filled Map
    DevExpress Presentation API - Charts - Map
    MapSeries
    Sunburst
    DevExpress Presentation API - Charts - Sunburst
    SunburstSeries
    Treemap
    DevExpress Presentation API - Charts - Treemap
    TreemapSeries
    Waterfall
    DevExpress Presentation API - Charts - Waterfall
    WaterfallSeries

    Customize Chart Axes

    For details on how to access chart axes, refer to the following help topic:

    Read Tutorial: Chart Axes

    Customize Chart Appearance

    Use the chart ColorPalette property to specify the chart color palette. Use the chart PlotArea property to specify plot area settings (for example, fill color). Specify the chart Style property to apply one of the predefined styles to the chart. The following code snippet customizes chart appearance:

    chart.ColorPalette = ChartColorPalette.Monochromatic1;
    chart.PlotArea.Fill = new SolidFill(Color.AliceBlue);
    chart.Style = ChartExStyle.Style3;
    

    Customize Individual Series Points

    Use the series CustomDataPoints property to access points you can customize individually. This property is a dictionary that maps data point indices to DataPointEx objects. The following code snippet customizes the first data point of a line series:

    series.CustomDataPoints = new DataPointExDictionary { 
        {0, new DataPointEx { Fill = new SolidFill(Color.Red) } } 
    };