Page 1 of 1

Using DBChart with text data

Posted: Wed Feb 12, 2020 7:42 pm
by 16586540
Good morning

I use DBChart to access data from a database and/or a memory table, using XValues, YValues and DataSource in TSeries. Now I wish to add a series with the data either in an array or from calculations. Is there a straightforward way to do this, or do I have to populate a memory table with the data points?

Thank you for your attention

Regards

Errol

Re: Using DBChart with text data

Posted: Fri Feb 14, 2020 10:32 am
by Marc
Hello Errol,

Yes, you could use code similar to this:

Code: Select all

var vals : array of double;
    i : Integer;
begin
  SetLength(vals, 8);
  for i := 0 to 7 do
     vals[i] := Random(10);

  Series1.AddArray(vals);
end;
You could send x and y arrays to the method:
ie.

Code: Select all

Series1.AddArray(xVals,yVals);
Regards,
Marc

Re: Using DBChart with text data

Posted: Mon Feb 17, 2020 7:00 am
by 16586540
Hi Marc
Thanks for the solution to my problem. However, I am trying to plot a closed polygon, and I can only plot values in an increasing-X direction. How can I plot the data in array index order.
Thanks and regards
Errol

Re: Using DBChart with text data

Posted: Mon Feb 17, 2020 4:42 pm
by Marc
Hello Errol,

It sounds like the ValueList Order may be what you need here.

Before you add the data, set:

Code: Select all

Series1.XValues.Order := loNone;
Series1.YValues.Order := loNone;
Regards,
Marc

Re: Using DBChart with text data

Posted: Mon Feb 17, 2020 9:32 pm
by 16586540
Thanks Marc

That did the trick. I had set the Orders, but after I had loaded the data.

Best regards

Errol