Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Single timeseries bar chart creates multiple ticks

Open liondog opened this issue 2 years ago • 0 comments

Expected behavior

Creating a timeseries based bar chart with only a single bar and setting the ticks source to data will result in two additional but undesired ticks (marked in red color) left and right to the single tick coming from the data itself:

2023-10-16_12h20_02

The issue can be found in _generate() in this commit. Here, min and max result in the additional ticks as they both have very small offset to the data itself (exactly 1 ms).

Current behavior

See a sample here: https://stackblitz.com/edit/js-vssd2m. You'll immediately notice the effect:

  1. The first chart shows a single bar with tree ticks.
  2. The second chart shows two bars (or more) that no longer show the effect of undesired ticks.

Reproducible sample

https://stackblitz.com/edit/js-vssd2m

Optional extra steps/info to reproduce

No response

Possible solution

See the _generate() function. min and max show a slight offset hence the timestamps array is extended with the additional ticks.

Context

No response

chart.js version

v4.4.0

Browser name and version

Firefox v118

Link to your project

No response

liondog avatar Oct 16 '23 11:10 liondog