Javascript 在highcharts散点图中添加自定义变量作为工具提示

Javascript 在highcharts散点图中添加自定义变量作为工具提示,javascript,highcharts,Javascript,Highcharts,我正在努力将自定义变量添加到highcharts散点图中的工具提示中 var options = { chart: { renderTo: 'container', type: 'scatter', plotBorderWidth: 1, zoomType: 'xy' }, legend: { enabled: false }, tooltip: { headerFormat: '<b>{s

我正在努力将自定义变量添加到highcharts散点图中的工具提示中

var options = {
  chart: {
    renderTo: 'container',
    type: 'scatter',
    plotBorderWidth: 1,
    zoomType: 'xy'
  },
  legend: {
    enabled: false
  },

  tooltip: {
                headerFormat: '<b>{series.name}</b><br>',
                pointFormat: 'First: {point.x}, Second: {point.y}'
            }, 


  xAxis: {
        gridLineWidth: 0,
        type: 'datetime',
        dateTimeLabelFormats: {
           day: '%m/%d'    //ex- 01 Jan 2016
        }
    },
yAxis: {
        gridLineWidth: 0,
        plotLines: [
                        {
                value:2019,
                color: 'grey',
                /* dashStyle: 'shortdash', */
                width: 0.5},
                {
                value:2018,
                color: 'grey',
                /* dashStyle: 'shortdash', */
                width: 0.5},

                ]
    },

  plotOptions: {
    scatter: {
      dataLabels: {
        enabled: false
      },
    },
   },

  series: [{}],
}

var data = {
  "other": [
    {
      "y": 2018,
      "x": "03/22/19",
      "contact_notes": "aa"
    },
    {
      "y": 2019,
      "x": "06/22/19",
      "contact_notes": "bb"
    },
    {
      "y": 2019,
      "x": "09/06/19",
      "contact_notes": "cc"
    }
  ],
}


var data2 = data['other']

data2.forEach(function(point) {
  point["x"] = new Date(point["x"]).getTime();
});

options.series[0].data = data2;
options.series[0].name = 'other'
options.series[0].color =  '#b20000' 

var chart = new Highcharts.Chart(options);
var选项={
图表:{
renderTo:'容器',
键入:“散布”,
打印边框宽度:1,
zoomType:'xy'
},
图例:{
已启用:false
},
工具提示:{
headerFormat:“{series.name}
”, pointFormat:'第一个:{point.x},第二个:{point.y}' }, xAxis:{ 网格线宽:0, 键入:“日期时间”, 日期时间标签格式:{ 日期:'%m/%d'//2016年1月1日 } }, 亚克斯:{ 网格线宽:0, 绘图线:[ { 价值:2019年, 颜色:“灰色”, /*短跑风格:“短跑”*/ 宽度:0.5}, { 价值:2018年, 颜色:“灰色”, /*短跑风格:“短跑”*/ 宽度:0.5}, ] }, 打印选项:{ 散布:{ 数据标签:{ 已启用:false }, }, }, 系列:[{}], } 风险值数据={ “其他”:[ { “y”:2018年, “x”:“19年3月22日”, “联系人注释”:“aa” }, { “y”:2019年, “x”:“19年6月22日”, “联系人注释”:“bb” }, { “y”:2019年, “x”:“09/06/19”, “联系人注释”:“抄送” } ], } var data2=数据[“其他”] 数据2.forEach(函数(点){ 点[“x”]=新日期(点[“x”])。getTime(); }); options.series[0]。数据=数据2; options.series[0]。名称='other' options.series[0]。颜色=“#b20000” var图表=新的Highcharts.图表(选项);
如果您查看我的数据对象,它有一个名为“contact_notes”的键,我希望在将鼠标移到图表上的三个数据点上时,除了x点和y点之外,还能看到该数据(即,请参见“aa”、“bb”、“cc”)


任何帮助都将不胜感激。谢谢

自定义属性最终会出现在该点的选项中,即这将起作用:

pointFormat: 'First: {point.x}, Second: {point.y}, Third: {point.options.contact_notes}'

自定义特性最终出现在该点的选项中,即,这将起作用:

pointFormat: 'First: {point.x}, Second: {point.y}, Third: {point.options.contact_notes}'

您可以使用
pointFormat
选项或
formatter
函数,通过
point获取自定义属性。联系\u notes

tooltip: {
    headerFormat: '<b>{series.name}</b><br>',
    pointFormat: 'First: {point.x}, Second: {point.y}, Third: {point.contact_notes}'
}
工具提示:{
headerFormat:“{series.name}
”, pointFormat:'第一个:{point.x},第二个:{point.y},第三个:{point.contact_notes}' }

现场演示:


API参考:

您可以使用
pointFormat
选项或
formatter
函数,通过
point获取自定义属性。联系\u notes

tooltip: {
    headerFormat: '<b>{series.name}</b><br>',
    pointFormat: 'First: {point.x}, Second: {point.y}, Third: {point.contact_notes}'
}
工具提示:{
headerFormat:“{series.name}
”, pointFormat:'第一个:{point.x},第二个:{point.y},第三个:{point.contact_notes}' }

现场演示:

API参考: