highChart动态生成图表一片空白
2016-02-18 17:32
232 查看
动态生成highChart的时候,
先把需要放图表的DIV 放到body里
var cellHistoryLine = $('#cellHistoryLine').appendTo(cellcoverRoot);//把图表DIV放到根DIV
然后再将图表生成到DIV中再appendTo 到根DIV中,
顺序 创建放图表的DIV到body中 》》动态生成图表放到 图表DIV中》》》再把已带图表DIV放到所需的DIV中 使用 appendTo()
先把需要放图表的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()
相关文章推荐
- 短信通信备忘录
- Select Input下拉框
- Android Studio Could not find method runProguard() for arguments?
- 单利的创建 iOS
- 移动表所在的表空间
- 解析后,封装到kvc的model对象中
- 2016学习进度记录
- 《iOS Human Interface Guidelines》——Undo and Redo
- php imagick
- awk中split函数的用法
- windows下utf-8和unicode的相互转换
- 哈理工oj 1372 Next Permutation【STL真好用系列】
- INSTALL_FAILED_OLDER_SDK
- AudioQueue 音频队列实现录音和播音
- hadoop详解
- android4.4的文件管理器documentsui源码解析
- iOS网络学习
- Hadoop生态上几个技术的关系与区别:hive、pig、hbase 关系与区别
- poj 3461 oulipo
- Android 轻松实现后台搭建+APP版本更新