【问题标题】:What is the solution for Highcharts hoverHighcharts悬停的解决方案是什么
【发布时间】:2015-03-08 13:31:07
【问题描述】:

我使用highchart jquery 插件绘制面积图。通过 AJAX 调用需要传递 3 个数组来绘制图表。 x 轴的第一个数组数据。 Y 轴的第二个数组数据。第三个数组的字符串值需要与 y 轴值一起传递到 hover(max) 中。每个数组有 90 个值。是否可以将第三个数组显示为悬停? 有谁能帮帮我吗?

$('#divcontainer').highcharts({

        chart: {

            type: 'area'
        },
        credits: {
  enabled: false },plotOptions: {
         area: {
            events: {
                legendItemClick: function () {

                    return false; // <== returning false will cancel the default action
                }
            }
        ,
        showInLegend: true
    }
}, title: {
        text: 'Chart',
        x: -20 //center
    },
    subtitle: {
        text: '',
        x: -20
    },
    xAxis: {
          labels:{rotation: rot, x:-20},
           categories: data[0]

      },
    yAxis: {
        title: {
            text: 'Status'
        },
        plotLines: [{
            value:0,
            width: 1,
            color: '#808080'
        }]
    },
    tooltip:{
         enabled: true,
         formatter: function() {
                    return '<b>' + this.x + '</b><br/><b>' + 'Status: ' + this.y + '</b>';}},

series: [{
        name: 'Status',
        data: data[1]
        }]
}); 

data[0] is 1st array, data[1] is 2nd array, and data[2] is 3rd array。这些是来自 ajax 调用的数组。

【问题讨论】:

  • 您能否编辑您的问题以添加一些用于构建此图表的代码?没有任何源代码的问题可能很难正确回答。
  • 当您说“悬停”时,您的意思是“工具提示”吗?
  • @aus_lacy 是的,它是工具提示
  • @kenster 我已添加代码。请检查

标签: jquery highcharts


【解决方案1】:

也许您可以尝试以下方法:

tooltip:{
         enabled: true,
         formatter: function() {
                    return '<b>' + this.x + '</b><br/><b>' + 'Status: ' + this.y + '</b>' + data[2][this.series.data.indexOf( this.point )];
         }
},

注意data[2][this.series.data.indexOf( this.point )]的部分。

【讨论】:

  • 我将在 jquery 系列中在哪里添加数据 [2]?我没有在系列 highchart 中添加数据 [2]。请告诉我
  • 现在我明白你写了什么
  • 你好@aus_lacy先生,我还有一个疑问。x轴的第一个数组数据有30个值。 Y 轴的第二个数组数据有 90 个值。但我想将图表单个 x 轴值绘制为 3 个 Y 轴值。这可能吗?如果可能请告诉我
  • 以上评论是不可能的。我有 90 个 x 轴值。我有 90 个 y 轴值。我想在 x 轴上显示 30 个值,在 y 轴上显示 90 个浮点数
猜你喜欢
  • 1970-01-01
  • 2018-04-02
  • 1970-01-01
  • 2013-07-03
  • 2019-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-02
相关资源
最近更新 更多