Skip to main content
A newer version of this page is available. .

ChartControl.BoundDataChanged Event

Occurs every time a chart control generates its series points from the underlying data source.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v19.2.UI.dll

Declaration

public event BoundDataChangedEventHandler BoundDataChanged

Event Data

The BoundDataChanged event's data class is EventArgs.

Remarks

You can handle this event to change the way in which chart data is plotted before the chart displays it. In general, this event should be used to change a series’ SeriesBase.Visible property, or to change any properties of series labels or a series view type.

Note

Note that not all series’ properties can be changed in the BoundDataChanged event handler. For example, changing the following properties will have no effect:

For a code example, refer to How to: Individually Change the View Type of Automatically Created Series.

For more information, refer to Generate Series from a Data Source.

Note

When auto-bridging a chart with Pivot Grid, the BoundDataChanged event is raised after automatic settings are applied to the axes, legend, and some other elements. To learn more on these options, see Pivot Charting (Integration with a Pivot Grid Control).

Example

This example demonstrates how an auto-created series (a series generated automatically based on the series template settings) can be accessed at runtime, to individually change its view type.

This is performed in a special ChartControl.BoundDataChanged event of the chart control.

using System;
using System.Data;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...

namespace ChangeViewOfAnAutoSeries {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private DataTable CreateChartData() {
            // Create an empty table.
            DataTable table = new DataTable("Table1");

            // Add three columns to the table.
            table.Columns.Add("Month", typeof(String));
            table.Columns.Add("Section", typeof(String));
            table.Columns.Add("Value", typeof(Int32));

            // Add data rows to the table.
            table.Rows.Add(new object[] { "Jan", "Section1", 10 });
            table.Rows.Add(new object[] { "Jan", "Section2", 20 });
            table.Rows.Add(new object[] { "Jan", "Section3", 40 });
            table.Rows.Add(new object[] { "Feb", "Section1", 20 });
            table.Rows.Add(new object[] { "Feb", "Section2", 30 });
            table.Rows.Add(new object[] { "Feb", "Section3", 80 });
            table.Rows.Add(new object[] { "March", "Section1", 30 });
            table.Rows.Add(new object[] { "March", "Section2", 40 });
            table.Rows.Add(new object[] { "March", "Section3", 100 });

            return table;
        }

        private void Form1_Load(object sender, EventArgs e) {
            // Create a chart.
            ChartControl chart = new ChartControl();

            // Generate a data table and bind the chart to it.
            chart.DataSource = CreateChartData();

            // Specify data members to bind the chart's series template.
            chart.SeriesDataMember = "Month";
            chart.SeriesTemplate.ArgumentDataMember = "Section";
            chart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Value" });

            // Specify the template's series view.
            chart.SeriesTemplate.View = new SideBySideBarSeriesView();

            // Specify the BoundDataChanged event handler.
            chart.BoundDataChanged +=
                new BoundDataChangedEventHandler(chart_BoundDataChanged);

            // Specify the template's name prefix.
            chart.SeriesNameTemplate.BeginText = "Month: ";

            // Dock the chart into its parent, and add it to the current form.
            chart.Dock = DockStyle.Fill;
            this.Controls.Add(chart);
        }

        private void chart_BoundDataChanged(object sender, EventArgs e) {
            ChartControl chart = (ChartControl)sender;

            // Change the view of the "Month: Feb" series from 
            // SideBySideBarSeriesView to LineSeriesView.
            Series feb = chart.GetSeriesByName("Month: Feb");
            if (feb != null)
                feb.ChangeView(ViewType.Line);

            // Change the view of the "Month: March" series from 
            // SideBySideBarSeriesView to SplineSeriesView.
            Series march = chart.GetSeriesByName("Month: March");
            if (march != null)
                march.ChangeView(ViewType.Spline);
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the BoundDataChanged event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also