使用 Highcharts,如何使用它的 id 选择一个点?例如,如果我使用以下代码创建图表:
chart1 = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'scatter'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
title: {
text: 'Fruit eaten'
}
},
series: [{
name: 'Jane',
data: [{
name: 'Point1',
x: 1,
y: 2
}, {
name: 'Point2',
x: 2,
y: 5
}]
}, {
name: 'John',
data: [5, 7, 3]
}]
});
});
工具提示告诉我,当我将鼠标悬停在某个点上时,该点的 id 是什么。但是,我无法弄清楚识别该点的语法。我知道chart1.series[0].name
回报Jane. Also,
Chart1.series[0].data[0].namereturns
point1` 有没有一种简单的方法可以让我只知道“point1”就选择点并更改颜色?
我想知道除了每次循环遍历所有点之外是否还有更有效的方法。