function onNewNetworkValue($newValue) { $this->networkSums[] = $newValue[0] + $newValue[1]; $this->networkStats[] = $newValue; if (count($this->networkSums) > 10) { array_shift($this->networkSums); array_shift($this->networkStats); $bars = array_shift($this->bars); $this->barsFrame->removeComponent($bars[2]); } else { $frame = new Frame(); $frame->setSizeX(($this->sizeX - 2) / 10); $sentBar = new Quad(); $sentBar->setSizeX(($this->sizeX - 2) / 10); $sentBar->setBgcolor('a00'); $sentBar->setValign('bottom'); $frame->addComponent($sentBar); $receivedBar = new Quad(); $receivedBar->setSizeX(($this->sizeX - 2) / 10); $receivedBar->setBgcolor('0a0'); $receivedBar->setValign('bottom'); $frame->addComponent($receivedBar); $bars = array($sentBar, $receivedBar, $frame); } $this->barsFrame->addComponent($bars[2]); $this->bars[] = $bars; $heightFactor = ($this->sizeY - 6) / max(51200, 1.2 * max($this->networkSums)); foreach ($this->bars as $i => $bars) { $bars[0]->setSizeY($this->networkStats[$i][1] * $heightFactor); $bars[1]->setSizeY($this->networkStats[$i][0] * $heightFactor); $bars[1]->setPosY($bars[0]->getRealSizeY()); } $i = 1; $step = max(51200, 1.2 * max($this->networkSums)) / 4096; foreach ($this->lines as $line) { $line[1]->setText('$fff' . round($i++ * $step) . ' kb/s'); } $this->redraw(); }