我在格式化我的图表轴时遇到问题,我无法找到更新版本 2.0 的示例。
我怎样才能(例如)赚到 2000000 到 2000000 欧元?
我的小提琴: https ://jsfiddle.net/Hiuxing/4sLxyfya/4/
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx, {
type: 'bar',
data: barChartData,
options: {
title: {
display:true,
text:"Figure"
},
legend: {
position: "bottom"
},
tooltips: {
mode: 'label',
bodySpacing: 10,
cornerRadius: 0,
titleMarginBottom: 15
},
scales: {
xAxes: [{
ticks: {}
}],
yAxes: [{
ticks: {
beginAtZero: true,
stepSize: 500000
}
}]
},
responsive: true
}
});
};
原文由 Mae 发布,翻译遵循 CC BY-SA 4.0 许可协议
修复
创建配置对象时,将函数分配给 userCallback。这在创建刻度线时被调用。您可以 在 Scales 文档底部的 Chart.js 中找到文档
修复示例