Reputation: 3
I got this error when I tried to integrate Plugins for charts. The plugins I found online are all for cake version 2.*. I try to did the same for 3.0 and got this error.Here's my code.I also tried high charts and got the same thing.
use App\Controller\AppController;
App::uses('AppController', 'Controller');
App::uses('GoogleCharts', 'GoogleCharts.Lib');
class ChartsController extends AppController {
public $helpers = array('GoogleCharts.GoogleCharts');
//Setup data for chart
public function index() {
$chart = new GoogleCharts();
$chart->type("LineChart");
//Options array holds all options for Chart API
$chart->options(array('title' => "Recent Scores"));
$chart->columns(array(
//Each column key should correspond to a field in your data array
'event_date' => array(
//Tells the chart what type of data this is
'type' => 'string',
//The chart label for this column
'label' => 'Date'
),
'score' => array(
'type' => 'number',
'label' => 'Score',
//Optional NumberFormat pattern
'format' => '#,###'
)
));
//You can also manually add rows:
$chart->addRow(array('event_date' => '1/1/2012', 'score' => 55));
//Set the chart for your view
$this->set(compact('chart'));
}
}
Upvotes: 0
Views: 18178
Reputation: 60503
You cannot just throw Cake 2x and Cake 3x stuff together and expect it to work, in case the plugin is not made for 3.x, you simply cannot use it as such.
You are receiving the error because there is no App
class in the current namespace, Cake 3x uses real namespaces and autoloading, so if you'd wanted to use the App
class, you would have to import it using the use
statement
use Cake\Core\App;
However there is no App::uses()
anymore anyways, you either use autoloading, or simply include/require the files manually.
Suggested readings:
Upvotes: 3