public function testSetParams() { $params = array('align' => Text::ALIGN_CENTER, 'fontSize' => 12, 'color' => '#ff0000', 'text' => 'foo', 'foo' => 123); $this->label->text()->setParams($params); $this->assertEquals($params['align'], $this->label->text()->getAlign()); $this->assertEquals($params['fontSize'], $this->label->text()->getFontSize()); $this->assertEquals($params['color'], $this->label->text()->getColor()); $this->assertEquals($params['text'], $this->label->text()->getValue()); $values = $this->label->toArray(); $this->assertEquals($params['align'], $values['align']); $this->assertEquals($params['fontSize'], $values['fontSize']); $this->assertEquals($params['color'], $values['color']); $this->assertEquals($params['text'], $values['text']); }
function drawValues($image, Boundary $b) { $out = $this->getValuesArea($b); if ($out->width() < $this->depth || $out->height() < $this->depth || $out->left() > $out->right() || $out->top() > $out->bottom()) { throw new ChartException("Недостаточно места для вывода значений."); } $line = new Line(new Boundary(0, 0, 0, 0), $this->values['bgcolors'][0], $this->values['thickness']); $w = ($out->width() - $this->depth) / count($this->data); $l = new Label(new Boundary(0, 0, 0, 0), '', $this->values['font'], Color::getDefault(), Label::ALIGN_CENTER_MIDDLE); $e = new Ellipse(new Boundary(0, 0, $this->values['thickness'] * 3, $this->values['thickness'] * 3)); for ($i = 0; $i < count($this->data); $i++) { $c = $out->left() + $w * $i + $w / 2.0; $line->bounds()->right($c); $line->bounds()->bottom($out->bottom() - ($this->data[$i] - $this->min) * $out->height() / ($this->max - $this->min)); $line->background($this->values['bgcolors'][$i % count($this->values['bgcolors'])]); if ($i != 0) { $line->draw($image); $e->bounds()->move(new Size($line->bounds()->left() - $this->values['thickness'] * 3 / 2, $line->bounds()->top() - $this->values['thickness'] * 3 / 2)); $e->background($this->values['bgcolors'][($i - 1) % count($this->values['bgcolors'])]); $e->draw($image); } $line->bounds()->left($line->bounds()->right()); $line->bounds()->top($line->bounds()->bottom()); if ($this->values['labels']) { $l->text($this->data[$i]); $l->bounds()->bottom($line->bounds()->top() - 5); $l->bounds()->top($l->bounds()->bottom() - $this->values['font']->getTextExtent()->height); $l->bounds()->left($line->bounds()->left()); $l->bounds()->right($line->bounds()->left()); $l->background($this->values['fgcolors'][$i % count($this->values['fgcolors'])]); $l->draw($image); } } $e->bounds()->move(new Size($line->bounds()->left() - $this->values['thickness'] * 3 / 2, $line->bounds()->top() - $this->values['thickness'] * 3 / 2)); $e->background($line->background()); $e->draw($image); }
function drawValues($image, Boundary $b) { $out = $this->getValuesArea($b); if ($out->width() < $this->depth || $out->height() < $this->depth || $out->left() > $out->right() || $out->top() > $out->bottom()) { throw new ChartException("Недостаточно места для вывода значений."); } $r = new Rectangle3D(new Boundary(0, 0, 0, 0), NULL, Color::getDefault(), NULL, $this->depth); $w = ($out->width() - $this->depth) / count($this->data); $wr = $w / 1.5 - $this->depth; $l = new Label(new Boundary(0, 0, 0, 0), '', $this->values['font'], Color::getDefault(), Label::ALIGN_CENTER_MIDDLE); for ($i = 0; $i < count($this->data); $i++) { $c = $out->left() + $w * $i + $w / 2.0; $r->bounds()->left($c - $wr / 2); $r->bounds()->right($c + $wr / 2); $r->bounds()->top($out->bottom() - ($this->data[$i] - $this->min) * $out->height() / ($this->max - $this->min)); $r->bounds()->bottom($out->bottom() - 1); $r->background($this->values['bgcolors'][$i % count($this->values['bgcolors'])]); $r->draw($image); $l->text($this->data[$i]); if (($h = $this->values['font']->getTextExtent()->height) > $r->bounds()->height()) { $r->bounds()->bottom($r->bounds()->top()); $r->bounds()->top($r->bounds()->bottom() - $h); } if ($this->values['labels']) { $l->bounds($r->bounds()); $l->background($this->values['fgcolors'][$i % count($this->values['fgcolors'])]); $l->draw($image); } } }