我有两条Y轴,一条用于左yaxis,另一条用于右yaxis。我们如何确定哪个轴的哪条线。
提琴: https://jsfiddle.net/35cqpu67/
var canvas = document.getElementById('chart');
new Chart(canvas, {
type: 'line',
data: {
labels: ['01-Mar-2019', '08-Mar-2019', '15-Mar-2019','22-Mar-2019'],
datasets: [{
label: 'A',
yAxisID: 'B',
data: [3.10,2.49,2.68,1.11],
fill: true,
borderColor: "#bae755",
}, {
label: 'B',
yAxisID: 'B',
data: [0.40,0.83,0.80,0.70],
fill: true,
borderColor: "red",
},
{
label: 'C',
yAxisID: 'A',
data: [96.10,96.25,96.05,97],
fill: true,
borderColor: "green",
},{
label: 'D',
yAxisID: 'B',
data: [0.40,0.42,0.47,0.40],
fill: true,
borderColor: "black",
pointHoverBorderWidth: 0,
lineWidth: 20,
pointRadius: 0,
pointHitRadius: 0
}]
},
options: {
scales: {
yAxes: [{
id: 'A',
type: 'linear',
position: 'left',
scaleLabel:{
display: true,
labelString: 'In Precentage',
fontColor: "#546372"
}
}, {
id: 'B',
type: 'linear',
position: 'right',
ticks: {
max: 10,
min: 0
},
scaleLabel:{
display: true,
labelString: 'In Precentage',
fontColor: "#546372"
}//,
//gridLines: { color: "#131c2b" }
}]
}
}
});
<body onload="displayLineChart();">
<div style="width:75%;">
<canvas id="chart"></canvas>
</div></body>
在这里,我的标签C(绿色)是左,其他是右。我们可以将框标签相应地左右移动吗?