Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Highcharts 如何使用highchart在工具提示中显示更多数组?_Highcharts - Fatal编程技术网

Highcharts 如何使用highchart在工具提示中显示更多数组?

Highcharts 如何使用highchart在工具提示中显示更多数组?,highcharts,Highcharts,我将在我的项目中绘制图表,并且我已经习惯了那个高图表。我正在为动态显示图表获得成功。我有3个数组。第一个数组存储日期。第二个数组存储跟随者计数和第三个数组存储字符串。所以我想在工具提示中显示第三个数组。现在在工具提示中显示“仅跟随者计数”现在我还想显示第三个数组数据。那么,你怎么能做到呢?关于这一点,请告诉我。下面我列出了我的代码和屏幕截图,任何人都知道,然后请帮助我 这是我的数组=> var Dates = []; "11-10-2017" "12-10-2017" "13-10-2017"

我将在我的项目中绘制图表,并且我已经习惯了那个高图表。我正在为动态显示图表获得成功。我有3个数组。第一个数组存储日期。第二个数组存储跟随者计数和第三个数组存储字符串。所以我想在工具提示中显示第三个数组。现在在工具提示中显示“仅跟随者计数”现在我还想显示第三个数组数据。那么,你怎么能做到呢?关于这一点,请告诉我。下面我列出了我的代码和屏幕截图,任何人都知道,然后请帮助我

这是我的数组=>

var Dates = [];
"11-10-2017"
"12-10-2017"
"13-10-2017"
"14-10-2017"
"15-10-2017"
"16-10-2017"
"17-10-2017" 

var FollowersCount = [];
  "0"
  "0"
  "0"
  "0"
  "50"
  "10"
  "0"

 var Activites = [];
  ""
  ""
  ""
  ""
  "Comment,LIke"
  "Like"
  "0"
我想在工具提示中显示第三个数组

这是我的代码=>

*Highcharts.chart('container', {
    xAxis: {
        categories: Dates
    },
    credits: {
        enabled: false
    },
    exporting: {
        chartOptions: { // specific options for the exported image
            plotOptions: {
                series: {
                    dataLabels: {
                        enabled: true
                    }
                }
            }
        },
        sourceWidth: 400,
        sourceHeight: 300,
        scale: 1,
        buttons: {
            customButton: {
                text: 'Next Dates',
                onclick: function () {
                    alert('You pressed the button!');
                }
            },
            anotherButton: {
                text: 'Previous Dates',
                onclick: function () {
                    alert('You pressed another button!');
                }
            }
        }
    },
    plotOptions: {
        line: {
            dataLabels: {
                enabled: true
            },
            enableMouseTracking: false
        }
    },
    title: {
        text: "Followers"
    },
    series: [{
        name: 'Followers',
        data: FollowersCount 
    }
    ]
});*
这是我的图表屏幕截图=>


一种方法是向每个点添加额外数据,在您的情况下,向每个数据点添加活动。然后用格式化程序在工具提示中显示它们。我举了一个例子:

首先,创建一个包含您的值和活动的新数组:

var processedData = [];
for (var i = 0; i < FollowersCount.length; i++) {
  processedData.push({
    y: FollowersCount[i],
    activity: Activites[i]
  })
}
然后创建工具提示以显示此活动,但仅当它存在时:

tooltip: {
  formatter: function() {
    let tmpTooltip = '<b>' + this.point.category + '</b><br/><span style="color:' + this.point.color + '">\u25CF</span> ' + this.series.name + ': <b>' + this.point.y + '</b>';
    if (this.point.activity != "") {
      return tmpTooltip + '<br/><b>Activity:</b>' + this.point.activity;
    } else {
      return tmpTooltip;
    }
  }
}
工具提示:{
格式化程序:函数(){
让tmpTooltip=''+this.point.category+'
\u25CF'+this.series.name+':''+this.point.y+''; 如果(this.point.activity!=“”){ 返回tmpTooltip+'
活动:'+this.point.Activity; }否则{ 返回tmpTooltip; } } }
最后,您得到了一个如下所示的图形:

工作示例


工具提示格式化程序上的API

太棒了,我想这样做,但现在日期隐藏在工具提示中,在活动开始前,小蓝颜色在圆点中,如何放置,你知道吗???@编辑我现在已更新代码以匹配此注释。如果你想移动蓝点,那么只需将
span
元素移动到格式化程序中你想要的任何位置。谢谢我会处理你的代码并告诉你非常感谢你的Amzing回答非常感谢你的帮助。
tooltip: {
  formatter: function() {
    let tmpTooltip = '<b>' + this.point.category + '</b><br/><span style="color:' + this.point.color + '">\u25CF</span> ' + this.series.name + ': <b>' + this.point.y + '</b>';
    if (this.point.activity != "") {
      return tmpTooltip + '<br/><b>Activity:</b>' + this.point.activity;
    } else {
      return tmpTooltip;
    }
  }
}