Postingan lainnya
bagaimana cara memfilter data grafik highcharts agar yang ditampilkan itu berdasarkan id ?
ini controller nya
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class C_datagt extends MY_Controller {
protected $access = array('Admin','Pengguna');
public function __construct()
{
parent::__construct();
$this->load->model('M_datagt');
}
public function index()
{
$data['suhu']=array();
$data['kelembaban']=array();
$data['gas']=array();
foreach($this->M_datagt->get()->result_array() as $row){
array_push($data['suhu'], (int) $row['suhu']);
array_push($data['kelembaban'], (int) $row['kelembaban']);
array_push($data['gas'], (int) $row['gas']);
}
$this->load->view('cover/header');
$this->load->view('v_datagt/tampil_datagt', array('data'=>$data));
$this->load->view('cover/footer');
}
}
/* End of file C_datagt.php */
/* Location: ./application/controllers/C_datagt.php */
ini model nya
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class M_datagt extends CI_Model {
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function get()
{
$id_gateway = $this->input->get('id_gateway');
$this->db->like('tanggal','2017-');
$this->db->order_by('tanggal','asc');
return $this->db->get_where('tb_datagt', array('id_gateway' => $id_gateway));
}
}
/* End of file M_datagt.php */
/* Location: ./application/models/M_datagt.php */
dan ini view nya
<aside class="right-side">
<!-- Main content -->
<section class="content-header">
<h1>Data Pengukuran</h1>
<ol class="breadcrumb">
</ol>
</section>
<form action="<?= site_url('C_datagt'); ?>" method="post">
<div class="form-group row">
<div class="col-xs-2">
<input class="form-control" name="id_gateway" id="id_gateway" type="text">
</div>
<button type="submit" class="btn btn-info">klik</button>
</div>
</form>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto">
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script type="text/javascript">
Highcharts.chart('container', {
chart: {
type: 'area'
},
title: {
text: 'Data Pengukuran SUHU, KELEMBABAN & GAS'
},
xAxis: {
categories: ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember']
},
credits: {
enabled: false
},
series: [{
name: 'SUHU',
data: <?php echo json_encode($data['suhu']); ?>
}, {
name: 'KELEMBABAN',
data: <?php echo json_encode($data['kelembaban']); ?>
}, {
name: 'GAS',
data: <?php echo json_encode($data['gas']); ?>
}]
});
</script>
</div>
</aside>
<!-- right-side -->
0
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban