我遇到了一个有趣的问题,我无法添加具有"日期时间"类型的 xAxis 的点和具有动态类别和动态添加系列的 yAxis 的点
$(document).ready(function() {
drawScatter();
$('#addSeries').on('click', function() {
//first check if value is already a series
var currentDate = new Date();
var id = document.getElementById('txtValue').value;
getSeriesIndexByEventID(eventid, function(index) {
//if it doesnt exist, add it to chart
if (index == -1) {
categories.push(id + ' category');
console.log(categories);
chart.yAxis[0].setCategories(categories);
idSeries.push({name: id+ 'n', data: [categories.length-1, [{x: currentDate.getTime()}]]});
chart.addSeries(idSeries[idSeries.length-1]);
console.log(chart.series[categories.length-1]);
}
});
});
}):
这是一个jsfiddlehttp://jsfiddle.net/5L59r1qt/10/
我希望能够单击该按钮并使用内部文本将其添加为一个系列。它这样做了,但它不会做正确的时间!
addSeries 中的数据数组不正确。它应该是具有 x/y 值的对象。
idSeries.push({name: id+ 'n', data: [{x: currentDate.getTime(),y:categories.length-1}]});
http://jsfiddle.net/5L59r1qt/12/