繁体   English   中英

HighChart:动态添加数据系列,并在yAxis上动态添加类别

[英]HighChart: add data series dynamically with dynamically added categories on yAxis

我遇到了一个有趣的问题,我无法添加带有'datetime'类型的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]);
                }
            });
        });
    }):

这是一个jsfiddle http://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/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM