gpt4 book ai didi

javascript - Highcharts : Json Array For ToolTip

转载 作者:行者123 更新时间:2023-11-29 21:42:00 26 4
gpt4 key购买 nike

我有一个如下所示的 Json 数组:

[{"label":"08\/09\/2015 03:15:49 AM","y":0.6,"y1":0.3,"y2":"0.3(XYZ)","y3":"0.6(XYZ)"},
{"label":"03\/09\/2015 04:23:04 AM","y":0.2,"y1":0.4,"y2":0.4,"y3":0.2},
{"label":"02\/09\/2015 12:50:56 AM","y":0.4,"y1":0.4,"y2(XYZ)":0.4,"y3":0.4}]

我在 HighChart 中的 javascript 代码如下:

    for (var i = 0; i < length; i++) {
dataXAxis.push(obj[i].label);
dataPointsLeft.push(obj[i].y);
dataPointsRight.push(obj[i].y1);
dataPointsLeft1.push(obj[i].y2);
dataPointsRight1.push(obj[i].y3);
}

$('#xyz').highcharts({
title: {
text: "Demo",
x: -20 //center
},
xAxis: {
categories: dataXAxis
},
tooltip: {
useHTML: true,
shared: true
},
series: [{
name: "X",
data: dataPointsRight,
color: '#FF0000'
}, {
name: "Y",
data: dataPointsLeft,
color: '#0000FF'
}]
});

现在我的问题是我想在工具提示中显示“dataPointsLeft1”数组。现在我的工具提示显示与 dataPointsLeft 数据相同,但我希望工具提示上的数据来自“dataPointsLeft1”数组。请尽快提出建议。

谢谢。

最佳答案

在推送时像这样使用:

    dataPointsLeft.push({y: obj[i].y, custom: obj[i].y1}); 
dataPointsRight.push({y: obj[i].y1, custom: obj[i].y3});

在工具提示中你可以使用

 tooltip: {              
formatter: function () {
var series = this.series;
return this.point.custom;
}
}

参见 https://jsfiddle.net/Nishith/gjezx1kq/ 处的 fiddle

关于javascript - Highcharts : Json Array For ToolTip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32470098/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com