function __construct($values, $labels) { parent::__construct(); $this->values = $values; $this->labels = $labels; $this->oChart = $this->buildChart(); }
protected function setUpGraph() { parent::setUpGraph(); $aDataSets = $this->getDataSets(); // if no data, or only one data point, we don't display the graph if (count($this->xLabels) <= 1) { return false; } $chart = $this->getGraph(); //set up the axes $y_axis = $this->createYAxis(); $y_axis->set_range(max(0, $this->getMinYValue() - 1), $this->getMaxYValue() + 1); $y_axis->set_steps(ceil($this->getMaxYValue() / 4)); $y_axis->set_label_text("#val#" . $this->yUnit); //y_axis legend $y_legend = new y_legend('Viewers'); $y_legend->set_style('color: #515151; font-size: 12px;'); $chart->set_y_legend($y_legend); $x_axis = $this->createXAxis(); $x_values = $this->xLabels; $xSteps = 5; if (count($x_values) < $xSteps) { $xSteps = count($x_values); } else { // hack around the set_steps that doesn't seem to work for X axis foreach ($x_values as $i => &$xValue) { if ($i % $xSteps != 0) { $xValue = ''; } } } $x_axis->set_steps($xSteps); $x_labels = new x_axis_labels(); $x_labels->set_labels($x_values); // Add the X Axis Labels to the X Axis $x_axis->set_labels($x_labels); $chart->add_y_axis($y_axis); $chart->x_axis = $x_axis; $oColorHelper = new Graph_DataSetColorsHelper(); foreach ($aDataSets as $aDataSet) { $values = $aDataSet['values']; $name = $aDataSet['name']; $aColors = $oColorHelper->getNextColors(); $dotValues = $this->buildDotValues($aColors['line'], $values, $name); $area = $this->createArea($aColors['line'], $aColors['fill']); $area->set_fill_alpha("0.1"); $area->set_values($dotValues); $area->set_text($name); // add the area object to the chart: $chart->add_element($area); } return $chart; }