Allow choosing chart skew at runtime
This commit is contained in:
parent
933d11ebc7
commit
77fe922d90
1 changed files with 5 additions and 4 deletions
|
@ -32,11 +32,12 @@ def clamp(value, lowest, highest):
|
|||
return value
|
||||
|
||||
class SkewTGraph():
|
||||
__slots__ = 'width', 'height', 'temp_step_width',
|
||||
__slots__ = 'width', 'height', 'skew', 'temp_step_width',
|
||||
|
||||
def __init__(self, width: float, height: float):
|
||||
def __init__(self, width: float, height: float, skew: float=SKEW):
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.skew = skew
|
||||
|
||||
self.temp_step_width = min(self.width, self.height) / TEMP_STEP_COUNT
|
||||
|
||||
|
@ -74,7 +75,7 @@ class SkewTGraph():
|
|||
cr.restore()
|
||||
|
||||
def skew_t_to_graph(self, x: float, y: float):
|
||||
return (x+SKEW*y, y)
|
||||
return (x+self.skew*y, y)
|
||||
|
||||
def sample_to_graph(self, temp: float, pressure: float):
|
||||
x = (temp / TEMP_STEP) * self.temp_step_width
|
||||
|
@ -241,7 +242,7 @@ class SkewTLegend():
|
|||
x_rel, y_rel = skew_t.sample_to_screen(temp, PRESSURE_MAX)
|
||||
|
||||
if x_rel < 0:
|
||||
y_rel = skew_t.height + x_rel / SKEW
|
||||
y_rel = skew_t.height + x_rel / skew_t.skew
|
||||
x_rel = 0
|
||||
|
||||
if y_rel <= 0:
|
||||
|
|
Loading…
Add table
Reference in a new issue