/** * Adds a dataset to the charts data * * @param string $name Name of dataset * @param ezcGraphDataSet $dataSet * @param mixed $values Values to create dataset with * @throws ezcGraphTooManyDataSetExceptions * If too many datasets are created * @return ezcGraphDataSet */ protected function addDataSet($name, ezcGraphDataSet $dataSet) { $this->data[$name] = $dataSet; $this->data[$name]->label = $name; $this->data[$name]->palette = $this->chart->palette; $this->data[$name]->displayType = $this->chart->getDefaultDisplayType(); }
/** * Does the magic. Creates all necessary stuff and finally * saves the graph to the specified filename * * @param string $strFilename * @return void */ public function saveGraph($strFilename) { $this->preGraphCreation(); if (strpos($strFilename, _realpath_) === false) { $strFilename = _realpath_ . $strFilename; } $this->objGraph->render($this->intWidth, $this->intHeight, $strFilename); }
/** * Add links to clickable SVG elements in a chart with SVG driver. * * @param ezcGraphChart $chart * @return void */ public static function linkSvgElements(ezcGraphChart $chart) { if (!$chart->driver instanceof ezcGraphSvgDriver) { throw new ezcGraphToolsIncompatibleDriverException($chart->driver, 'ezcGraphSvgDriver'); } $fileName = $chart->getRenderedFile(); if (!$fileName) { throw new ezcGraphToolsNotRenderedException($chart); } $dom = new DOMDocument(); $dom->load($fileName); $xpath = new DomXPath($dom); $elements = $chart->renderer->getElementReferences(); // Link chart elements foreach ($elements['data'] as $dataset => $datapoints) { foreach ($datapoints as $datapoint => $ids) { $url = $chart->data[$dataset]->url[$datapoint]; if (empty($url)) { continue; } foreach ($ids as $id) { $element = $xpath->query('//*[@id = \'' . $id . '\']')->item(0); $element->setAttribute('style', $element->getAttribute('style') . ' cursor: ' . $chart->driver->options->linkCursor . ';'); $element->setAttribute('onclick', "top.location = '{$url}'"); } } } // Link legend elements if (isset($elements['legend'])) { foreach ($elements['legend'] as $objectName => $ids) { $url = $elements['legend_url'][$objectName]; if (empty($url)) { continue; } foreach ($ids as $id) { $element = $xpath->query('//*[@id = \'' . $id . '\']')->item(0); $element->setAttribute('style', $element->getAttribute('style') . ' cursor: ' . $chart->driver->options->linkCursor . ';'); $element->setAttribute('onclick', "top.location = '{$url}'"); } } } $dom->save($fileName); }
/** * Set colors and border for this element * * @param ezcGraphPalette $palette Palette * @return void */ public function setFromPalette(ezcGraphPalette $palette) { foreach ($this->additionalAxis as $element) { $element->setFromPalette($palette); } parent::setFromPalette($palette); }
/** * Property write access * * @throws ezcBasePropertyNotFoundException * If Option could not be found * @throws ezcBaseValueException * If value is out of range * @param string $propertyName Option name * @param mixed $propertyValue Option value; * @return void * @ignore */ public function __set($propertyName, $propertyValue) { switch ($propertyName) { case 'axis': if ($propertyValue instanceof ezcGraphChartElementAxis) { $this->addElement('axis', $propertyValue); $this->elements['axis']->position = ezcGraph::BOTTOM; $this->elements['axis']->axisLabelRenderer = new ezcGraphAxisRadarLabelRenderer(); $this->renderElement['axis'] = false; } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphChartElementAxis'); } break; case 'rotationAxis': if ($propertyValue instanceof ezcGraphChartElementAxis) { $this->addElement('rotationAxis', $propertyValue); $this->renderElement['rotationAxis'] = false; } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphChartElementAxis'); } break; case 'renderer': if ($propertyValue instanceof ezcGraphRadarRenderer) { parent::__set($propertyName, $propertyValue); } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphRadarRenderer'); } break; default: parent::__set($propertyName, $propertyValue); } }
/** * Property write access * * @throws ezcBasePropertyNotFoundException * If Option could not be found * @throws ezcBaseValueException * If value is out of range * @param string $propertyName Option name * @param mixed $propertyValue Option value; * @return void * @ignore */ public function __set($propertyName, $propertyValue) { switch ($propertyName) { case 'axis': if ($propertyValue instanceof ezcGraphChartElementAxis) { $this->addElement('axis', $propertyValue); $this->elements['axis']->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $this->elements['axis']->axisLabelRenderer->showZeroValue = true; $this->elements['axis']->position = ezcGraph::LEFT; $this->elements['axis']->axisSpace = 0.05; } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphChartElementAxis'); } break; case 'renderer': if ($propertyValue instanceof ezcGraphOdometerRenderer) { parent::__set($propertyName, $propertyValue); } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphOdometerRenderer'); } break; default: parent::__set($propertyName, $propertyValue); } }
/** * Constructor * * @param array $options Default option array * @return void * @ignore */ public function __construct(array $options = array()) { $this->options = new ezcGraphPieChartOptions($options); parent::__construct($options); $this->data = new ezcGraphChartSingleDataContainer($this); }