最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dynamically add data to series in Highcharts - Stack Overflow

programmeradmin6浏览0评论

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".

I´ve tried 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); but it doesn´t work.

Any solution?

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".

I´ve tried 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); but it doesn´t work.

Any solution?

Share Improve this question asked Jun 4, 2014 at 23:45 jgm196jgm196 651 gold badge2 silver badges8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

You can use addPoint function which allows to add new data.

发布评论

评论列表(0)

  1. 暂无评论