1420
private function drawSides() {
1421
if (isset($this->axis_valuetype[GRAPH_YAXIS_SIDE_RIGHT])
1422
&& ($this->yaxisright != 0 || $this->skipRightScale != 1)) {
1423
$sides[] = GRAPH_YAXIS_SIDE_RIGHT;
1426
if (((isset($this->axis_valuetype[GRAPH_YAXIS_SIDE_LEFT]))
1427
&& ($this->yaxisleft != 0 || $this->skipLeftScale != 1)) || !isset($sides)) {
1428
$sides[] = GRAPH_YAXIS_SIDE_LEFT;
1431
foreach ($sides as $side) {
1432
$minY = $this->m_minY[$side];
1433
$maxY = $this->m_maxY[$side];
1438
for ($item = 0; $item < $this->num; $item++) {
1439
if ($this->items[$item]['axisside'] == $side) {
1440
// check if items use B or Bps units
1441
if ($this->items[$item]['units'] == 'B' || $this->items[$item]['units'] == 'Bps') {
1444
if (is_null($units)) {
1445
$units = $this->items[$item]['units'];
1447
elseif ($this->items[$item]['units'] != $units) {
1453
if (is_null($units) || $units === false) {
1457
for ($item = 0; $item < $this->num; $item++) {
1458
if ($this->items[$item]['axisside'] == $side && !empty($this->items[$item]['unitsLong'])) {
1459
$unitsLong = $this->items[$item]['unitsLong'];
1465
if (!empty($unitsLong)) {
1466
$dims = imageTextSize(9, 90, $unitsLong);
1468
$tmpY = $this->sizeY / 2 + $this->shiftY + $dims['height'] / 2;
1469
if ($tmpY < $dims['height']) {
1470
$tmpY = $dims['height'] + 6;
1473
$tmpX = $side == GRAPH_YAXIS_SIDE_LEFT ? $dims['width'] + 8 : $this->fullSizeX - $dims['width'];
1481
$this->getColor($this->graphtheme['textcolor'], 0),
1486
$step = $this->gridStep[$side];
1487
$hstr_count = $this->gridLinesCount[$side];
1489
// ignore milliseconds if -1 <= maxY => 1 or -1 <= minY => 1
1490
$ignoreMillisec = (bccomp($maxY, -1) <= 0 || bccomp($maxY, 1) >= 0
1491
|| bccomp($minY, -1) <= 0 || bccomp($minY, 1) >= 0);
1495
$maxYPow = convertToBase1024($maxY, 1024);
1496
$minYPow = convertToBase1024($minY, 1024);
1499
$maxYPow = convertToBase1024($maxY);
1500
$minYPow = convertToBase1024($minY);
1504
if (abs($maxYPow['pow']) > abs($minYPow['pow']) && $maxYPow['value'] != 0) {
1505
$newPow = $maxYPow['pow'];
1506
if (abs(bcdiv($minYPow['value'], bcpow($powStep, $maxYPow['pow']))) > 1000) {
1507
$newPow = $minYPow['pow'];
1510
if (abs($maxYPow['pow']) < abs($minYPow['pow']) && $minYPow['value'] != 0) {
1511
$newPow = $minYPow['pow'];
1512
if (abs(bcdiv($maxYPow['value'], bcpow($powStep, $minYPow['pow']))) > 1000) {
1513
$newPow = $maxYPow['pow'];
1516
if ($maxYPow['pow'] == $minYPow['pow']) {
1517
$newPow = $maxYPow['pow'];
1521
// get all values in y-axis if units != 's'
1522
if ($units != 's') {
1523
$calcValues = array();
1524
for ($i = 0; $i <= $hstr_count; $i++) {
1525
$hstr_count = ($hstr_count == 0) ? 1 : $hstr_count;
1527
$val = bcadd(bcmul($i, $step), $minY);
1529
if (bccomp(bcadd($val, bcdiv($step,2)), $maxY) == 1) {
1533
$calcValues[] = convert_units(array(
1535
'convert' => ITEM_CONVERT_NO_UNITS,
1536
'byteStep' => $byteStep,
1541
$calcValues[] = convert_units(array(
1543
'convert' => ITEM_CONVERT_NO_UNITS,
1544
'byteStep' => $byteStep,
1548
$maxLength = calcMaxLengthAfterDot($calcValues);
1551
for ($i = 0; $i <= $hstr_count; $i++) {
1552
$hstr_count = ($hstr_count == 0) ? 1 : $hstr_count;
1554
$val = bcadd(bcmul($i, $step), $minY);
1556
if (bccomp(bcadd($val, bcdiv($step, 2)), $maxY) == 1) {
1560
$str = convert_units(array(
1563
'convert' => ITEM_CONVERT_NO_UNITS,
1564
'byteStep' => $byteStep,
1566
'ignoreMillisec' => $ignoreMillisec,
1567
'length' => $maxLength
1570
if ($side == GRAPH_YAXIS_SIDE_LEFT) {
1571
$dims = imageTextSize(8, 0, $str);
1572
$posX = $this->shiftXleft - $dims['width'] - 9;
1575
$posX = $this->sizeX + $this->shiftXleft + 12;
1578
// marker Y coordinate
1579
$posY = $this->sizeY + $this->shiftY - $this->gridStepX[$side] * $i + 4;
1587
$this->getColor($this->graphtheme['textcolor'], 0),
1592
$str = convert_units(array(
1595
'convert' => ITEM_CONVERT_NO_UNITS,
1596
'byteStep' => $byteStep,
1598
'ignoreMillisec' => $ignoreMillisec,
1599
'length' => $maxLength
1602
if ($side == GRAPH_YAXIS_SIDE_LEFT) {
1603
$dims = imageTextSize(8, 0, $str);
1604
$posX = $this->shiftXleft - $dims['width'] - 9;
1605
$color = $this->getColor(GRAPH_ZERO_LINE_COLOR_LEFT);
1608
$posX = $this->sizeX + $this->shiftXleft + 12;
1609
$color = $this->getColor(GRAPH_ZERO_LINE_COLOR_RIGHT);
1618
$this->getColor($this->graphtheme['textcolor'], 0),
1622
if ($this->zero[$side] != $this->sizeY + $this->shiftY && $this->zero[$side] != $this->shiftY) {
1627
$this->shiftXleft + $this->sizeX,
1420
private function drawLeftSide() {
1421
if ($this->yaxisleft == 0 || $this->skipLeftScale == 1) {
1425
$minY = $this->m_minY[GRAPH_YAXIS_SIDE_LEFT];
1426
$maxY = $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT];
1431
for ($item = 0; $item < $this->num; $item++) {
1432
if ($this->items[$item]['axisside'] == GRAPH_YAXIS_SIDE_LEFT) {
1433
// check if items use B or Bps units
1434
if ($this->items[$item]['units'] == 'B' || $this->items[$item]['units'] == 'Bps') {
1437
if (is_null($units)) {
1438
$units = $this->items[$item]['units'];
1440
elseif ($this->items[$item]['units'] != $units) {
1446
if (is_null($units) || $units === false) {
1450
for ($item = 0; $item < $this->num; $item++) {
1451
if ($this->items[$item]['axisside'] == GRAPH_YAXIS_SIDE_LEFT && !empty($this->items[$item]['unitsLong'])) {
1452
$unitsLong = $this->items[$item]['unitsLong'];
1458
if (!empty($unitsLong)) {
1459
$dims = imageTextSize(9, 90, $unitsLong);
1461
$tmpY = $this->sizeY / 2 + $this->shiftY+$dims['height'] / 2;
1462
if ($tmpY < $dims['height']) {
1463
$tmpY = $dims['height'] + 6;
1472
$this->getColor($this->graphtheme['textcolor'], 0),
1477
$step = $this->gridStep[GRAPH_YAXIS_SIDE_LEFT];
1478
$hstr_count = $this->gridLinesCount[GRAPH_YAXIS_SIDE_LEFT];
1480
// ignore milliseconds if -1 <= maxY => 1 or -1 <= minY => 1
1481
$ignoreMillisec = (bccomp($maxY, -1) <= 0 || bccomp($maxY, 1) >= 0
1482
|| bccomp($minY, -1) <= 0 || bccomp($minY, 1) >= 0);
1486
$maxYPow = convertToBase1024($maxY, 1024);
1487
$minYPow = convertToBase1024($minY, 1024);
1490
$maxYPow = convertToBase1024($maxY);
1491
$minYPow = convertToBase1024($minY);
1495
if (abs($maxYPow['pow']) > abs($minYPow['pow']) && $maxYPow['value'] != 0) {
1496
$newPow = $maxYPow['pow'];
1497
if (abs(bcdiv($minYPow['value'], bcpow($powStep, $maxYPow['pow']))) > 1000) {
1498
$newPow = $minYPow['pow'];
1501
if (abs($maxYPow['pow']) < abs($minYPow['pow']) && $minYPow['value'] != 0) {
1502
$newPow = $minYPow['pow'];
1503
if (abs(bcdiv($maxYPow['value'], bcpow($powStep, $minYPow['pow']))) > 1000) {
1504
$newPow = $maxYPow['pow'];
1507
if ($maxYPow['pow'] == $minYPow['pow']) {
1508
$newPow = $maxYPow['pow'];
1511
for ($i = 0; $i <= $hstr_count; $i++) {
1513
$hstr_count = ($hstr_count == 0) ? 1 : $hstr_count;
1515
// using bc library, incase of large numbers
1516
$val = bcadd(bcmul($i, $step), $minY);
1518
if (bccomp(bcadd($val, bcdiv($step,2)), $maxY) == 1) {
1522
$str = convert_units($val, $units, ITEM_CONVERT_NO_UNITS, $byteStep, $newPow, $ignoreMillisec);
1524
$dims = imageTextSize(8, 0, $str);
1526
// marker Y coordinate
1527
$posY = $this->sizeY + $this->shiftY - $this->gridStepX[GRAPH_YAXIS_SIDE_LEFT] * $i + 4;
1533
$this->shiftXleft - $dims['width'] - 9,
1535
$this->getColor($this->graphtheme['textcolor'], 0),
1540
$str = convert_units($maxY, $units, ITEM_CONVERT_NO_UNITS, $byteStep, $newPow, $ignoreMillisec);
1542
$dims = imageTextSize(8, 0, $str);
1547
$this->shiftXleft - $dims['width'] - 9,
1549
$this->getColor($this->graphtheme['textcolor'], 0),
1553
if ($this->zero[GRAPH_YAXIS_SIDE_LEFT] != ($this->sizeY + $this->shiftY) && $this->zero[GRAPH_YAXIS_SIDE_LEFT] != $this->shiftY) {
1557
$this->zero[GRAPH_YAXIS_SIDE_LEFT],
1558
$this->shiftXleft + $this->sizeX,
1559
$this->zero[GRAPH_YAXIS_SIDE_LEFT],
1560
$this->getColor(GRAPH_ZERO_LINE_COLOR_LEFT)
1565
private function drawRightSide() {
1566
if ($this->yaxisright == 0 || $this->skipRightScale == 1) {
1570
$minY = $this->m_minY[GRAPH_YAXIS_SIDE_RIGHT];
1571
$maxY = $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT];
1576
for ($item = 0; $item < $this->num; $item++) {
1577
if ($this->items[$item]['axisside'] == GRAPH_YAXIS_SIDE_RIGHT) {
1578
// check if items use B or Bps units
1579
if ($this->items[$item]['units'] == 'B' || $this->items[$item]['units'] == 'Bps') {
1582
if (is_null($units)) {
1583
$units = $this->items[$item]['units'];
1585
elseif ($this->items[$item]['units'] != $units) {
1591
if (is_null($units) || $units === false) {
1595
for ($item = 0; $item < $this->num; $item++) {
1596
if ($this->items[$item]['axisside'] == GRAPH_YAXIS_SIDE_RIGHT && !empty($this->items[$item]['unitsLong'])) {
1597
$unitsLong = $this->items[$item]['unitsLong'];
1603
if (!empty($unitsLong)) {
1604
$dims = imageTextSize(9, 90, $unitsLong);
1606
$tmpY = $this->sizeY / 2 + $this->shiftY + $dims['height'] / 2;
1607
if ($tmpY < $dims['height']) {
1608
$tmpY = $dims['height'] + 6;
1615
$this->fullSizeX - $dims['width'],
1617
$this->getColor($this->graphtheme['textcolor'], 0),
1622
$step = $this->gridStep[GRAPH_YAXIS_SIDE_RIGHT];
1623
$hstr_count = $this->gridLinesCount[GRAPH_YAXIS_SIDE_RIGHT];
1625
// ignore milliseconds if -1 <= maxY => 1 or -1 <= minY => 1
1626
$ignoreMillisec = (bccomp($maxY, -1) <= 0 || bccomp($maxY, 1) >= 0
1627
|| bccomp($minY, -1) <= 0 || bccomp($minY, 1) >= 0);
1631
$maxYPow = convertToBase1024($maxY, 1024);
1632
$minYPow = convertToBase1024($minY, 1024);
1635
$maxYPow = convertToBase1024($maxY);
1636
$minYPow = convertToBase1024($minY);
1640
if (abs($maxYPow['pow']) > abs($minYPow['pow']) && $maxYPow['value'] != 0) {
1641
$newPow = $maxYPow['pow'];
1642
if (abs(bcdiv($minYPow['value'], bcpow($powStep, $maxYPow['pow']))) > 1000) {
1643
$newPow = $minYPow['pow'];
1646
if (abs($maxYPow['pow']) < abs($minYPow['pow']) && $minYPow['value'] != 0) {
1647
$newPow = $minYPow['pow'];
1648
if (abs(bcdiv($maxYPow['value'], bcpow($powStep, $minYPow['pow']))) > 1000) {
1649
$newPow = $maxYPow['pow'];
1652
if ($maxYPow['pow'] == $minYPow['pow']) {
1653
$newPow = $maxYPow['pow'];
1656
for ($i = 0; $i <= $hstr_count; $i++) {
1657
if ($hstr_count == 0) {
1661
// using bc module in case of large numbers
1662
$val = bcadd(bcmul($i, $step), $minY);
1664
if (bccomp(bcadd($val, bcdiv($step, 2)), $maxY) == 1) {
1668
$str = convert_units($val, $units, ITEM_CONVERT_NO_UNITS, $byteStep, $newPow, $ignoreMillisec);
1670
// marker Y coordinate
1671
$posY = $this->sizeY + $this->shiftY - $this->gridStepX[GRAPH_YAXIS_SIDE_RIGHT] * $i + 4;
1677
$this->sizeX + $this->shiftXleft + 12,
1679
$this->getColor($this->graphtheme['textcolor'], 0),
1684
$str = convert_units($maxY, $units, ITEM_CONVERT_NO_UNITS, $byteStep, $newPow, $ignoreMillisec);
1689
$this->sizeX + $this->shiftXleft + 12,
1691
$this->getColor($this->graphtheme['textcolor'], 0),
1695
if ($this->zero[GRAPH_YAXIS_SIDE_RIGHT] != $this->sizeY + $this->shiftY
1696
&& $this->zero[GRAPH_YAXIS_SIDE_RIGHT] != $this->shiftY) {
1700
$this->zero[GRAPH_YAXIS_SIDE_RIGHT],
1701
$this->shiftXleft + $this->sizeX,
1702
$this->zero[GRAPH_YAXIS_SIDE_RIGHT],
1703
$this->getColor(GRAPH_ZERO_LINE_COLOR_RIGHT)