/** * 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 3.0.0 * @param string $type * @param \Khill\Lavacharts\Values\Label $label * @param \Khill\Lavacharts\Values\ElementId $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 Javascript output * @throws \Khill\Lavacharts\Exceptions\ChartNotFound * @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue * @throws \Khill\Lavacharts\Exceptions\InvalidDivDimensions */ private function renderChart($type, Label $label, ElementId $elementId, $divDimensions = false) { $jsOutput = ''; if ($this->jsFactory->coreJsRendered() === false) { $jsOutput = $this->jsFactory->getCoreJs(); } if ($divDimensions !== false) { $jsOutput .= $this->div($elementId, $divDimensions); } $jsOutput .= $this->jsFactory->getChartJs($this->volcano->getChart($type, $label), $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. * * @deprecated Use the Lavacharts master object to keep track of charts to render. * @codeCoverageIgnore * @access public * @since 2.0.0 * @param string $elemId The id of an HTML element to render the chart into. * @return string Javascript code blocks * @throws \Khill\Lavacharts\Exceptions\InvalidElementId * */ public function render($elemId) { trigger_error("Rendering directly from charts is deprecated. Use the render method off your main Lavacharts object.", E_USER_DEPRECATED); $jsf = new JavascriptFactory(); return $jsf->getChartJs($this, $elemId); }