从控制器渲染图查看

我正在使用laravel图表(laraveldaily)

控制器

$options = [
            'chart_title' => 'Animals by type','chart_type' => 'pie','report_type' => 'group_by_relationship','model' => 'App\Animal','relationship_name' => 'type',// represents function type() on Transaction model
            'group_by_field' => 'category',// types.category


            'filter_months' => 12,// show only transactions for last 30 days

        ];

        $chart2 = new LaravelChart($options);

        return view('admin.index',compact('users','chart2'));

我认为我有

<div class="row pl-lg-5" style="width: 40%;">
                             <h1>{{ $chart2->options['chart_title'] }}</h1>
                             {!! $chart2->renderHtml() !!}
                             <hr>
                         </div>

@section('scripts')
    {!! $chart2->renderJs() !!}
    {!! $chart2->renderChartJslibrary() !!}
@endsection

我只得到标题,没有图表

zwx10527 回答:从控制器渲染图查看

在您呈现使用Chart

的JS代码之前,包含之前来自CloudFlare的ChartJS库。
@section('scripts')
{!! $chart2->renderChartJsLibrary() !!}
{!! $chart2->renderJs() !!}
@endsection

希望这会有所帮助

本文链接:https://www.f2er.com/3160980.html

大家都在问