Page 1 of 1

How to add NULL array to series

Posted: Wed May 07, 2014 4:13 am
by 16566869
Q1:We know that NULL values could be added to series by AddNull() function.
Is there a way to Add a null array to series, something like AddNullArray?

Q2: SetNull() function can be used to set specified point to NULL,
Is there a function to set all the point to NULL?

Re: How to add NULL array to series

Posted: Wed May 07, 2014 7:40 am
by yeray
Hello,
elmec wrote:Q1:We know that NULL values could be added to series by AddNull() function.
Is there a way to Add a null array to series, something like AddNullArray?
AddArray function just loops into the given array and calls the Add() function. If you want an addNullArray, you could create it yourself. Ie:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
    tmpVal: array of double;
begin
  SetLength(tmpVal, 20);
  for i:=Low(tmpVal) to High(tmpVal) do
    tmpVal[i]:=50+random*100;

  Chart1.AddSeries(TPointSeries);

  AddArrayNull(Chart1[0], tmpVal);
end;

function TForm1.AddArrayNull(const Series: TChartSeries; const Values:array of TChartValue):Integer;
var t : Integer;
begin
  with Series do
  begin
    BeginUpdate;
    try
      result:=High(Values)-Low(Values)+1;
      for t:=Low(Values) to High(Values) do
        SetNull(Add(Values[t]));
    finally
      EndUpdate;
    end;
  end;
end;
elmec wrote:Q2: SetNull() function can be used to set specified point to NULL,
Is there a function to set all the point to NULL?
As above, you'll have to loop your array of points. Ie:

Code: Select all

  for i:=0 to Count-1 do
    SetNull(i);