Ad Widget

Collapse

Chart time-coordinate translation in graph.inc.php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jshuler
    Junior Member
    • Jul 2007
    • 8

    #1

    Chart time-coordinate translation in graph.inc.php

    Hi!

    I'm working on integrating some MySQL monitoring into Zabbix which involves selecting a range of time.

    I need to be able to get the time a user is pointing to. That is, given an x-position on the generated image, I need the specific time represented.

    See the attached chart. I need to be able to programmatically determine the start time and end time of the range between the two vertical red bars.


    Does the graph class already contain such a function?

    If it does not, all I really need is a way to determine the exact x-value of the beginning and end of the graph, as well as the time for the beginning and end.


    graph.inc.php does not appear to be commented much, so I'm finding it rather difficult to find what I'm looking for (especially when I'm not exactly sure what I'm looking for...)


    Thanks for your help!!
    Attached Files
  • jshuler
    Junior Member
    • Jul 2007
    • 8

    #2
    I still cannot find the code for it, but it looks like the margin is 10px on the left side, and 62px on the right side. This remained the same as I changed the size of the graph.

    However, I then noticed that sometimes the graph does not touch the edge - so there is a little gap.

    I could still use some guidance from somebody who knows the code... please...


    Thanks!

    Comment

    • jshuler
      Junior Member
      • Jul 2007
      • 8

      #3
      I still have not been able to figure this out.

      If I am not using the appropriate method of requesting assistance, please let me know how I should proceed.

      Any help is greatly appreciated!

      Thanks!

      Comment

      • Aly
        ZABBIX developer
        • May 2007
        • 1126

        #4
        if there is left Y-axis then shiftxleft = 60px, shiftxright = 20px
        else if there is right Y-axis then shiftxleft = 10px, shiftxright = 60px
        else if there is right and left Y-axis then shiftxleft = 60px, shiftxright = 60px

        Image fullsizeX = graphsize + shiftxleft + shiftxright +1;

        Follow method draw()
        Zabbix | ex GUI developer

        Comment

        • jshuler
          Junior Member
          • Jul 2007
          • 8

          #5
          Thanks for the reply!

          I ended up measuring the margins with mspaint, and assuming the graph completely fills the inner box.

          I do something like this to charts.php (javascript pseudocode):

          Code:
          // startTime, endTime are calculated and passed in from 'from' and 'period'
          // variables in charts.php
          // 
          
          timePeriod = endTime - startTime;
          imageLeft = graphImg.left + 10;
          imageRight = graphImg.right - 62;
          boxLeft = selectionBox.style.left;
          boxRight = selectionBox.style.left + selectionBox.style.width;
          
          imageWidth = imageRight - imageLeft;
          
          rangeStart = (((imageLeft - boxLeft) / imageWidth) * timePeriod) + startTime;
          rangeEnd = (((imageLeft - boxRight) / imageWidth) * timePeriod) + startTime;
          rangeStart and rangeEnd are unix timestamps that I use to call the ajax-style detail infomation.


          Thanks again for your help!

          Comment

          Working...