Skip to content

Commit

Permalink
Fix chart minimal option
Browse files Browse the repository at this point in the history
- wasn't hiding legend, removing interactivity, or reducing point size automatically based on the minimal setting, as it should have
  • Loading branch information
andysellick committed Nov 22, 2024
1 parent 7fecf72 commit d3e41e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
chart_type ||= "line"
minimal ||= false
hide_heading ||= minimal
hide_legend ||= minimal
link ||= false
padding ||= false

Expand Down
3 changes: 3 additions & 0 deletions lib/govuk_publishing_components/presenters/chart_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ def initialize(options)
@rows = options[:rows]
@keys = options[:keys]
@minimal = options[:minimal]
@enable_interactivity = false
@enable_interactivity = true unless @minimal
@hide_legend = options[:hide_legend]
@hide_legend = true if @minimal
@point_size = options[:point_size] ||= 10
@point_size = 0 if @minimal
@height = options[:height] || 400
@h_axis_title = options[:h_axis_title]
@v_axis_title = options[:v_axis_title]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@

it "returns expected chart options when minimal is true" do
required_params[:minimal] = true
expected[:enableInteractivity] = nil
expected[:enableInteractivity] = false
expected[:hAxis][:textPosition] = "none"
expected[:vAxis][:textPosition] = "none"
expected[:legend] = "none"
expected[:pointSize] = 0

chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params)
options = chart_helper.chart_options
Expand Down

0 comments on commit d3e41e1

Please sign in to comment.