highChart动态生成图表一片空白

动态生成highChart的时候,

先把需要放图表的DIV 放到body里

var cellHistoryLine = $('<div id="cellHistoryLine" style="min-width:240px;height:280px;display:none;"></div>').appendTo('body');
再把图表放到  cellHistoryLine  DIV中

var cellHistoryLine = $('<div id="cellHistoryLine" style="min-width:240px;height:280px;display:none;"></div>').appendTo('body');
	var cellcoverRoot = $('<div id="cellcoverRoot"></div>');            <pre name="code" class="javascript">                                         .
                                         .
                                         .
aa(cellName,historyRate);//生成图表
    var cellHistoryLine = $('#cellHistoryLine').appendTo(cellcoverRoot);//把图表DIV放到根DIV

 

function aa(cellName,historyRate){
	var rateArray = new Array();
	var dataArray = new Array();
	cellName=cellName.replace(/图层/,"");
	if(typeof(historyRate) != "undefined"&&historyRate!=null){
		
		dataArray[0]="当前周"
	var rateStringArray =historyRate.split(",");
//		alert(rateStringArray.length);
	for(var i=0;i<rateStringArray.length;i++){
		rateArray[i]=parseFloat(rateStringArray[i]);
		dataArray[i]='前'+parseInt((rateStringArray.length)-i-1)+'周';
	}
	dataArray[rateStringArray.length-1]="当前周";
	}
    $('#cellHistoryLine').highcharts({
        title: {
           text: cellName,
           x: -20 //center
       },
       credits: {
           enabled: false
       },
  yAxis: {
           title: {
               text: '实装率(%)'
           },
           plotLines: [{
                  color:'red',    
                dashStyle:'solid',
               value: 1,
               width: 1,
               color: '#808080'
           }]
       },
       xAxis: {
//    	   title: {
//           text: '历史月份'
//       },
       categories: dataArray, 
       },

       series: [{
           name: cellName,
           data: rateArray
       }],
   });
}

然后再将图表生成到DIV中再appendTo 到根DIV中,

顺序       创建放图表的DIV到body中   》》动态生成图表放到 图表DIV中》》》再把已带图表DIV放到所需的DIV中 使用 appendTo()




                
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值