reports: add non-timeseries charts.

Add bar charts for non-timeseries data. For example, a bar chart of the
top 10 uploaders overall in the last month, rather than a timeseries
chart of the number of uploads per day for the last month.
This commit is contained in:
evazion
2022-10-23 04:42:51 -05:00
parent 9ca76dd3be
commit 203067b5ed
7 changed files with 192 additions and 110 deletions

View File

@@ -6,7 +6,16 @@
<% end %>
</div>
<% if mode == :table %>
<% if mode == :chart && x_axis.present? %>
<div class="line-chart" style="width: 100%; height: max(90vh, <%= chart_height.to_i %>px);"></div>
<script type="text/javascript">
var chart = new Danbooru.TimeSeriesComponent({
container: $(".line-chart").get(0),
options: <%= raw chart_options.to_json %>,
});
</script>
<% else %>
<table class="striped autofit" width="100%">
<thead>
<% dataframe.types.keys.each do |column| %>
@@ -26,16 +35,4 @@
<% end %>
</tbody>
</table>
<% elsif mode == :chart %>
<div class="line-chart" style="width: 100%; height: 80vh;"></div>
<script type="text/javascript">
var data = <%= raw dataframe.each_row.map(&:values).to_json %>;
var columns = <%= raw dataframe.types.keys.without("date").to_json %>;
var chart = new Danbooru.TimeSeriesComponent({
container: $(".line-chart").get(0),
data: data,
columns: columns,
});
</script>
<% end %>