3 final class PHUISegmentBarSegmentView
extends AphrontTagView
{
10 public function setWidth($width) {
11 $this->width
= $width;
15 public function getWidth() {
19 public function setColor($color) {
20 $this->color
= $color;
24 public function setPosition($position) {
25 $this->position
= $position;
29 public function setTooltip($tooltip) {
30 $this->tooltip
= $tooltip;
34 protected function canAppendChild() {
38 protected function getTagAttributes() {
40 'phui-segment-bar-segment-view',
44 $classes[] = $this->color
;
47 // Convert width to a percentage, and round it up slightly so that bars
48 // are full if they have, e.g., three segments at 1/3 + 1/3 + 1/3.
49 $width = 100 * $this->width
;
50 $width = ceil(100 * $width) / 100;
51 $width = sprintf('%.2f%%', $width);
53 $left = 100 * $this->position
;
54 $left = floor(100 * $left) / 100;
55 $left = sprintf('%.2f%%', $left);
57 $tooltip = $this->tooltip
;
58 if (strlen($tooltip)) {
59 Javelin
::initBehavior('phabricator-tooltips');
61 $sigil = 'has-tooltip';
72 'class' => implode(' ', $classes),
73 'style' => "left: {$left}; width: {$width};",