I have a chart that has a number of area series. I would like to z-order the series with the one in the back with the highest last-value of the series, and the one in the front lowest last value of the series.
How can I do that?
Thanks
Ed Dressel
Sort Area Series by last value
-
- Advanced
- Posts: 228
- Joined: Tue Aug 28, 2007 12:00 am
- Location: Oregon, USA
Re: Sort Area Series by last value
Hi Ed,
Is the following what you are trying to do?
Is the following what you are trying to do?
Code: Select all
uses series;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
for i:=0 to 3 do with Chart1.AddSeries(TAreaSeries.Create(self)) do FillSampleValues();
end;
procedure TForm1.Button1Click(Sender: TObject);
var i, n: Integer;
swapped: Boolean;
begin
n:=Chart1.SeriesCount;
swapped:=true;
while swapped do
begin
swapped:=false;
for i:=0 to n-2 do
begin
if Chart1[i].YValue[Chart1[i].Count-1] < Chart1[i+1].YValue[Chart1[i+1].Count-1] then
begin
Chart1.ExchangeSeries(i, i+1);
swapped:=true;
end;
end;
n:=n-1;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |