charts.js将y标签固定为8个小数位

问题描述 投票:0回答:1

如何修改具有0.00000034之类的数字的Y,因为我有3.4e-7

这是我的代码片段:

var speedData = {
    labels: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
    datasets: [{
        label: "BTC-DOGE",
        data: [0.00000008, 0.00000042],
        lineTension: 0,
        fill: false,
        borderColor: 'orange',
        backgroundColor: 'transparent',
        borderDash: [5, 5],
        pointBorderColor: 'orange',
        pointBackgroundColor: 'rgba(255,150,0,0.5)',
        pointRadius: 5,
        pointHoverRadius: 10,
        pointHitRadius: 30,
        pointBorderWidth: 2,
        pointStyle: 'rectRounded'
    }]
};
javascript chart.js
1个回答
0
投票
尝试一下,它应该可以工作。

var speedData = { labels: [0,1,2,3,4,5,6,7,8,9], datasets: [{ label: "BTC-DOGE", data: [0.00000008,0.00000042], lineTension: 0, fill: false, borderColor: 'orange', backgroundColor: 'transparent', borderDash: [5,5], pointBorderColor: 'orange', pointBackgroundColor: 'rgba(255,150,0,0.5)', pointRadius: 5, pointHoverRadius: 10, pointHitRadius: 30, pointBorderWidth: 2, pointStyle: 'rectRounded' }] }; new Chart(document.getElementById("line-chart"), { type: 'line', data: speedData });

© www.soinside.com 2019 - 2024. All rights reserved.