Skip to content

Commit b15657a

Browse files
author
Margaret Matocha
committed
Updating off-by-one error
1 parent 13b9ebc commit b15657a

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

examples/display_shapes_sparkline_ticks.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
max_items=40,
110110
y_min=0,
111111
y_max=10,
112-
x=40,
113-
y=30,
112+
x=20,
113+
y=20,
114114
color=line_color,
115115
)
116116

@@ -137,7 +137,7 @@
137137

138138

139139
bounding_rectangle = Rect(
140-
sparkline1.x, sparkline1.y, chart_width + 1, chart_height + 1, outline=line_color
140+
sparkline1.x, sparkline1.y, chart_width, chart_height, outline=line_color
141141
)
142142

143143

@@ -157,20 +157,15 @@
157157

158158
total_ticks = 10
159159

160-
for i in range(total_ticks + 1):
160+
for i in range(total_ticks+1):
161161
x_start = sparkline1.x - 5
162162
x_end = sparkline1.x
163-
y_both = sparkline1.y + i * int(round(chart_height / (total_ticks)))
163+
y_both = int(round(sparkline1.y + (i * (chart_height) / (total_ticks))))
164+
if y_both > sparkline1.y+chart_height-1:
165+
y_both = sparkline1.y+chart_height-1
166+
print('y_both: {}, i: {}'.format(y_both, i))
164167
my_group.append(Line(x_start, y_both, x_end, y_both, color=line_color))
165-
my_group.append(
166-
Line(
167-
x_start,
168-
sparkline1.y + chart_height,
169-
x_end,
170-
sparkline1.y + chart_height,
171-
color=line_color,
172-
)
173-
)
168+
174169

175170
# Set the display to show my_group that contains the sparkline and other graphics
176171
display.show(my_group)

0 commit comments

Comments
 (0)