chartjs / chartjs/Chart.js

Stacking area line charts with different x-values in data

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

Description

### Expected behavior

As shown in this sreenshot, we woud like the area chart can be stacked correctly even the x-value are random/mis-match.
![2022-07-11_04-03-42](https://user-images.githubusercontent.com/26291153/178261507-d677810e-f98a-4514-ab21-117423cb8277.png)

For example, in Series A, there is a data [x: "2022-06-27T21:00:00Z", y : 25], but no data point at this timestamp in Series B. we want the area chart can still be stacked with auto-fill [x: "2022-06-27T21:00:00Z", y : 0] in Series B and stacked?

### Current behavior

We use the ``` "react-chartjs-2": "^4.0.1" ``` and ``` "chart.js": "^3.7.1",``` to build area charts in our service. Our chart will display logs information which is time-based data like, {x:"2022-06-27T21:00:00Z", y:25}.

Since the time could be a random value in each data point, so there are some issue when we want to display a few series with different X-values(different time), as shown in the image. We got overlapping and blank area when the X-value(timestamp) is missing in another series.
![2022-07-11_04-03-42](https://user-images.githubusercontent.com/26291153/178261416-5e66423e-59cd-4f1b-bdf6-c2d6a14cf230.png)

Update: checked this Issue: https://github.com/chartjs/Chart.js/issues/7695. I notice they did have some missing/ different X-value. but looks the x-value is not random. when I made the x-values mis-match. same issue: https://codepen.io/derrickwanglf/pen/RwMRMXM

TO Simply demonstrate our issue, I mock some data(real number as x-value) here.

https://codepen.io/derrickwanglf/pen/gOeMvEL

Do you know how can we stack the area chart even the x-values are random?

### Reproducible sample

https://codepen.io/derrickwanglf/pen/gOeMvEL

### Optional extra steps/info to reproduce

_No response_

### Possible solution

For example, in Series A, there is a data [x: "2022-06-27T21:00:00Z", y : 25], but no data point at this timestamp in Series B. we want the area chart can still be stacked with auto-fill [x: "2022-06-27T21:00:00Z", y : 0] in Series B and stacked?

### Context

_No response_

### chart.js version

3.7.1

### Browser name and version

_No response_

### 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.