Skip to content

Commit 0b90425

Browse files
committed
fixing bar
1 parent 8769026 commit 0b90425

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

circuitpython_uplot/bar.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,17 @@ def __init__(
7070
self._projection = projection
7171
self._filled = fill
7272

73+
self._y = [i * plot.scale for i in y]
74+
7375
if max_value is None:
74-
y_max = max(y)
76+
y_max = max(self._y)
7577
else:
7678
y_max = max_value
7779

78-
self._y = [i * plot.scale for i in y]
79-
8080
self._bar_space = int(bar_space / plot.scale)
81+
82+
xstart = int(xstart / plot.scale)
83+
8184
self._graphx = plot.scale * ceil(
8285
abs(plot._newxmax - plot._newxmin) / (len(x) + 4)
8386
)
@@ -120,7 +123,7 @@ def __init__(
120123
xstart + (i * self._graphx) + self._graphx // 2,
121124
plot._newymin,
122125
)
123-
xstart = xstart + self._bar_space
126+
xstart = xstart + self._bar_space // plot.scale
124127
plot._index_colorused = plot._index_colorused + 1
125128
self._color_index = self._color_index + 1
126129
else:
@@ -164,11 +167,11 @@ def __init__(
164167
plot._index_colorused,
165168
)
166169

167-
xstart = xstart + bar_space
170+
xstart = xstart + self._bar_space
168171
plot._index_colorused = plot._index_colorused + 1
169172
plot.show_text(
170173
str(y[i]),
171-
xstart + (i * self._graphx) - bar_space + self._graphx // 2,
174+
xstart + (i * self._graphx) - self._bar_space + self._graphx // 2,
172175
plot._newymin,
173176
)
174177

0 commit comments

Comments
 (0)