从控制器到视图的渲染图

问题描述 投票:0回答:1

我正在使用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

我只得到标题,没有图表

laravel
1个回答
0
投票

包括CloudFlare的ChartJS库之前,您呈现使用Chart的JS代码>

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

希望这会有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.