これを行う方法を理解するのに苦労しています。私はウェブでいくつかの検索を行ってきましたが、いくつかの例を試しましたが、これを正しく行うことができませんでした. 私は codeigniter フレームワークを使用しており、ビュー ファイルの foreach ループから "カテゴリ" と "データ" 部分の javascript 関数に、静的な値ではなくグラフのパラメーターとしてデータベースの値を渡したいと考えています。$row->Time_Period;
データベースの値を$row->Data_Value;
、ビュー ファイルの本体から javascript 関数部分の「カテゴリ」と「データ」に渡すにはどうすればよいですか? またはこれを処理する他のアプローチはありますか?誰かがこれで私を助けてくれますか? どうもありがとう。以下は私のコードです。
Javascript 関数
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'RDI SYSTEM'
},
xAxis: {
categories: ['2012','2013']
},
yAxis: {
allowDecimals: false,
min: 0,
title: {
text: 'Values'
}
},
tooltip: {
formatter: function() {
return '<b>'+ this.x +'</b><br/>'+
this.series.name +': '+ this.y +'<br/>'+
'Total: '+ this.point.stackTotal;
}
},
plotOptions: {
column: {
stacking: 'normal'
}
},
series: [ {
name: 'jun',
data: [3000,2000],
stack: 'male'
}]
});
});
</script>
ファイルを閲覧する:
<?php
$submit=array('class'=>'btn','name'=>'submit','id'=>'submit','value'=>'Submit');
$indicator=array('name'=>'indicator','id'=>'indicator','value'=>'','placeholder'=>'Indicator Name');
$description=array('name'=>'description','id'=>'description','value'=>'','placeholder'=>'Description');
?>
<?php
$subsector_dropdown=array('0'=>'Select Sub-Sector');
$classes_dropdown=array('0'=>'Select Class');
$indicator_dropdown=array('0'=>'Select Indicator');
?>
<div class="hero-unit">
<div class="row-fluid">
<div class="span2"> <label><strong><h3>No.Of Rows:</h3></strong></label></div>
<div id="numrows" class="span1">
<h3 class="numrows"><strong><?php echo $total_rows; ?></strong></h3>
</div>
<div class="span7"> <h1><?php echo "List of Infrastructure Data"; ?></h1></div>
</div>
<div class="row-fluid">
<div class="span3"><i class="icon-plus"></i> <a href='<?php echo site_url('rdi_controller/insert_infra')?>'><strong>Add Infrastructure Data</strong></a></div>
<?php
$indicator_dropdown=array('0'=>'Select Indicators');
$year_dropdown=array('0'=>'Select Years','1'=>'Select All');
?>
<div class="span4">
<h2> <?php echo form_open('rdi_controller/infra');?>
<div class="input-append">
<?php echo form_dropdown("area_name",$area_name_dropdown,'','id="area_id" style="width:50%;height:130%"'); ?>
<?php echo form_dropdown("indicator",$indicator_dropdown,'','id="indicator_id" style="width:50%;height:130%"'); ?>
<?php echo form_dropdown("year",$year_dropdown,'','id="year_id" style="width:30%;height:130%"'); ?>
<input type="submit" class="btn btn-primary btn-medium" id="submit" name="search" value="Search"><button class="btn btn-primary btn-xlarge" type="button" id="displayAll" onclick="reload()">Display All</button>
</div>
<?php echo form_close();?> </h2>
<table class="table table-stripe">
<tr>
<td><a href='<?php echo site_url('rdi_controller/Infra_export_to_pdf')?>'> <img src="<?php echo base_url('img/pdf.png'); ?> " width="35" height="35" title="Export to PDF File"/></a><a href='<?php echo site_url('rdi_controller/Infra_export_to_Excel')?>'> <img src="<?php echo base_url('img/spreadsheet.png'); ?>" width="35" height="35" title="Export to Excel File" class="excel"/> </a></td>
</tr>
</table>
</br>
<table id="tablesorter-demo" class="tablesorter">
<thead>
<tr>
<th><strong>Select</strong></th>
<th><strong>Sector</strong></th>
<th><strong>Subsector</strong></th>
<th><strong>Class</strong></th>
<th><strong>Indicator</strong></th>
<th><strong>Data Value</strong></th>
<th><strong>Unit</strong></th>
<th><strong>Time Period</strong></th>
<th><strong>Area Name</strong></th>
</tr>
</thead>
<?php foreach($infra as $row){?>
<tr>
<td><input type='checkbox' id='chk' name='infra_id[]' value="<?php echo $row->fusion_id;?>" ></td>
<td> <?php echo anchor("rdi_controller/infra_update_form/$row->infra_id/",$row->Sector); ?></td>
<td><?php echo $row->Subsector ;?></td>
<td><?php echo $row->Classes ;?></td>
<td><?php echo $row->Indicator ;?></td>
<td><?php echo $row->Data_Value ;?></td>
<td><?php echo $row->Unit ;?></td>
<td><?php echo $row->Time_Period ;?></td>
<td><?php echo $row->Area_Name ;?></td>
</tr>
<?php }?>
</table>
<div class='row'>
<div class='span2 '><strong>Total Rows</strong> </div>
<div class='span1 ' colspan=6><strong><?php echo $total_rows; ?></strong></div>
</div>
出力: