Chartjs-Call to undefined method App\Charts\SampleChart::labels(), chartjs

1👍

It looks like you are trying to call ->labels() on an instance of SampleChart based on the principle of multi-inheritance in php. The problem with that here is that ->labels() is a method of Chartisan class not SampleChart or BaseChart which it extends, hence the error you get (basically just saying hey, I cannot find labels()).

See this answer for an explanation of multi-level inheritance in PHP.
More info: https://www.php.net/manual/en/language.oop5.inheritance.php

I’m curious what your use case for doing this in your controller is though. If it is for rendering, the docs you provided has this: https://charts.erik.cat/guide/render_charts.html

Leave a comment