<!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" src="http://cdn.hcharts.cn/highcharts/exporting.js"></script>
<script type="text/javascript">
$(function (){
$('#container').highcharts({
title: {
text: '?',
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: '数据'
},
},
series: [{
name: '?',
data: []
}]
});
});
</script>
<script type="text/javascript">
$(function () {
$('#container2').highcharts({
title: {
text: '链球菌毒素O',
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: '数据'
},
},
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>
<h1>曲线图</h1>
<!-- 第一个空图 -->
<div id="container" style="width:300px;height:300px;float:left;"></div>
<!-- 第二个有数据的图 -->
<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>
怎么把页面Table的值传到jquery里?
这个可以:
<!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: '数据'
},
},
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);
chart.setTitle({text:d.name});
chart.redraw();
}
</script>
<script type="text/javascript">
$(function () {
new Highcharts.Chart({
chart: {
renderTo: 'container2'
},
title: {
text: '链球菌毒素O',
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: '数据'
},
},
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='显示表格数据'/>
<h1>曲线图</h1>
<!-- 第一个空图 -->
<div id="container" style="width:300px;height:300px;float:left;"></div>
<!-- 第二个有数据的图 -->
<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>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。