我是 highcharts 的新手。我目前正在使用 DB2。我可以知道如何使用以下方法获取数据:
1) select 语句 2) 存储过程 3) 用户定义函数
我不太确定我是否做得正确。我在 xhtml h:head 部分中有这段代码
<?php
$sql = "select ccy, vdate, valrate from belsize.excrate where enterpriseid = '9cd15270-013d-f4d3-f70c-c0a80172aa77' and vdate >= '2013-10-01' and vdate <= '2013-10-10' and ccy = 'MYR'";
$result = mysql_query($sql);
$excrate = array();
while ($row = mysql_fetch_assoc($result)) {
$excrate[] = $row['ccy'];
$excrate[] = $row['vdate'];
$excrate[] = $row['valrate'];
}
?>
<script type="text/javascript">
$(function () {
$('#container2').highcharts({
title: {
text: 'Exchange Rate',
x: -20 //center
},
subtitle: {
text: 'Source: From Excrate table',
x: -20
},
xAxis: {
categories: ['1', '2', '3', '4', '5']
},
yAxis: {
title: {
text: 'Rate'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: ''
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
data: [<?php echo join($excrate, ', '); ?>]
}]
});
});
</script>
在 h:form 部分下,我有以下代码
<div id="container2" style="min-width: 310px; height: 400px; margin: 0 auto"></div>