chartjs / chartjs/Chart.js

Assign yAxisID to datapoint

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

Description

### Feature Proposal

I have following dataset:
```
[
{data: [100, 50, 0.5], backgroundColor:'#506f86', borderColor: '#506f86', hoverBackgroundColor:'#384e5e', hoverBorderColor: '#384e5e', label: 'Service'},
{data: [80, 20, 0.25], backgroundColor:'#9ec5fe', borderColor: '#9ec5fe', hoverBackgroundColor:'#6ea8fe', hoverBorderColor: '#6ea8fe', label: 'Maintenance'},
{data: [60, 20, 0.33], backgroundColor:'#ffc107', borderColor: '#ffc107', hoverBackgroundColor:'#cc9a06', hoverBorderColor: '#cc9a06', label: 'Monitoring'}
]
```

Here, datapoints are as follows:

```
data[0] - Sales
data[1] - Gross Profit $
data[2] - Gross Profit %
```

I have following scales defined:
```
scales: {
dollar: {
type: 'linear',
position: 'left',
ticks: {
callback: (label, index, labels) => {
return `$ ${label}`;
}
}
},
percent: {
type: 'linear',
position: 'right',
grid: {
display: false,
},
ticks: {
color: '#de703c',
callback: function(value, index, values) {
return (value + '%');
}
}
},
xAxis: {
type: 'category',
axis: 'x',
labels: ['Sales', 'Gross Profit $', 'Gross Profit %'],
},
},
```

This is what the chart looks like:

![chartjs](https://github.com/chartjs/Chart.js/assets/146914054/a6e4862f-0151-464b-b182-48460b0b715f)

I would like the third datapoint "Gross Profit %" in the dataset to be mapped to yAxisID "percent"

### Possible Implementation

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