动态地将数据添加到Highcharts系列中 [英] Dynamically add data to series in Highcharts
本文介绍了动态地将数据添加到Highcharts系列中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的系列看起来像:
系列:[{
name:'Serie1',
data:[
{
x:0,
low:Date .UTC(2013,07,03,0,00,00),
高:Date.UTC(2013,07,03,4,0,0),
客户:[{nombre:' Pepe',
Partida:'11111',
Bandejas:'35'},
{nombre:'Pepe1',
Partida:'222',
Bandejas :'50'}]
},
{
x:0,
low:Date.UTC(2013,07,03,5,0,0),
高:Date.UTC(2013,07,03,9,0,0)
},
{
x:0,
低:Date.UTC(2013,07 ,03,18,0,0),
high:Date.UTC(2 013,07,03,24,0,0)
}
]
},
{
名称:'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),
高: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)
}
]
}
]
当我点击一个按钮时,我想在Serie 1中添加新数据。
我试过了chart.series [pos]。使用setData(newdata);它的工作原理,但删除所有以前的数据。
我也尝试过使用chart.series [pos-1] .data.push(newdata);但它不起作用。
任何解决方案? 您可以使用允许添加新数据的 addPoint 功能。
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?
解决方案
You can use addPoint function which allows to add new data.
这篇关于动态地将数据添加到Highcharts系列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文