ハイチャートグラフの表示を指定するには、HTMLでselectの値を使用するにはどうすればよいですか?
たとえば、Yesterday's graph
を表示する場合は、HTMLページの選択フォームでYesterday
を選択します。 March's graph
を表示したいのと同じです。March
で選択します。各グラフについて、HTMLとは別に外部JSがあります。 (1つのJS 1つのグラフ用ファイル)をハイチャートグラフを表示するにはHTMLのselectタグに依存する
HTMLを選択
<select class="selectpicker" data-width="15%" data-style="btn-danger">
<option id="yesterday" value="yesterday">Yesterday</option>
<option id="pre_month_1" value="pre_month_1">March</option>
<option id="pre_month_2" value="pre_month_2">Febuary</option>
<option id="pre_month_3" value="pre_month_3">January</option>
</select>
<div id="graph_power_yesterday" style="height: 400px;"></div>
<div id="graph_power_march" style="height: 400px;"></div>
まずJSファイル(最初のグラフ)
$(document).ready(function(){
function read(){
$.post("graph_power_yesterday.php",
function(data, status){
if(status == 'success'){
cur_date = (data.cur_date.join(','));
pow_dat_1hr_00 = Number(data.pow_dat_1hr_00.join(','));
graph_power_yesterday(cur_date, pow_dat_1hr_00);
}
});
};
read();
function graph_power_yesterday(cur_date, pow_dat_1hr_00){
Highcharts.chart('graph_power_yesterday', {
// ====
});
};
});
第二のjsファイル(2番目のグラフ)
$(document).ready(function(){
function read(){
$.post("graph_power_march.php",
function(data, status){
if(status == 'success'){
cur_date = (data.cur_date.join(','));
pow_dat_1hr_00 = Number(data.pow_dat_1hr_00.join(','));
graph_power_march(cur_date, pow_dat_1hr_00);
}
});
};
read();
function graph_power_march(cur_date, pow_dat_1hr_00){
Highcharts.chart('graph_power_march', {
// ====
});
};
});
[これを確認してください](http://jsfiddle.net/hKGSK/)あなたのお役に立てば幸いです。 –
ありがとう、それは私を助けます。 – Nothingnez