Page 1 of 1
ExchangeSeries not working with dbchart?
Posted: Sun Nov 08, 2009 10:47 pm
by 10054213
I tried bringing Series2 to front with ExchangeSeries() in a 2 series dbchart but with no effect.
I tried both variations: dbChart1.ExchangeSeries(series1,series2) and dbChart1.ExchangeSeries(Series2,Series1);
Could it be that ExchangeSeries() works only for tchart and not for tdbchart?
Brgds
Steffen;
Re: ExchangeSeries not working with dbchart?
Posted: Mon Nov 09, 2009 2:44 pm
by yeray
Hi Steffen,
Could you please try the following code in an empty DBChart? It seems to work fine here:
Code: Select all
uses series;
procedure TForm1.FormCreate(Sender: TObject);
begin
DBChart1.AddSeries(TLineSeries.Create(self));
DBChart1.AddSeries(TLineSeries.Create(self));
DBChart1[0].FillSampleValues(25);
DBChart1[1].FillSampleValues(25);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DBChart1.ExchangeSeries(DBChart1[0], DBChart1[1]);
end;
I fit doesn't work for you, could you please tell us what exact TeeChart version are you using?
Re: ExchangeSeries not working with dbchart?
Posted: Mon Nov 16, 2009 12:14 pm
by 10054213
Dear Yeray,
thanks for the demo app. It helped my understand that the nature of my problem is that I have 2 cross tab series (a bar and a point one) which need to be exchanged (the points should be in front). Each cross tab generates a multitude of series and the indexes of the two kinds of series are mixed.
Now, I can identify the two matching pairs of series by their title (dbchart1.Series.Title) and exchange them pair by pair in a for next loop.
Anyhow, I'd rather prefer to avoid this. I tried deleting both crosstab-series and create them in an opposite order but this failed.
Can you imagine a smoother?
Best regards,
Steffen
Re: ExchangeSeries not working with dbchart?
Posted: Mon Nov 16, 2009 1:57 pm
by yeray
Hi Steffen,
You can use two variables to point to your bar and point series respectively. With that, you won't need to loop into your chart's series list. For example:
Code: Select all
uses series;
var bar1: TBarSeries;
points1: TPointSeries;
procedure TForm1.FormCreate(Sender: TObject);
begin
bar1:=Chart1.AddSeries(TBarSeries.Create(self)) as TBarSeries;
points1:=Chart1.AddSeries(TPointSeries.Create(self)) as TPointSeries;
bar1.FillSampleValues(25);
points1.FillSampleValues(25);
Chart1.AddSeries(TLineSeries.Create(self));
Chart1.AddSeries(TLineSeries.Create(self));
Chart1[2].FillSampleValues(25);
Chart1[3].FillSampleValues(25);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Chart1.ExchangeSeries(bar1, points1);
end;
Re: ExchangeSeries not working with dbchart?
Posted: Tue Nov 17, 2009 8:08 am
by 10054213
Dear Yeray,
that works nicely so far, thank you very much.
Still, I do not want to create series with .Addseries but in Object designer as all settings could be set easier.
So, I tried to assign:
bar1:=Series1 AS TBarSeries;
points1 := Series2 AS TPointSeries;
But with this, dbChart1.ExchangeSeries(bar1, points1) would again only exchange "series1" against "series2" not "series-set 1" against "series-set 2".
How would I adress a crosstab series-set instead of an individual series?
Does teechart make a difference between these two kinds of series at all?
Brgds.
Steffen
Re: ExchangeSeries not working with dbchart?
Posted: Tue Nov 17, 2009 10:32 am
by yeray
Hi Steffen,
I think I don't understand what is your exact situation. Could you please send us a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.