Getting Error in moodle chart api

Getting Error in moodle chart api

by santhosh kumar -
Number of replies: 1

Hi All,

 I am working on chart api in moodle 3.4. I am get exception error "Exception - Argument 1 passed to core\chart_base::add_series() must be an instance of core\chart_series, string given, called in [dirroot]\blocks\charttest\moodlechart.php on line 25". What i am missing in code.

// my file is in blocks/charttest/moodlechart.php

require_once("../../config.php");

require_once($CFG->libdir.'/lib.php');

$chart = new core\chart_bar();

print_r($chart);        /// printing object value as well

$labels = array(20,40,80,100);
$sales = array(100,200,300,400,500,600,700);
$expenses = array(50,60,70,80,90,100,110);

$chart->set_stacked(true);
$chart->add_series($saless);
$chart->add_series($expensess);
$chart->set_labels($labelss);
echo $OUTPUT->render($chart);





Average of ratings: -