如何使用highcharts截断工具提示中的值

时间:2014-04-24 12:49:23

标签: highcharts tooltip rounding

我有以下代码:

$(function () {
                    $('#container').highcharts({
                        chart: {
                            type: 'spline',
                            zoomType: 'xy',
                            borderRadius: 20,
                            borderWidth: 2,
                        },
                        credits: {
                            enabled: false
                        },
                        title: {
                            text: 'CO2 (Latest 7-days)'
                        },
                        exporting: {
                            enabled: false
                                },
                        xAxis: {
                            type: 'datetime',
                            labels: {
                                overflow: 'justify'
                            },
                            startOnTick: true,
                            showFirstLabel: true,
                            endOnTick: true,
                            showLastLabel: true,
                            categories: dateAndTimeArray,
                            tickInterval: 10,
                            labels: {
                                formatter: function() {
                                    return this.value.toString().substring(0, 6);
                                },
                                rotation: 0.1,
                                align: 'left',
                                step: 20,
                                enabled: true
                            },
                            style: {
                                fontSize: '8px'
                            }

                        },
                        yAxis: {
                            title: {
                                text: 'CO2'
                            },
                            labels: {
                                formatter: function() {
                                    return this.value +'°'
                                }
                            }
                        },

                        legend: {
                            enabled: false
                        },
                        tooltip: {
                        //    crosshairs: true,
                            shared: true,

                        },
                        plotOptions: {
                            spline: {
                                marker: {
                                    radius: 4,
                                    lineColor: '#666666',
                                    lineWidth: 1
                                }
                            }

                        },
                        series: [{
                            name: "CR3000Tower",
                            data: chartData,
                            marker: {
                                enabled: false
                            }

                        } ]
                    });
                });

它产生以下输出: enter image description here

我想在小数点后2处截断工具箱值。这样工具提示值将是414.26而不是长值。请帮忙。感谢。

1 个答案:

答案 0 :(得分:1)

设置valueDecimals,请参阅docs