Javascript 获取序列'的索引;单击点时s点:highcharts
我想得到这个点的索引。当我点击点时,它会给我该点的索引。这里我只有样本数据,但最初我有大量数据。现在,当我点击点时,它会给我x值,但我想要索引。请看这里的小提琴 html代码Javascript 获取序列'的索引;单击点时s点:highcharts,javascript,highcharts,Javascript,Highcharts,我想得到这个点的索引。当我点击点时,它会给我该点的索引。这里我只有样本数据,但最初我有大量数据。现在,当我点击点时,它会给我x值,但我想要索引。请看这里的小提琴 html代码 <div ng-app="myapp"> <div ng-controller="myctrl"> <div class="row"> <highchart id="chart1" config="mtv" class="span10
<div ng-app="myapp">
<div ng-controller="myctrl">
<div class="row">
<highchart id="chart1" config="mtv" class="span10"></highchart>
</div>
</div>
</div>
<h3><a href="https://github.com/pablojim/highcharts-ng">See Highcharts-ng on github</a></h3>`
试试这个:
var index=this.series.xData.indexOf(event.point.x)代码>。这给了我一个错误,无法读取x ata undefineAh的属性,对不起,您已经单击了系列,没有达到我对点的预期,请参阅:var index=this.xData.indexOf(event.point.x)代码>完美,它成功了非常感谢:-)
//See: https://github.com/pablojim/highcharts-ng
var myapp = angular.module('myapp', ["highcharts-ng"]);
myapp.controller('myctrl', function ($scope, $timeout) {
$scope.mtv = {
useHighStocks: true,
options: {
xAxis: {
min: 1435324365737,
max: 1435324410674,
type: "datetime",
plotLines: [],
}
,plotOptions: {
series: {
cursor: 'pointer',
events: {
click: function(e) {
// Log to console
alert(this.name + ' clicked\n' +
'Index: ' + event.point.x);
}
}
}
},
title: {
text: 'fssfgdf'
},
rangeSelector: {
enabled: false
},
navigator: {
enabled: false,
},
scrollbar: {
enabled: true
},
},
series: [{
name: 'gddfdg',
data: [
[1435324350703, 1],
[1435324365737, 1],
[1435324395659, 1],
[1435324410674, 1]
],
marker: {
enabled: true,
radius: 3
},
}],
}
});