DMU
DMU

Reputation: 69

Laravel Chart doesn't render the graph. Undefined variable: chart

I'm new in Laravel Chart. I followed all the steps in the guide (https://charts.erik.cat/getting_started.html). I'm working with Laravel 5.5 and I loaded the C3 library: '''php artisan make:chart alarmChart C3''' My controller: '''public function testChart() {

    $chart = new SampleChart;
    $chart->labels(['One', 'Two', 'Three', 'Four']);
    $chart->dataset('My dataset', 'line', [1, 2, 3, 4]);
    $chart->dataset('My dataset 2', 'line', [4, 3, 2, 1]);

    return view('AlarmMonitoring.Dashboard.alarmDashboard', compact('chart'));
}'''

My Route: '''Route::get('/AlarmMonitoring/AllAlarms/Dashboard', 'AlarmChartController@testChart');''' and my view: '''@extends('templates.2_layout')

@section('content') @include('templates.alarmMonitoringMenu')

TESTING CHARTS

{!! $chart->container() !!}

@endsection

@section('javascripts') @parent

{!! $chart->script() !!}

@endsection'''

I don't understand why the error is returned: Undefined variable: chart. can anyone help me understand? Thanks in advance Regards

Upvotes: 0

Views: 686

Answers (1)

DMU
DMU

Reputation: 69

I changed the original

use App\Charts\sampleChart;    

in my personal

use App\Charts\alarmChart;    

Upvotes: 0

Related Questions