2014-12-19 118 views
0

我碰到一个有趣的问题,我无法用型“日期时间”和的X轴加点与动态添加类动态添加数据系列Y轴的动态类型和动态添加一系列的HighChart:在Y轴

$(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]); 
       } 
      }); 
     }); 
    }): 

这里是一个的jsfiddle http://jsfiddle.net/5L59r1qt/10/

我希望能够点击该按钮,并与里面的文字将其添加为一个系列。它这样做,但它不会做正确的时间!

回答

0

您在addSeries中有不正确的数据数组。它应该是x/y值的对象。

idSeries.push({name: id+ 'n', data: [{x: currentDate.getTime(),y:categories.length-1}]}); 

http://jsfiddle.net/5L59r1qt/12/