Ad Widget

Collapse

Graph: last vertical line not always drawn

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pauldube
    Junior Member
    • Jun 2019
    • 9

    #1

    Graph: last vertical line not always drawn

    I've been using Zabbix since v2. I just upgraded to V4.2 to find out this bug is still there (even though Zabbix will probably not consider it as a bug).

    The last vertical line is not always drawn on a graph if there is no space for the label on the axis. Even though there is no space for the label, the vertical line should still be drawn.
    Check my attached screen shot: I expect a line to be drawn for 10:43:40. Since there is no space for the label it's OK not the write the label, but I see no valid reason for the line not to be drawn.
    Attached Files
  • pauldube
    Junior Member
    • Jun 2019
    • 9

    #2
    I fixed it myself.
    I updated file include/classes/graphdraw/CLineGraphDraw,php. I did not test it with all possible graphs but I think it's pretty safe. See attached image.
    Here is my diff, from version 4.2.3 (you can use it Zabbix...):

    1243a1244
    > * @param bool $drawLabel Should we draw the period label? If false, we only draw the vertical line.
    1245c1246
    < private function drawMainPeriod($value, $position) {
    ---
    > private function drawMainPeriod($value, $position, $drawLabel) {
    1248,1256c1249,1259
    < imageText(
    < $this->im,
    < 8,
    < 90,
    < $this->shiftXleft + $position + round($dims['width'] / 2),
    < $this->sizeY + $this->shiftY + $dims['height'] + 6,
    < $this->getColor($this->graphtheme['highlightcolor'], 0),
    < $value
    < );
    ---
    > if ($drawLabel) {
    > imageText(
    > $this->im,
    > 8,
    > 90,
    > $this->shiftXleft + $position + round($dims['width'] / 2),
    > $this->sizeY + $this->shiftY + $dims['height'] + 6,
    > $this->getColor($this->graphtheme['highlightcolor'], 0),
    > $value
    > );
    > }
    1272c1275
    < * @param strimg $value Readable timestamp.
    ---
    > * @param string $value Readable timestamp.
    1273a1277
    > * @param bool $drawLabel Should we draw the period label? If false, we only draw the vertical line.
    1275c1279
    < private function drawSubPeriod($value, $position) {
    ---
    > private function drawSubPeriod($value, $position, $drawLabel) {
    1278,1286c1282,1292
    < imageText(
    < $this->im,
    < 7,
    < 90,
    < $this->shiftXleft + $position + round($element['width'] / 2),
    < $this->sizeY + $this->shiftY + $element['height'] + 6,
    < $this->getColor($this->graphtheme['textcolor'], 0),
    < $value
    < );
    ---
    > if ($drawLabel) {
    > imageText(
    > $this->im,
    > 7,
    > 90,
    > $this->shiftXleft + $position + round($element['width'] / 2),
    > $this->sizeY + $this->shiftY + $element['height'] + 6,
    > $this->getColor($this->graphtheme['textcolor'], 0),
    > $value
    > );
    > }
    1477a1484,1490
    > // Did we reach the end of graph yet?
    > if ($position > $this->sizeX) {
    > break;
    > }
    >
    > $drawLabel = true;
    >
    1479,1483c1492,1494
    < if ($prev_time != $this->stime || $delta_x > $element_size['width']) {
    < // Last element overlaping check.
    < if ($position > $this->sizeX - $element_size['width']) {
    < break;
    < }
    ---
    > if ($prev_time == $this->stime && $delta_x <= $element_size['width']) {
    > $drawLabel = false;
    > }
    1485,1490c1496,1505
    < if ($draw_main) {
    < $this->drawMainPeriod($dt['sub']->format($format['main']), $position);
    < }
    < else {
    < $this->drawSubPeriod($dt['sub']->format($format['sub']), $position);
    < }
    ---
    > // Last element overlaping check.
    > if ($position > $this->sizeX - $element_size['width']) {
    > $drawLabel = false;
    > }
    >
    > if ($draw_main) {
    > $this->drawMainPeriod($dt['sub']->format($format['main']), $position, $drawLabel);
    > }
    > else {
    > $this->drawSubPeriod($dt['sub']->format($format['sub']), $position, $drawLabel);

    Attached Files
    Last edited by pauldube; 13-06-2019, 16:59.

    Comment

    • kloczek
      Senior Member
      • Jun 2006
      • 1771

      #3
      Could you please submit this as PR on https://github.com/zabbix/zabbix?
      http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
      https://kloczek.wordpress.com/
      zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
      My zabbix templates https://github.com/kloczek/zabbix-templates

      Comment

      • pauldube
        Junior Member
        • Jun 2019
        • 9

        #4
        GitHub Zabbix says "pull requests are ignored", so I am not sure how it works. Never worked with a public git before. Should I just make the changes on file and publish? If you give quick instructions I'll gladly do it.
        Thank you.

        Comment

        • pauldube
          Junior Member
          • Jun 2019
          • 9

          #5
          What's the purpose of https://github.com/zabbix/zabbix?
          If I post my changes there, will Zabbix eventually use it?

          Comment

          • Hartman141
            Junior Member
            • Jul 2019
            • 1

            #6
            Originally posted by pauldube
            What's the purpose of https://github.com/zabbix/zabbix?
            If I post my changes there, will Zabbix eventually use it?
            You can create your account there and share you doubts or solve others problem if you faced their errors in past. if you mention Zabbix in github post then thay can use your code.

            Regards,
            Hartman
            MyKFCExperience
            Last edited by Hartman141; 10-07-2019, 07:42.

            Comment

            Working...