/** * @dataProvider twoAxisDataProvider **/ public function testTwoAxis($firstAxisData, $secondtAxisData, $result) { foreach ($result as $chartClass => $expectedString) { $views = GoogleChartDataSet::create()->setData($firstAxisData); $clicks = GoogleChartDataSet::create()->setData($secondtAxisData); $chart = new $chartClass(); if ($chart->getData()->isNormalized()) { if ($views->getMax() >= 10) { $base = pow(10, floor(log10($views->getMax()))); } else { $base = 0.1; } $views->setBase($base); if ($clicks->getMax() >= 10) { $base = pow(10, floor(log10($clicks->getMax()))); } else { $base = 0.1; } $clicks->setBase($base); } $viewAxis = GoogleChartAxis::create(new GoogleChartAxisType(GoogleChartAxisType::Y))->setRange($views->getMinMax()); $clickAxis = GoogleChartAxis::create(new GoogleChartAxisType(GoogleChartAxisType::R))->setRange($clicks->getMinMax()); if ($chart->getData()->isNormalized()) { $viewAxis->setInterval($views->getBase()); $clickAxis->setInterval($clicks->getBase()); } $chart->setSize(GoogleChartSize::create()->setWidth(300)->setHeight(300))->addAxis($viewAxis)->addLine(GoogleChartLine::create()->setTitle('Показы')->setColor(Color::create('336699'))->setValue($views))->addAxis($clickAxis)->addLine(GoogleChartLine::create()->setTitle('Клики')->setColor(Color::create('339911'))->setValue($clicks)); $this->assertEquals($expectedString, $chart->toString()); } }
public function __construct() { parent::__construct(); $this->type = new GoogleChartType(GoogleChartType::TWO_DIMENSIONAL_PIE); $this->color = GoogleChartColor::create(); $this->label = GoogleChartLabel::create(); $this->data = GoogleChartData::create()->addDataSet(GoogleChartDataSet::create())->setEncoding(GoogleChartDataTextEncoding::create()); }
public function encode(GoogleChartDataSet $set) { return implode($this->delimiter, $set->getData()); }