javascript - 工具提示中 yaxis 值之间的 Highcharts 变化 (%)

标签 javascript highcharts

我有一个非常简单的样条图,我试图在每个工具提示上显示所选点和前一个点的值之间的变化,以百分比变化衡量。基本上 this 是我要显示的工具提示格式

我一直在寻找解决方案,但我唯一想到的是 this .

希望对您有所帮助。

这是我的图表选项:

GeneralChartOptions = {

    chart: {
        renderTo: 'dummycontainer',
        type: 'spline',
        zoomType: 'x',
        spacingRight: 20
    },
    credits: {
        enabled: false
    },
    title: {
        text: ''
    },
    xAxis: {
        type: 'datetime',
        dateTimeLabelFormats: {
            month: '%b \'%y',
            year: '%b'
        }
    },
    yAxis: {
        title: {
            text: ''
        },
        plotLines: []
    },
    tooltip: {
        xDateFormat: '%m-%Y',
        shared: true, 
        crosshairs: true,
    },
    exporting: {
        enabled: false
    },
    labels: {
       formatter: function() {
          return Highcharts.numberFormat(this.value, 2,".",",");

       }
    },
    series: []
}

谢谢你的帮助,我真的很感激。

最佳答案

看看他们是怎么做的,然后试试看如何?

tooltip: {
    pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
    valueDecimals: 2
},

plotOptions: {
    series: {
        compare: 'percent'
    }
}

demo

关于javascript - 工具提示中 yaxis 值之间的 Highcharts 变化 (%),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13828583/

相关文章:

javascript - 如何使用 setState 将对象添加到数组列表

javascript - 在 Highcharts 中自动刷新 Json 数据

javascript - 如何在 Highcharts 中使用循环分类

javascript - HighCharts 列系列数量未知

javascript - 有没有办法测试元素中内容的类型

javascript - 为什么以下 Facebook 分享按钮没有打开弹出窗口?

javascript - Jquery - 从最近的元素复制文本

javascript - 无法更改 Highcharts 上的日期格式

javascript - 使用php制作highchart的动态Y轴最大值和刻度间隔

javascript - PHP 变量作为 Javascript 变量名