@@ -101,24 +101,24 @@ def add_value(self, value):
101
101
# pylint: disable=no-else-return
102
102
@staticmethod
103
103
def _xintercept (
104
- x1 , y1 , x2 , y2 , horizontal_y
104
+ x_1 , y_1 , x_2 , y_2 , horizontal_y
105
105
): # finds intercept of the line and a horizontal line at horizontalY
106
- slope = (y2 - y1 ) / (x2 - x1 )
107
- b = y1 - slope * x1
106
+ slope = (y_2 - y_1 ) / (x_2 - x_1 )
107
+ b = y_1 - slope * x_1
108
108
109
- if slope == 0 and y1 != horizontal_y : # does not intercept horizontalY
109
+ if slope == 0 and y_1 != horizontal_y : # does not intercept horizontalY
110
110
return None
111
111
else :
112
112
xint = (
113
113
horizontal_y - b
114
114
) / slope # calculate the x-intercept at position y=horizontalY
115
115
return int (xint )
116
116
117
- def _plotLine (self , x1 , last_value , x2 , value , y_bottom , y_top ):
117
+ def _plotline (self , x_1 , last_value , x_2 , value , y_bottom , y_top ):
118
118
119
- y2 = int (self .height * (y_top - value ) / (y_top - y_bottom ))
120
- y1 = int (self .height * (y_top - last_value ) / (y_top - y_bottom ))
121
- self .append (Line (x1 , y1 , x2 , y2 , self .color )) # plot the line
119
+ y_2 = int (self .height * (y_top - value ) / (y_top - y_bottom ))
120
+ y_1 = int (self .height * (y_top - last_value ) / (y_top - y_bottom ))
121
+ self .append (Line (x_1 , y_1 , x_2 , y_2 , self .color )) # plot the line
122
122
123
123
# pylint: disable=invalid-name, too-many-branches, too-many-nested-blocks
124
124
@@ -150,16 +150,14 @@ def update(self):
150
150
if count == 0 :
151
151
pass # don't draw anything for a first point
152
152
else :
153
- x2 = int (xpitch * count )
154
- x1 = int (xpitch * (count - 1 ))
155
-
156
- # print("x1: {}, x2: {}".format(x1,x2))
153
+ x_2 = int (xpitch * count )
154
+ x_1 = int (xpitch * (count - 1 ))
157
155
158
156
if (self .y_bottom <= last_value <= self .y_top ) and (
159
157
self .y_bottom <= value <= self .y_top
160
158
): # both points are in range, plot the line
161
- self ._plotLine (
162
- x1 , last_value , x2 , value , self .y_bottom , self .y_top
159
+ self ._plotline (
160
+ x_1 , last_value , x_2 , value , self .y_bottom , self .y_top
163
161
)
164
162
165
163
else : # at least one point is out of range, clip one or both ends the line
@@ -170,10 +168,10 @@ def update(self):
170
168
pass
171
169
else :
172
170
xint_bottom = self ._xintercept (
173
- x1 , last_value , x2 , value , self .y_bottom
171
+ x_1 , last_value , x_2 , value , self .y_bottom
174
172
) # get possible new x intercept points
175
173
xint_top = self ._xintercept (
176
- x1 , last_value , x2 , value , self .y_top
174
+ x_1 , last_value , x_2 , value , self .y_top
177
175
) # on the top and bottom of range
178
176
179
177
if (xint_bottom is None ) or (
@@ -182,30 +180,30 @@ def update(self):
182
180
pass
183
181
else :
184
182
# Initialize the adjusted values as the baseline
185
- adj_x1 = x1
183
+ adj_x_1 = x_1
186
184
adj_last_value = last_value
187
- adj_x2 = x2
185
+ adj_x_2 = x_2
188
186
adj_value = value
189
187
190
188
if value > last_value : # slope is positive
191
- if xint_bottom >= x1 : # bottom is clipped
192
- adj_x1 = xint_bottom
193
- adj_last_value = self .y_bottom # y1
194
- if xint_top <= x2 : # top is clipped
195
- adj_x2 = xint_top
196
- adj_value = self .y_top # y2
189
+ if xint_bottom >= x_1 : # bottom is clipped
190
+ adj_x_1 = xint_bottom
191
+ adj_last_value = self .y_bottom # y_1
192
+ if xint_top <= x_2 : # top is clipped
193
+ adj_x_2 = xint_top
194
+ adj_value = self .y_top # y_2
197
195
else : # slope is negative
198
- if xint_top >= x1 : # top is clipped
199
- adj_x1 = xint_top
200
- adj_last_value = self .y_top # y1
201
- if xint_bottom <= x2 : # bottom is clipped
202
- adj_x2 = xint_bottom
203
- adj_value = self .y_bottom # y2
204
-
205
- self ._plotLine (
206
- adj_x1 ,
196
+ if xint_top >= x_1 : # top is clipped
197
+ adj_x_1 = xint_top
198
+ adj_last_value = self .y_top # y_1
199
+ if xint_bottom <= x_2 : # bottom is clipped
200
+ adj_x_2 = xint_bottom
201
+ adj_value = self .y_bottom # y_2
202
+
203
+ self ._plotline (
204
+ adj_x_1 ,
207
205
adj_last_value ,
208
- adj_x2 ,
206
+ adj_x_2 ,
209
207
adj_value ,
210
208
self .y_bottom ,
211
209
self .y_top ,
0 commit comments