高图表添加新系列不起作用
highcharts Adding New Series Not Working
我有几个图表,这些图表是根据数组数据添加id的,然后根据其id将它们呈现到特定的图表中。正在添加 ID,但未更新新的图表数据。我的代码有什么问题?
My_jsfiddle
$('.bars').each(function(){
bars = new Highcharts.Chart({
chart: {type:'bar',renderTo:this,backgroundColor:'#222',plotBorderWidth:0,plotBackgroundColor:{linearGradient:{ x1:0, y1:0, x2:0, y2:1 },stops: [[0.40, "#383838"],[1, "#000"],[0.50, "#383838"]]},plotBorderColor:'#a6a0a0',height:70},
title: {align:'left',margin:5,style: {color:'#FFFFFF',fontSize:'10px',"text-transform":"uppercase"}},legend: {enabled:false},credits: {enabled:false},tooltip:{enabled:false},
loading:{labelStyle:{fontWeight:'bold',color:'#FF0000',top:'10%'},style:{backgroundColor:'#222'},hideDuration:1000},
xAxis: {labels: {enabled:false},tickWidth:0,tickInterval:0,gridLineWidth:0},
yAxis: {labels: {enabled:false},title: {text:null},min:0,max:100,tickWidth:0,gridLineWidth:0},
series: [{data:[5]}]
});
});
function test(){
while(bars.series.length){
bars.series[0].remove();
}
var idS = [50,60,40,80],
horiz = document.getElementById('horizBarGauage'),
idSL = 4,
j;
for (j=idSL;j--;){
console.log('Logging', idS[j]);
horiz.children[j].id = idS[j];
console.log('Logging', horiz.children[j].id);
var idData = idS[j];
bars.renderTo = idData;
bars.addSeries({data:[idData]});
bars.redraw();
}
}
test();
每次创建图表时,bars
都会重置为该新图表。因此,在test()
中,当您引用bars
时,它使用的是最近创建的图表。
在test()
中,您需要找到要编辑的实际图表:
var chart = $("#" + idS[j]).highcharts();
chart.addSeries({data: [idData] });
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 监视函数从服务返回不起作用,但作用域函数起作用
- 幻灯片滚动javascript不起作用
- 简单的javascript在Shopify中不起作用
- Recaptcha在IE7和IE8中不起作用
- Ember Data DS.Model's set函数不起作用
- JsFiddle上的鼠标事件不起作用
- 我的AngularJS表达式没有'不起作用
- 点击按钮输入不起作用
- 面向对象的Javascript代码在IE7中不起作用
- 分部隐藏在jquery中不起作用
- 在phonegap应用程序内部重定向不起作用
- Array.length似乎不起作用;console.log则显示其他情况
- $ionicplatform内的$scope不;不起作用
- Highcharts colorsByPoint与系列中的线性渐变一起使用时不起作用
- Highcharts在将javascript变量作为Hightcharts系列数据传递时不起作用
- 高图表添加新系列不起作用
- 浮动饼图切换系列不起作用
- Rickshaw:多个系列的数据不起作用
- 使用javascript更改字体系列字体大小和字体粗细不起作用