我在格式化图表轴时遇到了问题,而我无法找到更新版本2.0的示例。Chart.js 2.0使用货币和千位分隔符格式化Y轴
我怎么能(例如)2000000到€2,000.000?
我的小提琴: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
}
});
};
非常感谢@L Bahr!我忽略了这个功能。您的代码添加了一个。负数之前。 (例如-500000变成-.500.000>所以我用替换替换了拆分,这里有一个新的小提琴https://jsfiddle.net/Hiuxing/4sLxyfya/8/ – Mae
完美!把它放到正确的路径让它工作正常为了我自己 – vanhornRF