Commit 8ad3fe93059fd2897e3c43a2205fda8c9c654e5f

Authored by Christopher Stone
1 parent dc810420
Exists in master

Replaced placeholder axis tags with calculated ones - although better rounding (…

…based on sig. fig., not dp) is needed
Showing 1 changed file with 13 additions and 5 deletions   Show diff stats
telemetry/code/monitor/graph_plotter_rewrite.py
... ... @@ -29,6 +29,8 @@ class Series:
29 29 self.title = title
30 30 self.xname = xname
31 31 self.yname = yname
  32 + self.xlimits = (100, 0)
  33 + self.ylimits = (0, 255)
32 34 self.data = []
33 35 self.points = points
34 36 def addpoint(self, point):
... ... @@ -43,8 +45,8 @@ class Plot(pyglet.window.Window):
43 45 pyglet.window.Window.__init__(self, resizable=True)
44 46 self.series = series
45 47 self.font = 'Arkhip'
46   - self.margins = (0.08, 0.08) # Fractions of window size
47   - self.lines = (12, 8)
  48 + self.margins = (0.1, 0.08) # Fractions of window size
  49 + self.lines = (10, 8)
48 50 #self.resizable = True
49 51 self.set_caption(self.series.title)
50 52  
... ... @@ -85,11 +87,14 @@ class Plot(pyglet.window.Window):
85 87 # Using fp arithmetic to avoid intermittent fencepost errors
86 88 pos = int(pos)
87 89 if axis==0: # x axis, vertical lines
  90 + scale = float(self.series.xlimits[1]-self.series.xlimits[0])/(stop-start)
  91 + tagvalue = ((pos-start) * scale) + self.series.xlimits[0]
  92 + tagtext = str(round(tagvalue, 1))
88 93 pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (pos, limita, pos, limitb)),
89 94 ('c3B', (0, 0, 0, 0, 0, 0)))
90   - tag = pyglet.text.Label("123", color=BLACK,
  95 + tag = pyglet.text.Label(tagtext, color=BLACK,
91 96 font_name=self.font, font_size=self.height*self.margins[1-axis]*0.28,
92   - x=pos, y=self.height*self.margins[axis],
  97 + x=pos, y=self.height*self.margins[1-axis],
93 98 anchor_x='left', anchor_y='top')
94 99 axistitle = pyglet.text.Label(self.series.xname, color=BLACK,
95 100 font_name=self.font, font_size=self.height*self.margins[axis]*0.3,
... ... @@ -97,9 +102,12 @@ class Plot(pyglet.window.Window):
97 102 anchor_x='center', anchor_y='bottom')
98 103 axistitle.draw()
99 104 if axis==1: # y axis, horizontal lines
  105 + scale = float(self.series.ylimits[1]-self.series.ylimits[0])/(stop-start)
  106 + tagvalue = ((pos-start) * scale) + self.series.ylimits[0]
  107 + tagtext = str(round(tagvalue, 1))
100 108 pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (limita, pos, limitb, pos)),
101 109 ('c3B', (0, 0, 0, 0, 0, 0)))
102   - tag = pyglet.text.Label("123", color=BLACK,
  110 + tag = pyglet.text.Label(tagtext, color=BLACK,
103 111 font_name=self.font, font_size=self.width*self.margins[axis]*0.22,
104 112 x=self.width*self.margins[1-axis]*0.9, y=pos,
105 113 anchor_x='right', anchor_y='center')
... ...