我想查看美元符号以及 Y 轴刻度数据。我正在使用 ChartJS 版本 2.1.0 来渲染图表。我调查了这个LINK但我无法理解。我知道我需要更改我的ScaleLabel,但我无法这样做。请指导我。因此规模 2000 应显示为 $2000
以下是我到目前为止所拥有的。
define(['backbone'], function(Backbone) {
var firstSubViewModel = Backbone.View.extend({
template: _.template($('#myChart-template').html()),
render: function() {
$(this.el).html(this.template());
var ctx = $(this.el).find('#lineChart')[0];
var lineChart = new Chart(ctx, {
type: 'line',
data: {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
datasets: {
label: "This Year",
data: this.model.attributes.incThisYear
}
},
options: {
scales: {
yAxes: [{
scaleLabel: {
display: true
}
}]
}
}
});
},
initialize: function() {
this.render();
}
});
return firstSubViewModel;
});
图片:
编辑
我的选项现在看起来像这样:
options: {
scales: {
yAxes: [{
scaleLabel: function (incValue){ return '$ '+ incValue.value; }
}]
}
}
最佳答案
关于javascript - 如何更改 Y 轴以在图表中显示 $,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39256476/