如何更改chartjs

时间:2015-07-11 13:41:54

标签: chart.js

您能否指导我如何更改Chartjs中的Y-AXIS值。

请提供逐步更改的程序。

2 个答案:

答案 0 :(得分:1)

这是你在找什么?

var data = {
    labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
    datasets: [
        {
            label: "My First dataset",
            fillColor: "#FFC069",
            strokeColor: "rgba(220,220,220,1)",
            pointColor: "rgba(220,220,220,1)",
            pointStrokeColor: "#FF9C85",
            data: [45, 39, 40, 31, 26, 45, 10, 36, 25, 30, 2, 10]
        }
    ]
};

var ctx = document.getElementById("myChart").getContext("2d");
var myLineChart = new Chart(ctx).Line(data, {
    // adjusting your scale labels
    scaleLabel: "<%=value/10%>M",
    // adjusting your scale
    scaleOverride: true,
    scaleSteps: 5,
    scaleStepWidth: 10,
    scaleStartValue: 0,
    // ajusting tooltips
    tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value / 10 %>M",
});

小提琴 - http://jsfiddle.net/t0o07xbf/

答案 1 :(得分:0)

您可以将此属性添加到代码中:

scaleOverride : true,
scaleSteps : 5,
scaleStepWidth : 5,
scaleStartValue : 0,