動(dòng)態(tài)更新highcharts數(shù)據(jù)的實(shí)現(xiàn)方法
動(dòng)態(tài)更新highcharts數(shù)據(jù)的實(shí)現(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è)置標(biāo)題 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>
<!-- 第一個(gè)空?qǐng)D -->
<div id="container" style="width:300px;height:300px;float:left;"></div>
<!-- 第二個(gè)有數(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>
以上這篇?jiǎng)討B(tài)更新highcharts數(shù)據(jù)的實(shí)現(xiàn)方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
基于dataset的使用和圖片延時(shí)加載的實(shí)現(xiàn)方法
下面小編就為大家分享一篇基于dataset的使用和圖片延時(shí)加載的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2017-12-12
JavaScript function 的 length 屬性使用介紹
函數(shù)的 length 得到的是形參個(gè)數(shù),如果函數(shù)內(nèi)部是通過arguments 調(diào)用參數(shù),而沒有實(shí)際定義參數(shù)的話, length 只會(huì)的得到02014-09-09
JS實(shí)現(xiàn)側(cè)邊欄鼠標(biāo)經(jīng)過彈出框+緩沖效果
本文主要介紹了JS實(shí)現(xiàn)側(cè)邊欄鼠標(biāo)經(jīng)過彈出框+緩沖效果的實(shí)現(xiàn)原理與方法步驟。具有很好的參考價(jià)值,下面跟著小編一起來看下吧2017-03-03
JS點(diǎn)擊圖片彈出文件選擇框并覆蓋原圖功能的實(shí)現(xiàn)代碼
這篇文章主要介紹了JS點(diǎn)擊圖片彈出文件選擇框并覆蓋原圖功能的實(shí)現(xiàn)代碼,需要的朋友可以參考下2017-08-08
淺談JavaScript暫時(shí)性死區(qū)與垃圾回收機(jī)制
本文主要介紹了淺談JavaScript暫時(shí)性死區(qū)與垃圾回收機(jī)制,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05

