如何在 Y 轴右侧显示与 Y 轴 ChartJS 左侧相同的标签
How to show label at right side of Y axis same as left side of Y Axis ChartJS
我已经创建了一个在 Y 轴左侧显示金额的折线图,现在我必须在 Y 轴右侧显示左侧 Y 轴金额的百分比。
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre><code>yAxes: [
{
id: 'A',
fontFamily: "DINPRO, Arial, sans-serif",
ticks: {
callback: (value, index, values) => {
window.values = values;
let newValue = value;
if (value >= 1000) {
newValue = Math.floor(newValue / 1000);
newValue += " Tsd.";
}
return newValue;
}
},
position: "left",
gridLines: {}
},
{ id: "B",
type: "linear",
display: true,
fontFamily: "DINPRO, Arial, sans-serif",
position: "right",
ticks: {
callback: (value, index, values) => {
// Here I will write percentage calculation logic but the values coming here is not same as left side of Y axis.
}
},
]
我已经创建了一个在 Y 轴左侧显示金额的折线图,现在我必须在 Y 轴右侧显示左侧 Y 轴金额的百分比。
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre><code>yAxes: [
{
id: 'A',
fontFamily: "DINPRO, Arial, sans-serif",
ticks: {
callback: (value, index, values) => {
window.values = values;
let newValue = value;
if (value >= 1000) {
newValue = Math.floor(newValue / 1000);
newValue += " Tsd.";
}
return newValue;
}
},
position: "left",
gridLines: {}
},
{ id: "B",
type: "linear",
display: true,
fontFamily: "DINPRO, Arial, sans-serif",
position: "right",
ticks: {
callback: (value, index, values) => {
// Here I will write percentage calculation logic but the values coming here is not same as left side of Y axis.
}
},
]