【发布时间】:2019-08-24 00:22:26
【问题描述】:
我的图表数据正在工作,但我希望 Y 轴从我的最低值以下开始,并在最大值上方稍微延伸一点,我正在查看 yAxes-> ticks-> min/max 来执行此操作。但是当我将此添加到选项中时,会添加第二个 Y 轴标签,其刻度为 -1.0 到 1.0;我不知道如何摆脱它。我附上了一些屏幕截图和一些模拟的 js 代码。谢谢
var chartData = {
labels: ['January', 'February', 'March'],
datasets: [{
type: 'line',
label: 'Dataset 1',
borderColor: 'blue',
borderWidth: 2,
fill: false,
data: [
85, 80, 75
]
}, {
type: 'bar',
label: 'Dataset 2',
backgroundColor: 'red',
data: [
90, 85, 80
],
borderColor: 'white',
borderWidth: 2
}, {
type: 'bar',
label: 'Dataset 3',
backgroundColor: 'green',
data: [
95, 90, 85
]
}]
};
var ctx = document.getElementById('canvas').getContext('2d');
window.myMixedChart = new Chart(ctx, {
type: 'bar',
data: chartData,
options: {
title: {
display: true,
text: 'A Funky Label'
},
tooltips: {
mode: 'index',
intersect: false
},
responsive: true,
scales: {
xAxes: [{
stacked: false
}],
yAxes: [
{
ticks: {
max: 100,
min: 50,
stepSize: 10,
callback: function (value, index, values) {
return value + " HP";
}
}
},
{
stacked: false
}
]
},
layout: {
padding: {
left: 10,
right: 10,
top: 0,
bottom: 0
}
}
}
});
}
【问题讨论】:
-
我在创建帖子时无法上传这张图片,但它是没有勾号的图片link - 谢谢
标签: chart.js