[英]Chartjs not showing chart
Here is my view, where I'm trying to render chart: 这是我的视图,正在尝试绘制图表:
<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>
My controller, with the most simple test example: 我的控制器,带有最简单的测试示例:
$chart = new CandidatesAgeChart;
$chart->labels(['2 days ago', 'Yesterday', 'Today']);
$chart->dataset('My dataset', 'line', [$variable1, $variable2, $variable3]);
return view('chart', compact('chart'));
and lastly, CandidateAgeChart, left as created. 最后是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();
}
}
When I go to this specific view, chart is not being shown. 当我转到该特定视图时,未显示图表。 I'm not sure what exactly I need to amend in order to get this to work, and documentation did not gave me the answer.
我不确定我到底需要修改什么才能使它生效,并且文档没有给我答案。
You need to add {!! 您需要添加{!! $chart->script() !!} to your view.
$ chart-> script()!!}添加到您的视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.