This is a migrated thread and some comments may be shown as answers.

Multiple Y axes errors

1 Answer 56 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Joe Liu
Top achievements
Rank 1
Joe Liu asked on 29 Mar 2010, 11:36 AM

when i use this Multiple Y axes feature, i found this odd exception hard to address,

i create a chart with multiple Y axes using this code:

            Chart1.DefaultView.ChartArea.AdditionalYAxes.Add(new AxisY());
            Chart1.DefaultView.ChartArea.AdditionalYAxes.Add(new AxisY());
            Chart1.DefaultView.ChartArea.AdditionalYAxes[0].AxisName = "Secondary";
            Chart1.DefaultView.ChartArea.AdditionalYAxes[1].AxisName = "Tertiary";

then i bind data on it and it's running correctly first time.
and i use a event(say button click) to trigger this code:

            Chart1.SeriesMappings.Clear();
            Chart1.DefaultView.ChartArea.AdditionalYAxes.Clear();

after this i run the same code above to add AdditionalYAxes and bind data again, and in throw a null reference exception everytime.

complete codes are like this:

        public MultipleAxesTest()
        {
            InitializeComponent();

            this.FillSampleChartData();
        }
        private void FillSampleChartData()
        {
            Chart1.DefaultView.ChartArea.AdditionalYAxes.Add(new AxisY());
            Chart1.DefaultView.ChartArea.AdditionalYAxes.Add(new AxisY());
            Chart1.DefaultView.ChartArea.AdditionalYAxes[0].AxisName = "Secondary";
            Chart1.DefaultView.ChartArea.AdditionalYAxes[1].AxisName = "Tertiary";

            Chart1.DefaultView.ChartArea.DataSeries.Add(GenerateSeries(0, 10, "Legend1", string.Empty, new BarSeriesDefinition()));
            Chart1.DefaultView.ChartArea.DataSeries.Add(GenerateSeries(15, 50, "Legend2", "Secondary", new SplineSeriesDefinition()));
        }

        private static DataSeries GenerateSeries(int minRange, int maxRange, string legendLabel, string axisName, ISeriesDefinition definition)
        {
            DataSeries series = new DataSeries();
            Random r = new Random();
            series.Definition = definition;
            series.LegendLabel = legendLabel;
            series.Definition.AxisName = axisName;

            for (int i = 0; i < 6; i++)
                series.Add(new DataPoint(r.Next(minRange, maxRange)));

            return series;
        }

        private void previewButton_Click(object sender, RoutedEventArgs e)
        {
            Chart1.SeriesMappings.Clear();
            Chart1.DefaultView.ChartArea.AdditionalYAxes.Clear();
            this.FillSampleChartData();
        }

every time i trigger this event there's this exception.
and if i skip those two lines:
            Chart1.SeriesMappings.Clear();
            Chart1.DefaultView.ChartArea.AdditionalYAxes.Clear();

and it's ok, but obviously this is not the case as intend :(

This sounds a bug to me.
I would appreciate if anyone can give me more details about this behavior.

Edit: this only occur when i use 2010 Q1 version. i just try 2009 Q3 and it's running correctly.

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Velin
Telerik team
answered on 31 Mar 2010, 05:51 PM
Hello Joe Liu,

Indeed, there is an issue in this scenario. Our developers will investigate it further and will provide a fix with the next internal build(coming in the end of the week).

Please, accept our apologies for the inconvenience. Your Telerik points have been updated.

Kind regards,
Velin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Chart
Asked by
Joe Liu
Top achievements
Rank 1
Answers by
Velin
Telerik team
Share this question
or