public function testGetData() { $chart = new Chart(); $data = new Data(); $chart->setData($data); $this->assertInstanceOf('Phighchart\\Data', $chart->getData()); }
/** * Tests the xAxis format options for the linear type */ public function testFormatOptions() { $data = new Data(); $data->addSeries('Test', array('01-08-2012' => 18, '02-08-2012' => 4, '03-08-2012' => 12)); $chart = new Chart(); $chart->setData($data); $chart->setRenderer(new Area()); $linear = new Linear(); $formatOptions = $linear->getFormatOptions($chart); $this->assertInstanceOf('Phighchart\\Options\\Container', $formatOptions); $expected = new \StdClass(); //for linear format the xAxis labels are set as categories $expected->categories = array('01-08-2012', '02-08-2012', '03-08-2012'); $this->assertEquals($expected, $formatOptions->getOptions()); $this->assertSame('xAxis', $formatOptions->getOptionsType()); }
public function testRenderWithNoData() { $options = new OptionsContainer('chart'); $options->setRenderTo('chart_example_59'); $options->setMarginRight(130); $options->setMarginBottom(25); $data = new Data(); // put it all together $chart = new Chart(); $chart->addOptions($options); $chart->setData($data); $chart->setRenderer(new Pie()); // test the full expected output $this->assertSame('', $chart->render()); $this->assertSame('<div id="chart_example_59"></div>', $chart->renderContainer()); }
public function testAreaRenderWithCustomDateTimeFormat() { $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('1st May, 2012 00:00:00' => 12, '2nd May, 2012 00:00:00' => 3, '3rd May, 2012 00:00:00' => 33))->addSeries('Oranges', array('1st May, 2012 00:00:00' => 32, '2nd May, 2012 00:00:00' => 36, '3rd May, 2012 00:00:00' => 18)); $format = new DatetimeFormat(); $format->setDateTimeFormat('jS F, Y H:i:s'); // put it all together $chart = new Chart(); $chart->addOptions($options); $chart->addOptions($titleOptions); $chart->setData($data); $chart->setFormat($format); $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":{"type":"datetime"},"series":[{"name":"Apples","data":[[Date.UTC(2012,4,01,00,00,00),12],[Date.UTC(2012,4,02,00,00,00),3],[Date.UTC(2012,4,03,00,00,00),33]]},{"name":"Oranges","data":[[Date.UTC(2012,4,01,00,00,00),32],[Date.UTC(2012,4,02,00,00,00),36],[Date.UTC(2012,4,03,00,00,00),18]]}]});', $chart->render()); $this->assertSame('<div id="chart_example_59"></div>', $chart->renderContainer()); }