比如定义了图表之后,我想知道y轴的步长。// Your average chartvar ctx = document.getElementById('myChart').getContext('2d');var chart = new Chart(ctx, { type: 'line', data: { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [{ label: 'My First dataset', backgroundColor: 'rgb(255, 99, 132)', borderColor: 'rgb(255, 99, 132)', data: [0, 10, 5, 2, 20, 30, 45] }] }, options: {}});我可以执行以下操作吗?console.log(downChart.options.scales.yAxes.ticks.stepSize);
1 回答
![?](http://img1.sycdn.imooc.com/545850200001359c02200220-100-100.jpg)
杨__羊羊
TA贡献1943条经验 获得超7个赞
不知道能不能直接得到stepSize的个数,但是用
chartVariable.scales['y-axis-0'].ticksAsNumbers
你会得到一个包含所有刻度的数组。有了这个,您可以轻松获得 stepSize。
编辑: chartVariable
是chart
在您的具体情况。
添加回答
举报
0/150
提交
取消