Skip to content

Commit

Permalink
Add option for chart height
Browse files Browse the repository at this point in the history
- currently hard coded as the chart isn't responsive
- quite difficult to write a test for this as it's applied as an inline style
  • Loading branch information
andysellick committed Oct 18, 2024
1 parent 383b16a commit 3ae4245
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
minimal_link ||= nil
hide_legend ||= minimal
link ||= false
height ||= 400

# minimal should:
# set a smaller height? Or pass as separate option
Expand Down Expand Up @@ -52,7 +53,7 @@
enableInteractivity: enableInteractivity,
legend: legend,
pointSize: pointSize,
height: 400,
height: height,
tooltip: { isHtml: true },
hAxis: {
textStyle: font_16,
Expand Down
40 changes: 40 additions & 0 deletions app/views/govuk_publishing_components/components/docs/chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,43 @@ examples:
- 118
- 85
- 80
with_a_different_height:
description: |
Sets a height in pixels for the chart, defaulting to `400`. This is useful where the chart might appear in a narrow column and the default height would be too tall.
The component is not currently responsive.
data:
chart_heading: Page views
h_axis_title: Day
v_axis_title: Views
minimal: true
minimal_link: "https://www.gov.uk"
chart_overview: This is a graph of views per day
height: 200
keys:
- 1st
- 2nd
- 3rd
- 4th
- 5th
- 6th
- 7th
rows:
- label: January 2015
values:
- 5
- 119
- 74
- 117
- 33
- 89
- 79
- label: January 2016
values:
- 3
- 8
- 37
- 82
- 118
- 85
- 80

0 comments on commit 3ae4245

Please sign in to comment.