/** * Responsible for generating opening tags and any content that needs to go directly inside * @param \Altamira\Chart $chart * @param array $styleOptions * @return string */ public static function preRender(\Altamira\Chart $chart, array $styleOptions = array()) { $style = self::renderStyle($styleOptions); return <<<ENDDIV <div class="{$chart->getLibrary()}" id="{$chart->getName()}" style="{$style}"> ENDDIV; }
$chart7 = new Chart('chart7', $library); $chart7->addSeries($chart7->createManySeries(array(array('Screws', 4, 7, 5), array('Nails', 5, 3, 6), array('Bolts', 4, 5, 7), array('Nuts', 3.5, 4, 6), array('Washers', 3, 2, 5), array('Pliers', 4, 1, 5), array('Hammers', 4.5, 6, 6)), $bubbleFactoryMethod, 'Bubble'))->setTitle('Bubble Chart')->setType('Bubble', array('bubbleAlpha' => 0.5, 'highlightAlpha' => 0.7))->setAxisOptions('x', 'min', 2)->setAxisOptions('x', 'max', 6)->setAxisOptions('y', 'min', -2)->setAxisOptions('y', 'max', 10); if ($library == \Altamira\JsWriter\JqPlot::LIBRARY) { foreach ($chart7->getSeries() as $series) { $series->useLabels(); } } $array1 = array(1, 4, 8, 2, 1, 5); $array2 = array(3, 3, 5, 4, 2, 6); $num = max(count($array1), count($array2)); for ($i = 0; $i < $num; $i++) { $total = $array1[$i] + $array2[$i]; $array1[$i] = $array1[$i] / $total * 100; $array2[$i] = $array2[$i] / $total * 100; } $chart8 = new Chart('chart8', $library); $chart8->setTitle('Vertical Stack Chart')->addSeries($chart8->createSeries(TwoDimensionalPointFactory::getFromYValues($array1), 'Is'))->addSeries($chart8->createSeries(TwoDimensionalPointFactory::getFromYValues($array2), 'Is Not'))->setType('Bar', array('stackSeries' => true))->setLegend(array('on' => true, 'location' => 'se', 'x' => 5, 'y' => 5))->setAxisOptions('y', 'max', 100); $charts = array($chart, $chart2, $chart3, $chart4, $chart5, $chart6, $chart7, $chart8); if ($library == \Altamira\JsWriter\Flot::LIBRARY) { $charts[] = $chart6a; } $chartIterator = new ChartIterator($charts); ?> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <!-- enable this if you want to display the charts on IE --> <!--<script type="text/javascript" src="js/excanvas.js"></script>--> <?php
/** * Closes div created on preRender * @param \Altamira\Chart $chart * @param array $styleOptions * @return string */ public static function postRender(\Altamira\Chart $chart, array $styleOptions = array()) { return $chart->titleHidden() ? '' : '</div>'; }