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

XYChart not allowing missing data points #5293

Open
jgclark opened this issue Feb 16, 2024 · 7 comments · May be fixed by #5369
Open

XYChart not allowing missing data points #5293

jgclark opened this issue Feb 16, 2024 · 7 comments · May be fixed by #5369
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@jgclark
Copy link

jgclark commented Feb 16, 2024

Description

In some lines of work, there can be missing data points.
At the moment, XYChart throws errors if there are missing data points.
I hope this can be included in future.

Steps to reproduce

e.g. line [15, 20, 10, , 15]

Screenshots

No response

Code Sample

No response

Setup

  • Mermaid version: 10.8.0
  • Browser and Version: n/a

Suggested Solutions

Ideally want to be able to use
line [15, 20, 10, , 15]
or
line [15, 20, 10, NaN, 15]
to specify a data point is missing, and the line breaks at that point.

Most established graphing packages allow missing data points.

Additional Context

No response

@jgclark jgclark added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Feb 16, 2024
@JingyuMarcelLee
Copy link
Contributor

I am trying to work on this issue, but I need more details when NaN is passed on the line chart. For the Bar chart type, I set the height and width of the bar with the NaN value to 0, so the chart does not render that specific bar. However, since line charts are continuous, I'm not sure at which point I should break the line and restart it. @jgclark It would be helpful if you could show me how other graphing packages deal with this issue.

image

@jgclark
Copy link
Author

jgclark commented Feb 17, 2024

Thank you for your work on this.
gnuplot handles this by disconnecting the line where required, so in your example you'd just get a dot on data point 1 and then nothing until data point 3 where the line would start and continue on. You can actually specify what character to use (or blank space) to indicate a missing point: e.g. set datafile missing '?' or set datafile missing 'NaN'. Fuller details: https://gnuplot.sourceforge.net/docs_4.2/node172.html.
For example:

@jgclark
Copy link
Author

jgclark commented Feb 17, 2024

Google Chart API by default leaves a similar break, according to its documentation https://developers.google.com/chart/interactive/docs/gallery/linechart?csw=1#Configuration_Options under InterpolateNulls.

@Hancho2009
Copy link

Yes thank you for your work on this.
In my usecase I want to draw a line for i.e. x=0 y=100 to x=100 y=0. I have other lines on that chart which have more datapoints between x 0 and 100. Be able to draw that line without supplying the values inbetween would be nice.

@JingyuMarcelLee
Copy link
Contributor

image

Sorry for taking a while to work on this; I made changes so that the passed-in NaN values break the line before and after the missing point. I wonder if we should include options so that users can customize how NaN values are represented. One possibility is to assign a different theming variable (maybe with a dashed line or lighter color as shown in https://observablehq.com/@d3/line-chart-missing-data/2?intent=fork)

image

This would probably be a separate issue after this one has been resolved.

@JingyuMarcelLee JingyuMarcelLee linked a pull request Mar 7, 2024 that will close this issue
4 tasks
@jgclark
Copy link
Author

jgclark commented Mar 8, 2024

Thanks for your work on this.
I think I would start a separate issue for the "customize how NaN values are represented. One possibility is to assign a different theming variable (maybe with a dashed line or lighter color" idea. Some will want this ability for certain datasets, but for others it would be misleading, so should default off.

@Azizjon8822
Copy link

спасибо большое

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants