Recent

Author Topic: Real time chart  (Read 883 times)

j.g.holstein@rug.nl

  • New Member
  • *
  • Posts: 24
Real time chart
« on: January 22, 2021, 05:45:33 pm »
Hi group,

I search on the forum for a realtime chart with on X axis the time in hh:mm but without luck,  this is for my temperature recorder.

I like to use one channel.

Can someone help with an example?

Best regards,
Johan

MarkMLl

  • Hero Member
  • *****
  • Posts: 2325
Re: Real time chart
« Reply #1 on: January 22, 2021, 06:10:37 pm »
Have you investigated https://wiki.freepascal.org/TAChart ?

I've used it a little, and my recollection is that it's OK if your sample times are evenly-spaced but rather less so if they're erratic (e.g. you log the precise instants something changes but nothing between).

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

wp

  • Hero Member
  • *****
  • Posts: 8249
Re: Real time chart
« Reply #2 on: January 22, 2021, 06:36:27 pm »
Please search the forum for "TAChart" and myself as a poster. There are lots of posts about creating time-series charts.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

j.g.holstein@rug.nl

  • New Member
  • *
  • Posts: 24
Re: Real time chart
« Reply #3 on: January 22, 2021, 08:53:21 pm »
Hi WP,
 Sure but not a good example can you point me in a good direction?
Thanks,
Johan

wp

  • Hero Member
  • *****
  • Posts: 8249
Re: Real time chart
« Reply #4 on: January 22, 2021, 10:15:02 pm »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

j.g.holstein@rug.nl

  • New Member
  • *
  • Posts: 24
Re: Real time chart
« Reply #5 on: January 26, 2021, 08:56:20 pm »
Hi WP, group,

This is a bad example and not what I need .... I need a X time axis in hh:mm but the example is far from that.

Is there someone who can help me with that or point to a example....

Thanks in advance,

Best regards,
Johan

wp

  • Hero Member
  • *****
  • Posts: 8249
Re: Real time chart
« Reply #6 on: January 26, 2021, 10:24:30 pm »
It is a good example. If you had not given up immediately after running the sample and had studied the code you would have seen that time and value are passed to the series in the order x=value and y = time (there's even a comment in the code pointing to this). So you only have to exchange the order of value and time in the AddXY method of the series:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.AddDataPoint(t: TDateTime; value: Double);
  2. begin
  3. //   Chart1LineSeries1.AddXY(Value, t);   // value on x, time on y axis!
  4.    Chart1LineSeries1.AddXY(t, Value);
  5. end;

The remaining change is less straightforward. There is a TDataTimeIntervalChartSource which is responsible for formatting floating point numbers as date/time. The example had the time axis pointing upward, therefore the DateTimeIntervalChartSource is hooked to the Marks.Source property of the left axis. In order to format the x axis as date/time remove the DateTimeIntervalChartSource from the left axis and attach it to the bottom axis. And set Chart.BottomAxis.Marks.Style to smsLabel (to display the time labels) and reset Chart.LeftAxis.Marks.Style to smsValue (to restore the original values on the y axis).

Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

MarkMLl

  • Hero Member
  • *****
  • Posts: 2325
Re: Real time chart
« Reply #7 on: January 29, 2021, 03:45:58 pm »
This is a bad example and not what I need .... I need a X time axis in hh:mm but the example is far from that.

Is there someone who can help me with that or point to a example....

I've just been looking at https://forum.lazarus.freepascal.org/index.php?action=dlattach;topic=49251.0;attach=36220 (data_arriving.zip) which I believe was the example cited and found it perfectly adequate.

However (@j.g.holstein@rug.nl, this is for you): I think the important point is that this sort of thing is not going to be very much use if you simply type the files, since you don't get to see the hints that the IDE is trying to give you about the design-time configuration of the various components. You /did/ take the trouble to open the files using the IDE didn't you? What did you find difficult to follow?

Responding "this is a bad example ... is there someone who can help" when somebody /is/ trying to help you isn't going to make you any friends.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1350
  • Former Delphi 1-7, 10.2 User
Re: Real time chart
« Reply #8 on: January 29, 2021, 11:24:22 pm »
This is a bad example and not what I need

Of course it's not precisely what you need - it is, after all, an example which demonstrates the principle. You will need to adapt it to your own specific requirements. If you are unwilling to do that, then you'll need to find someone else to do it for you and compensate them appropriately.
Lazarus 2.1 r64861 FPC 3.3.1 r49035 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r64891 3.3.1 r49100 macOS 11.2.3 aarch64 Xcode 12.4
Lazarus 2.1 r61574 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 3.2.0 Win10 Parallels VM

 

TinyPortal © 2005-2018