这是我的视图,正在尝试绘制图表:
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/0.2.0/Chart.min.js" type="text/javascript">
<script src="bower_components/Chart.js/Chart.js" language="javascript"></script><div><canvas id="countries" width="600" height="400"></canvas></div>
<div class="container">
<div class="row">
<div style="width:75%;">{!! $chart->container() !!}
</div>
我的控制器,带有最简单的测试示例:
$chart = new CandidatesAgeChart;
$chart->labels(['2 days ago', 'Yesterday', 'Today']);
$chart->dataset('My dataset', 'line', [$variable1, $variable2, $variable3]);
return view('chart', compact('chart'));
最后是CandidateAgeChart,保持原样。
<?php
namespace App\Charts;
use ConsoleTVs\Charts\Classes\Chartjs\Chart;
class CandidatesAgeChart extends Chart
{
/**
* Initializes the chart.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
}
答案 0 :(得分:0)
您需要添加{!! $ chart-> script()!!}添加到您的视图。