Skip to content

Commit

Permalink
Use new rows method in the view
Browse files Browse the repository at this point in the history
  • Loading branch information
leenagupte committed Oct 18, 2024
1 parent 0f13af0 commit 6d47892
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions app/views/landing_page/blocks/_statistics.html.erb
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
<%
add_gem_component_stylesheet("chart")

rows = []
lines = {}
block.rows.each_with_index do |row, i|
if lines.key?(row["variable"].to_sym)
lines[row["variable"].to_sym][:values] << row["value"].to_i
else
lines[row["variable"].to_sym] = {
label: row["Date"],
values: [
row["value"].to_i
]
}
end

end

lines.each do |key, array|
rows << {
label: key.to_s,
values: lines[key][:values]
}
end
%>
<%= render "govuk_publishing_components/components/chart", {
Expand All @@ -31,6 +8,6 @@
v_axis_title: block.y_axis_label,
hide_legend: block.hide_legend,
keys: block.x_axis_keys,
rows: rows,
rows: block.rows,
} %>
<%= link_to block.data["data_source_link_text"], block.data_source_link %>

0 comments on commit 6d47892

Please sign in to comment.