我有两个文件 1. Analytics.php 2. data_edgefactor.php
Analytics.php 代码
<script type="text/javascript">
function show_auth(auth_id){
$.post("analysis_table/show_table_ef.php", {AUTHID_TEST_EF: ""+auth_id+""}, function(data_ef){
if(data_ef.length > 0) {
//////////////////////DATA OUTPUT//////////////////////
document.getElementById('get_table_ef').innerHTML = data_ef;
}
});
$.post("analysis_table/data_edgefactor.php", {AUTHID_TEST_EF: ""+auth_id+""}, function(data_ef){
var options = {
chart: {
renderTo: 'container_edgefactor',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
xAxis: {
title: {
text: 'Year'
},
categories: []
},
yAxis: {
title: {
text: 'Number of Citations'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
series: [{
type: 'line',
name: 'Citations',
data: []
}]
}
$.getJSON("analysis_table/data_edgefactor.php", {AUTHID_TEST_EF:auth_id}, function(data_ef) {
options.series[0].data = data_ef;
chart = new Highcharts.Chart(options);
});
});
}
</script>
<?php
echo '<a href="#" style="text-decoration:none; color: #000;" onClick="show_auth('.$id_auth.')">'.$get_auth.'</a>'; ?>
<div id="container_edgefactor" style="width: 900px; height: 400px; "></div>
<select name="from_year">
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
</select>
and
<select name="to_year">
<option value="1991">1991</option>
<option value="1992">1992</option>
<option value="1993">1993</option>
</select>
<input id="fixsubmit" type="submit" name="update_citations" value="Update Graph">
2.data_edgefactor.php代码
<?php
include '../connect.php';
$get = $_REQUEST['AUTHID_TEST_EF'];
$result_citations = mysql_query("SELECT year, citations, auth_id FROM subj_area WHERE auth_id='$get'");
$rows_citations = array();
while($r_citations = mysql_fetch_array($result_citations)) {
$row_citations[0] = $r_citations[0];
$row_citations[1] = $r_citations[1];
array_push($rows_citations,$row_citations);
}
print json_encode($rows_citations, JSON_NUMERIC_CHECK);
?>
这里一切正常,图表通过 onclick 功能根据用户显示,但我需要过滤年份并根据用户选择的年份显示图表。
怎么做。请帮忙。