public function testAreaRender()
 {
     $extOptions = new ExtendedOptionsContainer();
     $extOptions->setStickyColour('apples', '#629632');
     $extOptions->setStickyColour('oranges', '#CD3700');
     $options = new OptionsContainer('chart');
     $options->setRenderTo('chart_example_59');
     $options->setMarginRight(130);
     $options->setMarginBottom(25);
     $titleOptions = new OptionsContainer('title');
     $titleOptions->setText('Monthly Details');
     $titleOptions->setX(-20);
     $data = new Data();
     $data->addSeries('Apples', array('2012-05-01' => 12, '2012-05-02' => 3, '2012-05-03' => 33))->addSeries('Oranges', array('2012-05-01' => 32, '2012-05-02' => 36, '2012-05-03' => 18));
     // put it all together
     $chart = new Chart();
     $chart->addOptions($options);
     $chart->addOptions($titleOptions);
     $chart->addOptions($extOptions);
     $chart->setData($data);
     $chart->setRenderer(new Area());
     // test the full expected output
     $this->assertSame('var chart_example_59; chart_example_59 = new Highcharts.Chart({"chart":{"renderTo":"chart_example_59","marginRight":130,"marginBottom":25,"type":"area"},"title":{"text":"Monthly Details","x":-20},"xAxis":{"categories":["2012-05-01","2012-05-02","2012-05-03"]},"series":[{"name":"Apples","data":[12,3,33],"color":"#629632"},{"name":"Oranges","data":[32,36,18],"color":"#CD3700"}]});', $chart->render());
     $this->assertSame('<div id="chart_example_59"></div>', $chart->renderContainer());
 }
Exemple #2
0
 public function testRender()
 {
     $extOptions = new ExtendedOptionsContainer();
     $extOptions->setStickyColour('apples', '#629632');
     $extOptions->setStickyColour('oranges', '#CD3700');
     $options = new OptionsContainer('chart');
     $options->setRenderTo('chart_example_59');
     $options->setMarginRight(130);
     $options->setMarginBottom(25);
     $titleOptions = new OptionsContainer('title');
     $titleOptions->setText('Monthly Details');
     $titleOptions->setX(-20);
     $data = new Data();
     $data->addCount('Apples', 32);
     $data->addCount('Oranges', 68);
     // put it all together
     $chart = new Chart();
     $chart->addOptions($options);
     $chart->addOptions($titleOptions);
     $chart->addOptions($extOptions);
     $chart->setData($data);
     $chart->setRenderer(new Pie());
     // test the full expected output
     $this->assertSame('var chart_example_59; chart_example_59 = new Highcharts.Chart({"chart":{"renderTo":"chart_example_59","marginRight":130,"marginBottom":25},"title":{"text":"Monthly Details","x":-20},"series":[{"type":"pie","data":[{"name":"Apples","y":32,"color":"#629632"},{"name":"Oranges","y":68,"color":"#CD3700"}]}]});', $chart->render());
     $this->assertSame('<div id="chart_example_59"></div>', $chart->renderContainer());
 }
Exemple #3
0
 /**
  * The options to use when rendering this chart
  * @param  Container|ExtendedContainer $options stocked instance of chart options
  * @return Chart                       $this Current instance
  * @throws \InvalidArgumentException   if wrong instance type passed in
  */
 public function addOptions($options)
 {
     if ($options instanceof Container) {
         $this->_options[$options->getOptionsType()] = $options;
     } elseif ($options instanceof ExtendedContainer) {
         $this->_extendedOptions = $options;
     } elseif (is_array($options)) {
         foreach ($options as $option) {
             $this->addOptions($option);
         }
     } else {
         throw new \InvalidArgumentException("Options must be instance of Container or ExtendedContainer", 1);
     }
     return $this;
 }
 /**
  * @expectedException InvalidArgumentException
  */
 public function testSetInvalidStickyColourKey()
 {
     $options = new ExtendedContainer();
     $options->setStickyColour(array('foo' => 'bar'), '#629632');
 }
<?php

require_once '/home/sites/phighcharts/poc/UniversalClassLoader.php';
use Symfony\Component\ClassLoader\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->register();
$loader->registerNamespaces(array('Phighchart' => __DIR__ . '/../classes'));
use Phighchart\Chart;
use Phighchart\Options\Container as OptionsContainer;
use Phighchart\Options\ExtendedContainer as ExtendedOptionsContainer;
use Phighchart\Data;
use Phighchart\Renderer\Pie;
use Phighchart\Renderer\Line;
$extOptions = new ExtendedOptionsContainer();
$extOptions->setStickyColour('apples', '#629632');
$extOptions->setStickyColour('oranges', '#CD3700');
$options = new OptionsContainer('chart');
$options->setRenderTo('chart_example_59');
$options->setMarginRight(130);
$options->setMarginBottom(25);
$titleOptions = new OptionsContainer('title');
$titleOptions->setText('Monthly Details');
$titleOptions->setX(-20);
$data = new Data();
$data->addCount('Apples', 32)->addCount('Oranges', 68)->addSeries('Apples', array('2012-05-01' => 12, '2012-05-02' => 3, '2012-05-03' => 33))->addSeries('Oranges', array('2012-05-01' => 32, '2012-05-02' => 36, '2012-05-03' => 18));
// put it all together
$chart = new Chart();
$chart->addOptions($options)->addOptions($titleOptions)->addOptions($extOptions)->setData($data)->setRenderer(new Pie());
// a line chart is similiar, and our data container holds series data for this
$lineChart = clone $chart;
$options = new OptionsContainer('chart');