Trouble assigning series to other series

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
h.hasenack
Newbie
Newbie
Posts: 32
Joined: Tue Jul 21, 2009 12:00 am
Location: Nijmegen, Netherlands

Trouble assigning series to other series

Post by h.hasenack » Tue Jul 28, 2009 10:03 am

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
Attachments
TestTChart.zip
Demo for TCHartseries.Assign bug
(35.64 KiB) Downloaded 280 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Trouble assigning series to other series

Post by Yeray » Tue Jul 28, 2009 11:06 am

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]));
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

h.hasenack
Newbie
Newbie
Posts: 32
Joined: Tue Jul 21, 2009 12:00 am
Location: Nijmegen, Netherlands

Re: Trouble assigning series to other series

Post by h.hasenack » Tue Jul 28, 2009 11:59 am

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

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Trouble assigning series to other series

Post by Yeray » Tue Jul 28, 2009 2:49 pm

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
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply