Add extra ChartValueList on TLineSeries

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Lenfors
Newbie
Newbie
Posts: 49
Joined: Thu Sep 20, 2007 12:00 am

Add extra ChartValueList on TLineSeries

Post by Lenfors » Wed Jan 27, 2010 2:16 pm

Hello!

I have several TLineSeries containing lots of data. Now I would like to filter the "visible" data y-serie but still keep my original values.
Of course I could have duplicate TLineSeries one containing the original data (invisible) and another TLineSeries containing the filtered data, or a separate array containing the original. The proble is my project is huge and this would generate changes all over!

My ide is to add a a ChartValueList to the TLineSeries and save the original data there, is this a good ide?

ChartValueList := TChartValueList.Create(Series3, 'UnFiltered');
Series3.ValuesList.Add(ChartValueList);

Now Series3.ValuesList.Count reports 4! I thought it would now be 3, X, Y and UnFiltered!?

Then I load my original data:
For I := 0 To Series3.Count - 1 Do
Begin
Series3.ValuesList[2].Items := Series3.YValue;
End;

Do I have to dimension the Items array before assigning data?

All this seems to worke fine, except for one thing. When I close my application I get an EInvalidPointer exception.
Any ideas?

Regards, Mikael

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

Re: Add extra ChartValueList on TLineSeries

Post by Yeray » Thu Jan 28, 2010 3:18 pm

Hi Mikael,

Here is how I found that this could be done. Please note that the sentence Series3.ValuesList.Add(ChartValueList); is redundant as you've already given the series to the TChartValueList.Create method.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var ChartValueList: TChartValueList;
    i: integer;
begin
  Chart1.View3D:=false;
  Chart1.AddSeries(TLineSeries.Create(self));
  Chart1[0].FillSampleValues();

  ShowMessage(inttostr(Chart1[0].ValuesList.Count));
  ChartValueList := TChartValueList.Create(Chart1[0], 'UnFiltered');

  //option1: copy all Y values to the new valuelist at the same time.
  //Chart1[0].ValuesList[2].Count:=Chart1[0].Count;
  //Chart1[0].ValuesList[2].Value:=Chart1[0].YValues.Value;

  //option2: copy all Y values to the new valuelist one by one being able to modify them.
  SetLength(Chart1[0].ValuesList[2].Value, Chart1[0].Count);
  for i:=0 to Chart1[0].Count-1 do
    Chart1[0].ValuesList[2].Value[i]:=Chart1[0].ValuesList[1].Value[i]/10;

  ShowMessage(IntToStr(Chart1[0].ValuesList.Count) + ' valuelists // Y value 0: ' + FloatToStr(Chart1[0].ValuesList[1].Value[0]) + '// extra value 0: ' + FloatToStr(Chart1[0].ValuesList[2].Value[0]));
end;
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