Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

Author Topic: TChart: +32% Processor load while plotting more than 4000 datapoints  (Read 1289 times)

Curt Carpenter

• Sr. Member
• Posts: 329
Re: TChart: +32% Processor load while plotting more than 4000 datapoints
« Reply #15 on: March 23, 2023, 07:47:02 pm »
A great place to start is https://wiki.lazarus.freepascal.org/Developing_with_Graphics

In your program, you will declare something like

TraceVu:  TBitMap

and then at the appropriate point in your code do something like

TraceVu.Canvas.Pixels[x,y] := cl.Red;

which will draw one red pixel at point [x,y] on the canvas.

Work a few of the examples in the wiki and you'll be up the learning curve in no time.   TChart is amazing, but you can't beat handling your own pixels for the ultimate in presentation flexibility.

KatiYusha

• New member
• Posts: 6
Re: TChart: +32% Processor load while plotting more than 4000 datapoints
« Reply #16 on: March 24, 2023, 04:36:00 pm »
A great place to start is https://wiki.lazarus.freepascal.org/Developing_with_Graphics

In your program, you will declare something like

TraceVu:  TBitMap

and then at the appropriate point in your code do something like

TraceVu.Canvas.Pixels[x,y] := cl.Red;

which will draw one red pixel at point [x,y] on the canvas.

Work a few of the examples in the wiki and you'll be up the learning curve in no time.   TChart is amazing, but you can't beat handling your own pixels for the ultimate in presentation flexibility.
Something else to consider: disable autoscale as much as possible, in your case the voltage should really be below 4.5V, so you can preconfigure the range of that axis. Also try to prescale the x-axis.  This may be more difficult if you don't know the total time for the plot, but one strategy is to manually increment the x-axis range by say 1 hour when your data reaches the current limit of the x-axis.

Here is an example which generates data for 3 line series.  When I set the loop to 10 hours, it generates over 100 000 data points which gets plotted in less than 2 seconds (which includes running a model to generate the OP series.  This was tested on my very modest dual core Celeron N3050 Linux laptop.
Thanks, I'll try them out.