我想在我使用lavacharts的同一视图上显示我的所有图表我给了我的图表不同的no但在视图中它显示了控制器中的最后一个图表。
控制器代码:
function l()
{
$lava = new Lavacharts; // See note below for Laravel
$reasons = \Lava::DataTable();
$abs=Absencecollab::all();
$r=$abs->count();
$absm=Absencecollab::where('motif','maladie');
$tm=$absm->count();
$absc=Absencecollab::where('motif','conge');
$tc=$absc->count();
$absnj=Absencecollab::whereNull('motif');
$tnj=$absnj->count();
$pm=($tm100)/$r;
$pc=($tc100)/$r;
$pnj=($tnj100)/$r;
$reasons->addStringColumn('Reasons')
->addNumberColumn('Percent')
->addRow(['Maladie',$pm ])
->addRow(['Conge',$pc])
->addRow(['Absence non justifiée',$pnj]);
\Lava::PieChart('IMDB', $reasons, [
'title' => 'Abscences collaborateurs par motif',
'is3D' => true,
'slices' => [
['offset' => 0.2],
['offset' => 0.25],
['offset' => 0.3]
]
]);
$reasons1 = \Lava::DataTable();
$abs1=Absence::all();
$r1=$abs1->count();
$absm1=Absence::where('motif','maladie');
$tm1=$absm1->count();
$absc1=Absence::where('motif','conge');
$tc1=$absc1->count();
$absnj1=Absencecollab::whereNull('motif');
$tnj1=$absnj1->count();
$pm1=($tm1100)/$r;
$pc1=($tc1100)/$r;
$pnj1=($tnj1*100)/$r;
$reasons1->addStringColumn('Reasons')
->addNumberColumn('Percent')
->addRow(['Maladie',$pm1 ])
->addRow(['Congé parents',$pc1])
->addRow(['Absence non justifiée',$pnj1]);
\Lava::PieChart('abse', $reasons1, [
'title' => 'Abscences enfants par motif',
'is3D' => true,
'slices' => [
['offset' => 0.2],
['offset' => 0.25],
['offset' => 0.3]
]
]);
return view('statistiquesg');
查看代码
@piechart('IMDB', 'chart-div')
<canvas id="line" height="300" width="450"></canvas>
</div>
</section>
</div>
<!-- Bar -->
<div class="col-lg-6">
<section class="panel">
<header class="panel-heading">
Absence enfants
</header>
<div class="panel-body text-center" id="chart-div">
@piechart('abse', 'chart-div')
<canvas id="bar" height="300" width="500"></canvas>
</div>
</section>
</div>
答案 0 :(得分:0)
@piechart
的第二个参数是div的ID,两个饼图都使用chart-div
id。