使用重绘摆脱图表数据,提供的jsfiddle [英] Use redraw to get data from chart, Jsfiddle provided
问题描述
我要加上一个highchart重绘函数来显示一组新的数据的一个系列,四所取得的按钮,但code背后很努力。
I want to add a redraw function on highchart to show a new set of data for a series, iv made the button but the code behind am struggling.
HTML
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<button id="button">redraw </button>
JS:
function loadA(chart) {
chart.xAxis[0].update({
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
});
chart.yAxis[0].setTitle({
text: "kHw"
});
chart.addSeries({
name: 'Rainfall11',
type: 'column',
color: '#08F',
data: [100, 200, 300, 400, 100, 200, 0, 0, 0, 0, 0, 0]
});
chart.addSeries({
name: 'Rainfall2',
type: 'column',
color: '#808000',
data: [100, 200, 300, 400, 100, 200, 0, 0, 0, 0, 0, 0]
});
chart.addSeries({
name: 'Rainfall3',
type: 'column',
color: '#FFA500',
data: [100, 200, 300, 400, 100, 200, 0, 0, 0, 0, 0, 0]
});
}
$(function() {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
}
});
哪里重绘方法去,如何将我称之为重绘按钮被点击时,新的数据。
where does the redraw method go, and how would i call it to redraw new data when the button is clicked.
我现在有这个更新
function redraw() {
// Delete all the series.
while (chart.series.length > 0) {
chart.series[0].remove(false);
}
// Add the new series.
chart.addSeries({ data: Highcharts.map(Array(12), Math.random) }, false);
// Redraw the chart.
chart.redraw();
不过,我需要从图表相同的数据;而不是删除系列中,我需要从现有图表添加数据,这样我就可以从vb.net code
However I need to get the same data from the chart; instead of deleting the series, I need it to add data from the existing chart, so I can call it from vb.net code
更新FIDDLE:
推荐答案
使用重绘(),因为addSeries()已列入重绘功能。
use redraw(), because addSeries() has included redraw function.
http://api.highcharts.com/highcharts#Chart.addSeries( )
这篇关于使用重绘摆脱图表数据,提供的jsfiddle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!