Page 1 of 1

ChangeType doesn´t preserve order of X values?

Posted: Thu Sep 21, 2006 4:01 pm
by 9642212
Hi,

When I use the Series.ChangeType method on a series, that already has specific ordering set for the X values, this ordering is not preserved while changing to another type.

Code: Select all

Series mySeries = tChart.Series.Add(typeof(FastLine));
mySeries.XValues.Order = ValueListOrder.None;
// Append a couple of points            
Random rnd = new Random();
for (int pointIndex = 0; pointIndex < 10; pointIndex++)
{
    mySeries.Add(rnd.NextDouble(),rnd.NextDouble());
}

--> this would result in a plot showing random lines

// Change the plot type
Series.ChangeType(ref mySeries, typeof(Line));

--> this results in lines that are ordered according to X-axis value (default ascending ordered)
I´m using the stable v2.0.2306.26232 version of the library. Didn´t find a bugfix that fixes it in the latest Debug build (in the release notes).

Regards

[/code]

Posted: Fri Sep 22, 2006 7:48 am
by narcis
Hi dimitrig,

This is because line series is designed to plot sequential data. Please read this thread where this is explained.

Posted: Fri Sep 22, 2006 8:22 am
by 9642212
Thanks for the reply.

I understand that a line series defaults to sequential data, nevertheless it is perfectly possible to plot non-sequential data on it (when setting the order properly to None), as can be seen in this image:
Image

So I would expect that when you use the ChangeType method, before the values are copied to the new series, the ordering is preserved instead of gone back to the default for the new plot type.
So in the ChangeType method I would expect that there are 2 lines somewhere that state:

Code: Select all

newSeries.XValues.Order = oldSeries.XValues.Order;
newSeries.YValues.Order = oldSeries.YValues.Order;
Is it really the purpose that this does not happen?
If it is, is there a known workaround to easily change the plot type, but preserve the order?

Posted: Fri Sep 22, 2006 11:36 am
by narcis
Hi dimitrig,

Yes, you are right, this is a bug (TF02011763) which I've added to our defect list to be fixed for future releases. The only solution I've found is creating a new series, manually copying all original series to the new series and finally removing the old series:

Code: Select all

    private void button1_Click(object sender, EventArgs e)
    {
      Line line1 = new Line(tChart1.Chart);

      line1.XValues.Order = tChart1[0].XValues.Order;
      line1.Color = tChart1[0].Color;

      for (int i = 0; i < tChart1[0].Count; i++)
      {        
        line1.Add(tChart1[0].XValues[i], tChart1[0].YValues[i]);
      }

      tChart1.Series.Remove(tChart1[0]);      
    }

Posted: Fri Mar 09, 2007 2:12 pm
by 9642212
Hi,

I'm using the latest version of the library (2.0.2586.24039), and this bug is still present (half year has passed since then). To me, it looks that this can be easily fixed, so I would've expected to see it fixed earlier. Any idea when this will be fixed and/or is it possible to speed up this fix, since it's important for us that this is solved?

Regards

Posted: Fri Mar 09, 2007 3:32 pm
by narcis
Hi dimitrig,

I can't tell you for sure when this will be fixed. I've increased its priority in the list to be fixed sooner. Please be aware at this forum for new release announcements and what's implemented on them.