summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-03-07 13:24:21 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-03-13 13:52:39 (GMT)
commit647a98ace052642be893fd05c6c4bcea5a45ff42 (patch)
tree2c9948d959e6fdce6944a88ef69d584de614a93f
parent9bb1721644f23d30b16cde389108c3959b9d8319 (diff)
downloadcombo-647a98ace052642be893fd05c6c4bcea5a45ff42.zip
combo-647a98ace052642be893fd05c6c4bcea5a45ff42.tar.gz
combo-647a98ace052642be893fd05c6c4bcea5a45ff42.tar.bz2
stacking tests
-rw-r--r--combo/apps/dataviz/views.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/combo/apps/dataviz/views.py b/combo/apps/dataviz/views.py
index fc9290d..b70bc23 100644
--- a/combo/apps/dataviz/views.py
+++ b/combo/apps/dataviz/views.py
@@ -44,7 +44,7 @@ def dataviz_graph(request, *args, **kwargs):
plt.style.use('bmh')
fig, ax = plt.subplots(figsize=(8, 4))
- if False:
+ if True:
# barcharts
x_labels = response['axis'].get('x_labels') or []
y_labels = response['axis'].get('y_labels') or []
@@ -57,14 +57,26 @@ def dataviz_graph(request, *args, **kwargs):
index = np.arange(n_groups)
bar_width = 0.8 / len(y_labels)
+ STACKED = True
+ if STACKED:
+ bar_width = 0.8
+
+ bottom = np.array([0] * len(x_labels))
for i, serie_label in enumerate(y_labels):
if len(response['axis']) == 1:
values = response['data']
else:
values = [response['data'][i][j] for j in range(len(x_labels))]
- if False:
- ax.bar(index + bar_width*i, values, bar_width,
- label=serie_label if len(y_labels) > 1 else None)
+ if True:
+ if not STACKED:
+ ax.bar(index + bar_width*i, values, bar_width,
+ label=serie_label if len(y_labels) > 1 else None,
+ bottom=bottom)
+ else:
+ ax.bar(index+0.25, values, bar_width,
+ label=serie_label if len(y_labels) > 1 else None,
+ bottom=bottom)
+ bottom = bottom + np.array(values)
else:
# plot
ax.plot(index + bar_width*i, values,