我正在使用chart.js来创建带有控制器和视图的图形:
控制器:
public function clickGraphic(){
$home_data['click'] = $this->intranet_model->clickedFiles();
$home = $this->load->view('modules/Home/index', $home_data, true);
return $home;
}
观点:
<div class="portlet-body">
<div class="row">
<div class="col-md-12 col-sm-12">
<canvas id="filesChart" width="650" height="400"></canvas>
</div>
</div>
</div>
我在这里创建图形:
$(function(){
var barChartData = {
labels : [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ],
datasets : [
{
fillColor : "rgba(11,103,158,0.5)",
strokeColor : "rgba(11,103,158,1)",
data : [7,5,4,3,3,3,2,2,2,1]
}
]
}
var barChartData1 = {
labels : ["January","February","March","April","May","June","July"],
datasets : [
{
fillColor : "rgba(11,103,158,0.5)",
strokeColor : "rgba(11,103,158,1)",
data : [28,48,40,19,96,27,100]
},
{
fillColor : "rgba(255,245,0,0.5)",
strokeColor : "rgba(255,245,0,1)",
data : [5,8,13,21,34,55,89]
},
]
}
var myLine = new Chart(document.getElementById("filesChart").getContext("2d")).Bar(barChartData);
var myLine = new Chart(document.getElementById("filesChart2").getContext("2d")).Bar(barChartData1);
});
在第一页加载它可以工作,但是当我从另一个视图再次调用控制器时,我松开了图形。我该如何维护呢?
<ul class="page-breadcrumb breadcrumb">
<li>
<i class="icon-home"></i>
<a href="/admin/clickGraphic/">Página Principal</a>
</li>
</ul>