Fixing Data series for the ... chart can not have a different number of data points problem

by Al Beecy April 15, 2009
Recently I was getting an error message from a Dundas chart saying that "Data series for the Stacked Area chart can not have a different number of data points." while using the DataBindCrossTab() method. I was using a stacked area chart, but the error or a similar one occurs on a number of different stacked chart types.

Turns out that after databinding, but before setting the chart type, you must call the AlignDataPointsByAxisLabel() method as shown:

    //databind
    Chart1.DataBindCrossTab(
        new DataView(myDataTable),
        "seriesGroupByField",
        "xField",
        "yField",
        string.Empty);
    //create fake data points if needed
    Chart1.AlignDataPointsByAxisLabel();
    //set chart type
    foreach (Series series in Chart1.Series)
    {
        series.Type = SeriesChartType.StackedArea;
    }

What the AlignDataPointsByAxisLabel() method does is fake up data points as needed so that all series have the same number.

Tags: ,

Dundas Chart

Comments

April 18, 2009 #

DotNetKicks.com

Trackback from DotNetKicks.com

Fixing Data series for the ... chart can not have a different number

DotNetKicks.com

April 18, 2009 #

Web Development Community

Trackback from Web Development Community

Fixing Data series for the ... chart can not have a different number

Web Development Community

June 14, 2009 #

DotNetShoutout

Fixing Data series for the ... chart can not have a different number of data points problem

Thank you for submitting this cool story - Trackback from DotNetShoutout

DotNetShoutout

September 9, 2009 #

Anonymous

Thanks! This has fixed the error!

Anonymous United Kingdom

Powered by BlogEngine.NET1.5.0.7 | Theme by Mads Kristensen