本文介绍了Chart.js编号为许多小数位的Y-AXIS标签格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到chart.js Y轴标签问题。我有以下数据。

I'm having problems with chart.js Y-axis labels. I have the following data.

var data = {
labels: ["1","2","3","4","5"],
datasets: [
    {
        label: "My First dataset",
        fillColor: "rgba(220,220,220,0.5)",
        strokeColor: "rgba(220,220,220,0.8)",
        highlightFill: "rgba(220,220,220,0.75)",
        highlightStroke: "rgba(220,220,220,1)",
        data: [0.15000000000000088,0.15000000000000133,0.15000000000000177,0.15000000000000221,0.15000000000000308]
    },
]
};

我得到了这个结果。

请注意,图表中的值将超出限制。有关详细信息,请参阅。

Note that there will be a rounding off of the values in the chart beyond a limit. See https://stackoverflow.com/a/30373552/360067 for more information.

如果您想避免最好的选择是将您的比例/值的静态部分视为字符串,即您的数据将是88,133,177等,并且您的比例/值前缀将是0.150000 .....

If you want to avoid that your best bet would be to treat the static part of your scale / value as a string i.e. your data would be 88, 133, 177, etc. and your scale / value prefix would be 0.150000.....

这篇关于Chart.js编号为许多小数位的Y-AXIS标签格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:53
查看更多