javascript - 在 HighCharts 中设置超过 6 位小数?

标签 javascript highcharts

我是 HighStocks API 的新手,我正在尝试为小数设置 8 位小数(例如“0.00000001”)。

我已经测试了多种格式化方法,但我无法使用下面的这些值来格式化超过 6 个小数点的大小写。

我不知道这是 JS 的错误还是 HighCharts 的限制,我只是想让这个工作正常。

谢谢。

JSFiddle Link

$('#container').highcharts({
        chart: {
            type: 'line'
        },
        title: {
            text: 'Test'
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },
        yAxis: {
            title: {
                text: 'Decimals'
            }
        },
        plotOptions: {
            line: {
                dataLabels: {
                    enabled: true,
                    formatter: function () {
                        return Highcharts.numberFormat(this.y,8);
                    }
                },
                enableMouseTracking: false
            }
        },
        series: [{
            name: 'Test',
            data: [0.00000020,0.00000020,0.00000020,0.00000020]
        }]
    });

最佳答案

这似乎是 Highcharts.numberFormat 函数的限制 - 对于非常小的数字,无法更改带有 e 的表示法。

您可以使用toFixed()代替:

                    formatter: function () {
                        return this.y.toFixed(7);
                    }

现场演示:http://jsfiddle.net/BlackLabel/0cmLcrLp/

关于javascript - 在 HighCharts 中设置超过 6 位小数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49683246/

相关文章:

javascript - 如何使用 webworks 修复 Javascript (jquery) 中的 "Origin null is not allowed by Access-Control-Allow-Origin"错误?

javascript - ReactJS + Redux,出现错误 "Failed prop type: Right-hand side of ' instanceof' is not callable”

javascript - 控制台 HighCharts 错误破坏了可视化

javascript - 具有 x、y 值 golang 结构的 Highcharts 数据

javascript - 在 highcharts 中为同步图表添加或声明两个绘图选项

javascript - Highchart 标签旋转使我的专栏消失

javascript - 如何动态设置minPointLength除了0

javascript - WebRTC远程视频不流畅

javascript - Jquery 在单击动态添加的按钮时不调用函数

javascript - 如何计算 2 日期时间选择器?