Page 1 of 1

Trouble assigning series to other series

Posted: Tue Jul 28, 2009 10:03 am
by 10553957
There is some trouble when using tChartseries.Assign to copy settings and data from one series to another.

Please check the attached zip file for a demo

1) CLick btTestSTack to add some data
2) Edit the chart , take a look at BarSum series, there is an AddTee function -> OK :)
3) click btTestCloneChart
4) Take a look at the newly opened chart window. a nice cloned chart.
5) from the main form open the chart editor once more. Take a look at BarSum series, :shock: the datasource is not the teeAdd function anymore.
6) click btTestCloneChart once more
7) :shock: this cloned chart looks a lot different? - well of course, the source chart has been altered! :cry:

This must be wrong: the Assign method should never change the provided source object.

I have currently no fix for this. Yet I need to clone charts on a regular basis, so please tell me how to accomplish this in the official Teemach way, without destroying /altering my source chart...

Regards - hans

Re: Trouble assigning series to other series

Posted: Tue Jul 28, 2009 11:06 am
by yeray
Hi Hans,

Yes you are right. I'll add this to be revised for future releases.
In the meanwhile, I've changed your btTestCloneChart for the following and it seems to work fine. Could you please try it?

Code: Select all

  f:=TfrmDynChart.Create(self);
  f.Show;

  for i:=0 to Chart1.SeriesCount-1 do
    f.Chart1.AddSeries(CloneChartSeries(Chart1[i]));

Re: Trouble assigning series to other series

Posted: Tue Jul 28, 2009 11:59 am
by 10553957
Yes that works just fine. :D

But still I have to call my 'FixupDatasources' because the cloned series in the new chart still use the series in the original chart as a datasources :roll: . This could be WAD though.

:idea: Maybe it's a good idea to have a CloneChart routine as well as a CloneChartSeries that also does the datasource fixup handling... Anyway, in my app I can revise some code now just by using CloneChartseries - it's just better that way.

Regards - Hans

Re: Trouble assigning series to other series

Posted: Tue Jul 28, 2009 2:49 pm
by yeray
Hi Hans,

Well, for cloning charts we usually recommend to do through Streams. Please, take a look at the following topics where different suggestions where discussed:
http://www.teechart.net/support/viewtop ... f=3&t=7358
http://www.teechart.net/support/viewtop ... f=3&t=7121