chartjs / chartjs/Chart.js

Floating Stacked Bar Chart problem + Duplicate legend problem

Open
#11,730 0 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

- Creating Stacked bar chart with floated bars should use values given in data to display bars correctly on the chart.
- Datasets with same label defined should have same color and use the same legend

### Current behavior

In given example bellow you can see that:
- on lines 27 and 28 of javascript i needed to subtract the values from previous dataset so the bar would be positioned correctly in chart. It then shows wrong text when creating tooltip.
- Despite dataset 3 and 4 have the same label name it created a new legend and new color for the 4th dataset bar.

### Reproducible sample

https://codepen.io/birko/pen/dyLJmmE

### Optional extra steps/info to reproduce

_No response_

### Possible solution

- when calculating bar positions for stacked bar chart disable values combination when using floated bars data values.
- if ```dataset.label``` is defined in the ```data.labels``` property. before creating new legend definitions for a dataset. It should lookup if the legend with the same name does not exists and use it instead

### Context

In our company we need to create a chart that show how long was an item (in example task) was by certain state (worker).
For the visualization we needed to show it in a form of horizontal bar chart.

### chart.js version

4.3

### Browser name and version

Edge 123.0.2420.65

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