/** * Renders the chart into the page * * Given a chart label and an HTML element id, this will output * all of the necessary javascript to generate the chart. * * @access public * @since v2.0.0 * * @param string $chartType Type of chart to render. * @param string $chartLabel Label of a saved chart. * @param string $elementId HTML element id to render the chart into. * @param mixed $divDimensions Set true for div creation, or pass an array with height & width * * @return string */ public function renderChart($chartType, $chartLabel, $elementId, $divDimensions = false) { $jsOutput = ''; $chart = $this->volcano->getChart($chartType, $chartLabel); if ($this->jsFactory->coreJsRendered() === false) { $jsOutput = $this->jsFactory->getCoreJs(); $this->jsFactory->coreJsRendered(true); } if ($divDimensions !== false) { $jsOutput .= $this->div($elementId, $divDimensions); } $jsOutput .= $this->jsFactory->getChartJs($chart, $elementId); return $jsOutput; }
/** * Outputs the chart javascript into the page * * Pass in a string of the html elementID that you want the chart to be * rendered into. * * @since v2.0.0 * @param string $ei The id of an HTML element to render the chart into. * @throws InvalidElementId * * @return string Javscript code blocks */ public function render($ei) { $jsf = new JavascriptFactory(); return $jsf->getChartJs($this, $ei); }