You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the ChartJS library via react-chartjs-2.
For my charts, I am using the Time Cartesian Axis alongside the date-fns adapter.
I am having an issue when rendering only a single data point on my line chart / bar chart / scatter chart. It currently renders like this.
It seems that since there is only one data point (and no other points to reference), it displaying the timestamps in the x scale like:
12:46:26.999 p.m.
12:46:27.000 p.m.
12:46:27.001 p.m.
And also nothing is drawn on my line chart when there is only a single point, since I am using a point radius of 0 and they are only shown on hover.
How can I handle these single data point cases so that
Only the actual timestamp of the data point is rendered (not the extra ones on either side)
I can format that timestamp nicely
Something is displayed on the line chart when there is just a single point
I was thinking I would have to override chart options like line chart point radius, source field in ticks option, etc. to configure the options for the special case of a single data point maybe?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am using the ChartJS library via react-chartjs-2.
For my charts, I am using the Time Cartesian Axis alongside the date-fns adapter.
I am having an issue when rendering only a single data point on my line chart / bar chart / scatter chart. It currently renders like this.
It seems that since there is only one data point (and no other points to reference), it displaying the timestamps in the x scale like:
And also nothing is drawn on my line chart when there is only a single point, since I am using a point radius of 0 and they are only shown on hover.
How can I handle these single data point cases so that
I was thinking I would have to override chart options like line chart point radius,
source
field inticks
option, etc. to configure the options for the special case of a single data point maybe?Or are there better, cleaner ways to handle this?
Beta Was this translation helpful? Give feedback.
All reactions