Commit 7f7ce6b508c68e31777919c878e59ed43e7f01b0

Authored by Christopher Stone
1 parent 2cb884e3
Exists in master

Fixed bug in axis-labelling code, lower limits were being calculated incorrectly

Showing 1 changed file with 4 additions and 5 deletions   Show diff stats
telemetry/code/monitor/graph_plotter.py
... ... @@ -34,12 +34,12 @@ def drawgrid(xlines, ylines, xlimits, ylimits):
34 34 pyglet.gl.glColor4f(0.5, 0.5, 0.5, 1.0)
35 35 for xpos in range(0, window.width, window.width/xlines):
36 36 pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (xpos, 0, xpos, window.height)))
37   - tagtext = str(round((xlimits[1]-xlimits[0])*(float(xpos)/window.width), 1))
  37 + tagtext = str(round((xlimits[1]-xlimits[0])*(float(xpos)/window.width) + xlimits[0], 1))
38 38 tag = pyglet.text.Label(tagtext, font_name='Arkhip', font_size=10, x=xpos-2, y=0, anchor_x='right', anchor_y='bottom')
39 39 tag.draw()
40   - for ypos in range(0, window.width, window.width/ylines):
  40 + for ypos in range(0, window.width, window.height/ylines):
41 41 pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (0, ypos, window.width, ypos)))
42   - tagtext = str(round((ylimits[1]-ylimits[0])*(float(ypos)/window.height), 1))
  42 + tagtext = str(round((ylimits[1]-ylimits[0])*(float(ypos)/window.height) + ylimits[0], 1))
43 43 tag = pyglet.text.Label(tagtext, font_name='Arkhip', font_size=10, x=0, y=ypos-2, anchor_x='left', anchor_y='top')
44 44 tag.draw()
45 45  
... ... @@ -70,7 +70,6 @@ ydata = [0]
70 70 @window.event
71 71 def on_draw():
72 72 window.clear()
73   - #ydata.append(random.uniform(0, 10))
74 73 value = datafeed.readline()
75 74 try:
76 75 value = float(value)
... ... @@ -83,7 +82,7 @@ def on_draw():
83 82 del xdata[0]
84 83 except:
85 84 pass
86   - drawgrid(10, 12, [min(xdata), max(xdata)], [min(ydata), max(ydata)])
  85 + drawgrid(10, 10, [min(xdata), max(xdata)], [min(ydata), max(ydata)])
87 86 plotline(xdata, ydata)
88 87  
89 88  
... ...