简体   繁体   English

在Highcharts中动态添加数据到系列

[英]Dynamically add data to series in Highcharts

I´m trying to update my highchart serie appending new data. 我正在尝试更新我的追踪新数据的高级系列。

My series look like: 我的系列看起来像:

series: [{
        name: 'Serie1',
        data:[
            {
                x: 0,
                low: Date.UTC(2013, 07, 03, 0, 00, 00),
                high: Date.UTC(2013, 07, 03, 4, 0, 0),
                cliente:[{nombre:'Pepe',
                    Partida:'11111',
                    Bandejas:'35'},
                    {nombre:'Pepe1',
                    Partida:'222',
                    Bandejas:'50'}]
            },
            {
                x: 0,
                low: Date.UTC(2013, 07, 03, 5, 0, 0),
                high: Date.UTC(2013, 07, 03, 9, 0, 0)
            },
                            {
                x: 0,
                low: Date.UTC(2013, 07, 03, 18, 0, 0),
                high: Date.UTC(2013, 07, 03, 24, 0, 0)
            }
      ]
    },
        {
        name: 'Serie2',
        data:[
            {
                x: 2,
                low: Date.UTC(2013, 07, 03, 4, 0, 0),
                high: Date.UTC(2013, 07, 03, 10, 0, 0)
            },
                            {
                x: 2,
                low: Date.UTC(2013, 07, 03, 18, 0, 0),
                high: Date.UTC(2013, 07, 03, 24, 0, 0)
            },
                            {
                x: 2,
                low: Date.UTC(2013, 07, 03, 0, 0, 0),
                high: Date.UTC(2013, 07, 03, 2, 0, 0)
            },
                            {
                x: 2,
                low: Date.UTC(2013, 07, 03, 11, 0, 0),
                high: Date.UTC(2013, 07, 03, 18, 0, 0)
            }
      ]
    }          
            ]

When I click a button I want to append new data inside "Serie 1". 当我单击一个按钮时,我想在“Serie 1”中添加新数据。

I´ve tried chart.series[pos].setData(newdata); 我试过chart.series [pos] .setData(newdata); and it works, but delete all the previous data. 它可以工作,但删除所有以前的数据。 I´ve also tried using chart.series[pos-1].data.push(newdata); 我也尝试过使用chart.series [pos-1] .data.push(newdata); but it doesn´t work. 但它不起作用。

Any solution? 有解决方案吗

您可以使用addPoint函数来添加新数据。

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

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