Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more lines to the same chart panel in realtime? #1691

Closed
kdesroch1 opened this issue Jun 20, 2024 · 10 comments
Closed

Adding more lines to the same chart panel in realtime? #1691

kdesroch1 opened this issue Jun 20, 2024 · 10 comments

Comments

@kdesroch1
Copy link

kdesroch1 commented Jun 20, 2024

All of the line chart examples seems to have a predetermined number of lines hard coded in. Is it possible to add lines on the fly? For example, if you were reading some data from a device on the serial port (say periodic samples of 256 points of data) and wanted to add a new line on the same chart panel every time a new sample came in?

The minX, maxX, minY, maxY would be constant. New lines of different color would be added and possibly line labels.

@imaNNeo
Copy link
Owner

imaNNeo commented Jun 20, 2024

It should be very simple, you just need to keep a list of showingLines and update the list when a new data comes.
You can find the source code here

CleanShot.2024-06-21.at.00.14.22.mp4

@imaNNeo imaNNeo closed this as completed Jun 20, 2024
@kdesroch1
Copy link
Author

kdesroch1 commented Jun 20, 2024

Amazing! Thank you!

One other question: is there a way to specify a the axis step? I found the grid size control, but cannot figure out how to adjust the numbers on the axis to match.

@kdesroch1
Copy link
Author

Also, it there a way to keep the grid lines showing when there is no data?

@imaNNeo
Copy link
Owner

imaNNeo commented Jun 21, 2024

s step? I found the grid size control, but cannot figure out how to adjust the numbers on the axis to match.

You can use interval property in the SideTitles or FlGridData

@imaNNeo
Copy link
Owner

imaNNeo commented Jun 21, 2024

Also, it there a way to keep the grid lines showing when there is no data?

It is a bug and should be fixed in the next version. Stay tuned! 😊

@kdesroch1
Copy link
Author

kdesroch1 commented Jun 21, 2024

s step? I found the grid size control, but cannot figure out how to adjust the numbers on the axis to match.

You can use interval property in the SideTitles or FlGridData

The FLGridData intervals only seems to control the grid and not the text on the axis.

I got the FLTitlesData to adjust the text on the axis, but it seems quite complicated for such a simple thing. I had to add a widget or I was getting errors. It's such a basic thing, seems like there should be something that works like the minX/maxX/etc... of at the very most like the FLGridData intervals. Am I missing something?

@imaNNeo
Copy link
Owner

imaNNeo commented Jun 21, 2024

It's very simple, you just need to change the interval property in the SideTitles class. (no need to update other things)
Take a look at the below sample:
(source code is here)

CleanShot.2024-06-21.at.17.48.54.mp4

@kdesroch1
Copy link
Author

kdesroch1 commented Jun 21, 2024

Your support for this package is incredible! Thank you!

I'm not clear though, why this works:

double verticalInterval = 1.0;
.
.
.
sideTitles: SideTitles(
reservedSize: 26,
showTitles: true,
interval: verticalInterval,
),

But, this does not:

sideTitles: SideTitles(
reservedSize: 26,
showTitles: true,
interval: 1.0, // as int (1) doesn't work either
),

@kdesroch1
Copy link
Author

kdesroch1 commented Jun 21, 2024

Ok, I figured it out, a 'const' goes in front of AxisTitles. This doesn't follow the same patten as the other parameters like minX, reservedSize, etc..., so it was a bit confusing.

bottomTitles: const AxisTitles(
sideTitles: SideTitles(
reservedSize: 26,
showTitles: true,
interval: 1.0,
),
),

FYI, in your example, the verticalInterval and horizontalInterval variables are assigned to the wrong axis.

This was referenced Aug 26, 2024
@imaNNeo
Copy link
Owner

imaNNeo commented Aug 26, 2024

Landed in 0.69.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants