chartjs / chartjs/Chart.js

Time X axis week rendering wrong on bar charts, correct on line charts with same data

Open
#10,258 3 comments 0 reactions 0 assignees View on GitHub
time scale type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Expected behavior

I'd expect the bar on a bar chart to be in the same place as the dot on a line chart for the same dataset and axis config. In my example below, the bar chart has bars showing in the wrong month., for example, the below screenshot shows a March figure plotted in April.

Screenshot 2022-03-24 at 15 12 45

### Current behavior

They're not in the same place.

### Reproducible sample

https://jsfiddle.net/fje5wrav/3/

### Optional extra steps/info to reproduce

This should explain the issue I think, but please let me know if not.

Also, interestingly, I noticed that re-using the `chart_options` object in both charts makes them both wrong! See this block and try the other option.
```js
var chart_options2 = Object.assign({}, chart_options);
// todo: Try commenting the line above and using the below instead, I give the wrong result too in that case!
//var chart_options2 = chart_options;
```

### Possible solution

_No response_

### Context

_No response_

### chart.js version

v3.7.1

### Browser name and version

Firefox (Dev edition v99) and Chrome

### Link to your project

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.