public function testFactory() { $dataPoint = DataPoint::factory(null, null); $this->assertInstanceOf('Misd\\Highcharts\\DataPoint\\DataPointInterface', $dataPoint); $this->assertNull($dataPoint->getXValue()); $this->assertNull($dataPoint->getYValue()); $dataPoint = DataPoint::factory(5, 10); $this->assertInstanceOf('Misd\\Highcharts\\DataPoint\\DataPointInterface', $dataPoint); $this->assertSame(5, $dataPoint->getXValue()); $this->assertSame(10, $dataPoint->getYValue()); }
/** * {@inheritdoc} */ public function addData(array $data) { if (null !== $this->xAxis) { $categories = array_keys($this->xAxis->getCategories()); } else { $categories = array(); } foreach ($data as $category => $datum) { $dataPoint = new DataPoint(); if (false !== ($position = array_search($category, $categories))) { $dataPoint->setXValue($position); } $dataPoint->setYValue($datum); $this->addDataPoint($dataPoint); } return $this; }