動態(tài)更新highcharts數(shù)據(jù)的實現(xiàn)方法
更新時間:2016年05月28日 14:43:26 投稿:jingxian
下面小編就為大家?guī)硪黄獎討B(tài)更新highcharts數(shù)據(jù)的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
動態(tài)更新highcharts數(shù)據(jù)的實現(xiàn)方法
<!doctype html>
<html>
<head>
<script type="text/javascript" src="http://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
<script type="text/javascript">
var chart ;
$(function (){
chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
title: {
text: '?',
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: '數(shù)據(jù)'
},
},
series: []
});
});
function show(){
var trs = $('table tr');
var datas=[];
var map={};
for(var i=1;i<trs.length;i++){
var nams = $('td:first',trs[i]).html();
var value = $('td:last',trs[i]).html();
if(typeof map[nams]=='undefined'){
var pos = datas.length;
map[nams] = pos;
datas[pos]={name:nams,data:[]};
}
datas[map[nams]]["data"].push(Number(value));
}
var series=chart.series;
if(series.length > 0){
series[0].remove(false);
}
var d = datas[0];
chart.addSeries(d);//設(shè)置數(shù)據(jù),danielinbiti
chart.setTitle({text:d.name});//設(shè)置標題 commend by danielinbiti
chart.redraw();
}
</script>
<script type="text/javascript">
$(function () {
new Highcharts.Chart({
chart: {
renderTo: 'container2'
},
title: {
text: '鏈球菌毒素O',
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: '數(shù)據(jù)'
},
},
series: [{
name: 'SBASO',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}]
});
});
</script>
</head>
<body>
<input type='button' onclick='show()' value='顯示表格數(shù)據(jù)'/>
<h1>曲線圖</h1>
<!-- 第一個空圖 -->
<div id="container" style="width:300px;height:300px;float:left;"></div>
<!-- 第二個有數(shù)據(jù)的圖 -->
<div id="container2" style="width:300px;height:300px;float:left;"></div>
<table border="1" align="left">
<tr>
<td>CName</td>
<td>EName</td>
<td>Time</td>
<td>Date</td>
</tr>
<tr>
<td>血小板</td>
<td>HPLT</td>
<td>1</td>
<td>7.0</td>
</tr>
<tr>
<td>血小板</td>
<td>HPLT</td>
<td>2</td>
<td>6.9</td>
</tr>
<tr>
<td>血小板</td>
<td>HPLT</td>
<td>3</td>
<td>9.5</td>
</tr>
</table>
</body>
</html>
以上這篇動態(tài)更新highcharts數(shù)據(jù)的實現(xiàn)方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
基于dataset的使用和圖片延時加載的實現(xiàn)方法
下面小編就為大家分享一篇基于dataset的使用和圖片延時加載的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2017-12-12
JavaScript function 的 length 屬性使用介紹
函數(shù)的 length 得到的是形參個數(shù),如果函數(shù)內(nèi)部是通過arguments 調(diào)用參數(shù),而沒有實際定義參數(shù)的話, length 只會的得到02014-09-09
JS實現(xiàn)側(cè)邊欄鼠標經(jīng)過彈出框+緩沖效果
本文主要介紹了JS實現(xiàn)側(cè)邊欄鼠標經(jīng)過彈出框+緩沖效果的實現(xiàn)原理與方法步驟。具有很好的參考價值,下面跟著小編一起來看下吧2017-03-03
JS點擊圖片彈出文件選擇框并覆蓋原圖功能的實現(xiàn)代碼
這篇文章主要介紹了JS點擊圖片彈出文件選擇框并覆蓋原圖功能的實現(xiàn)代碼,需要的朋友可以參考下2017-08-08

