app/views/shared/_css_bar_chart.html.slim
head
== stylesheet_link_tag webpack_url('stylesheets/views/shared/css-bar-chart.css')
ruby:
max_height = 150
sums_by_date = report.sums.values.transpose
max_sum = sums_by_date.map(&:sum).max
colors = report.colors.to_h.values
labels = report.labels
div class="bar-chart-container" style="height: #{max_height}px"
- sums_by_date.each_with_index do |sums, date_index|
div class="date" style="height: #{max_height}px; width: #{100.0 / sums_by_date.count}%"
- height = max_height - (sums.sum * 1.00 / max_sum * max_height)
div class="bar" style="height: #{height}px; background-color: transparent;"
- sums.each_with_index do |sum, sum_index|
- height = sum * 1.00 / max_sum * max_height
div class="bar" style="height: #{height}px; background-color: #{colors[sum_index]};"
span class="label"
= labels[date_index]