无法在Highcharts标题中显示x轴值

时间:2015-06-29 18:06:24

标签: javascript highcharts

以下是我需要它如何工作highchart example

的示例

如果你在现场悬停,你会看到像

这样的东西
Apr
Dog: 2323

因此它在工具提示中显示xAxis值。 我已经制作了自己的,但它显示的是图表名称而不是xAxis值。

my highchart

xAxis: {
    title: {
        text: 'Date'
    },
    categories: data.categories
},

我做错了什么?

2 个答案:

答案 0 :(得分:0)

替换工具提示格式化程序中的内容 - 它应该可以正常工作

              tooltip: {

                formatter: function () {
                    return  '<b>'+this.series.name+'<br>'+this.x + ':' + this.point.y;
            }

答案 1 :(得分:0)

这很奇怪,但在pointFormat中,{point.x}指的是索引类别,而不是类别名称。在这种情况下,请使用headerFormat添加该信息:http://jsfiddle.net/3frcqbkv/1/

        tooltip: {
            headerFormat: '<b>{series.name}</b><br>{point.x}',
            pointFormat: ': $ {point.y:.2f}'
        },

如果您有更多系列,并且无法使用上述解决方案,请改用tooltip.formatter

修改

您可以通过以下方式获取类别名称:{point.category}。演示:http://jsfiddle.net/3frcqbkv/3/

            pointFormat: '{point.category}: $ {point.y:.2f}'