diff --git a/Gemfile.lock b/Gemfile.lock index 24fb4425ba..e26efc20cf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,6 @@ PATH remote: . specs: govuk_publishing_components (46.4.0) - chartkick govuk_app_config govuk_personalisation (>= 0.7.0) kramdown @@ -106,7 +105,6 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - chartkick (5.1.2) climate_control (1.2.0) coderay (1.1.3) concurrent-ruby (1.3.4) diff --git a/app/assets/javascripts/govuk_publishing_components/components/chart.js b/app/assets/javascripts/govuk_publishing_components/components/chart.js deleted file mode 100644 index 3d6a6c49b1..0000000000 --- a/app/assets/javascripts/govuk_publishing_components/components/chart.js +++ /dev/null @@ -1 +0,0 @@ -//= require chartkick diff --git a/app/assets/stylesheets/govuk_publishing_components/components/_chart.scss b/app/assets/stylesheets/govuk_publishing_components/components/_chart.scss deleted file mode 100644 index 4f76bbe4bf..0000000000 --- a/app/assets/stylesheets/govuk_publishing_components/components/_chart.scss +++ /dev/null @@ -1,57 +0,0 @@ -@import "govuk_publishing_components/individual_component_support"; - -.gem-c-chart { - position: relative; - - // slight hack to hide the table automatically added by the charts JS - // not needed as we already output the table manually in the component - svg + div:has(table) { - display: none; - } - - .google-visualization-tooltip { - background-color: govuk-colour("black"); - box-shadow: none; - border: 0; - - span { - color: govuk-colour("white"); - @include govuk-font($size: 16, $weight: bold); - } - } -} - -.gem-c-chart__table-wrapper { - overflow: auto; -} - -.gem-c-chart__table { - margin-top: govuk-spacing(3); - - .govuk-table { - margin: 0; - } - - .govuk-table .govuk-table__header { - text-align: center; - } - - .govuk-table .govuk-table__cell { - text-align: center; - } -} - -.gem-c-chart .gem-c-chart__a11y-note-link { - display: none; - margin-bottom: govuk-spacing(2); -} - -.js-enabled { - .gem-c-chart .gem-c-chart__a11y-note-link { - display: inline; - } - - .gem-c-chart .gem-c-chart__a11y-note-link:focus-within { - display: inline-block; - } -} diff --git a/app/views/govuk_publishing_components/components/_chart.html.erb b/app/views/govuk_publishing_components/components/_chart.html.erb deleted file mode 100644 index fd04667772..0000000000 --- a/app/views/govuk_publishing_components/components/_chart.html.erb +++ /dev/null @@ -1,146 +0,0 @@ -<% - add_gem_component_stylesheet("chart") - add_gem_component_stylesheet("table") - add_gem_component_stylesheet("details") - add_gem_component_stylesheet("heading") - add_gem_component_stylesheet("skip-link") - - chart_heading_level ||= 2 - table_direction ||= "horizontal" - rows ||= [] - keys ||= [] - chart_overview ||= nil - chart_type ||= "line" - minimal ||= false - hide_heading ||= minimal - link ||= false - local_assigns[:margin_bottom] ||= 3 - - chart_id = "chart-id-#{SecureRandom.hex(4)}" - table_id = "table-id-#{SecureRandom.hex(4)}" - @external_script ||= OpenStruct.new(loaded: 0) - @external_script[:loaded] += 1 - - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(local_assigns) - component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns) - component_helper.add_class("gem-c-chart") - component_helper.add_class("gem-c-chart--minimal") if minimal - - require "chartkick" - Chartkick.options[:html] = '
' - - if !minimal && !chart_heading - raise ArgumentError, "A chart heading must be provided for accessibility purposes." - end -%> -<% if rows.length > 0 && keys.length > 0 %> - <%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" if @external_script[:loaded] == 1 %> - <%= tag.div(**component_helper.all_attributes) do %> - <% if chart_heading && !hide_heading %> -
-
- <%= render "govuk_publishing_components/components/heading", { - text: chart_heading, - heading_level: chart_heading_level, - margin_bottom: 2, - } %> -
-
- <% end %> - - <% aria_attributes = { hidden: true } if minimal %> - <%= content_tag :div, id: chart_id, class: "gem-c-chart__chart", aria: aria_attributes do %> - <% unless minimal %> -
- <%= content_tag :div, chart_overview, class: "gem-c-chart__a11y-note-1" if chart_overview %> - <%= content_tag :div, t("components.chart.accessibility_html"), class: "gem-c-chart__a11y-note-2" %> -
- - <%= render "govuk_publishing_components/components/skip_link", { - text: t("components.chart.accessibility_link", chart_heading: chart_heading), - href: "##{table_id}" - } %> - - <% end %> - - <% if chart_type == "column" %> - <%= column_chart(chart_helper.chart_format_data, library: chart_helper.chart_options) %> - <% elsif chart_type == "bar" %> - <%= bar_chart(chart_helper.chart_format_data, library: chart_helper.chart_options) %> - <% else %> - <%= line_chart(chart_helper.chart_format_data, library: chart_helper.chart_options) %> - <% end %> - <% end %> - - <% unless minimal %> -
- <%= render("govuk_publishing_components/components/details", - title: t("components.chart.table_dropdown") - ) do %> -
- - - <% if table_direction == "horizontal" %> - - - - <% keys.each do |key| %> - - <% end %> - - - - <% rows.each do |row| %> - - - <% row[:values].each do |value| %> - - <% end %> - - <% end %> - - <% else %> - - - - <% rows.each do |row| %> - - <% end %> - - - - <% keys.each_with_index do |key, index| %> - - - <% rows.each do |row| %> - - <% end %> - - <% end %> - - <% end %> -
"> - <%= t("components.chart.accessibility_heading", chart_heading: chart_heading) %> -
- <%= key %> -
<%= row[:label] %> - <%= number_with_delimiter value %> -
- <%= row[:label] %> -
- <%= key %> - - <%= number_with_delimiter row[:values][index] %> -
-
- <% end %> -
- - <% if link %> -

- <%= link_to "Download chart data", link, class: "govuk-link" %> -

- <% end %> - <% end %> - <% end %> -<% end %> diff --git a/app/views/govuk_publishing_components/components/docs/chart.yml b/app/views/govuk_publishing_components/components/docs/chart.yml deleted file mode 100644 index 4c103eb309..0000000000 --- a/app/views/govuk_publishing_components/components/docs/chart.yml +++ /dev/null @@ -1,576 +0,0 @@ -name: Chart (experimental) -description: The chart component presents a data chart and a tabular version of the same data -part_of_admin_layout: true -body: | - This component takes a set of data and presents it as a line graph and a table with one or more rows and lines. - The chart relies upon chartkick and renders using JavaScript, so the table is provided as a fallback for a lack of JavaScript, - an accessible view on the data for screenreaders, and a simple view of the raw data for all users. - - The `chart_overview` option can be used to provide an explanation for screen reader users of what the chart shows. -accessibility_criteria: | - Charts must: - - - use line colours with a contrast ratio higher than 4.5:1 against the background colour to meet WCAG AA - - contain a `chart_heading` option if `minimal` is not set to true, so that skip links and visually hidden headings are accurate -shared_accessibility_criteria: - - link -uses_component_wrapper_helper: true -examples: - default: - data: - chart_heading: Chart showing page views on the website in January 2015 - h_axis_title: Day - v_axis_title: Views - chart_overview: This chart shows page views for January 2015. - keys: - - "2015-01-01" - - "2015-01-02" - - "2015-01-03" - - "2015-01-04" - - "2015-01-05" - - "2015-01-06" - - "2015-01-07" - - "2015-01-08" - - "2015-01-09" - - "2015-01-10" - rows: - - label: January 2015 - values: - - 500 - - 1190 - - 740 - - 820 - - 270 - - 450 - - 110 - - 210 - - 670 - - 430 - multiple rows of data: - description: Where more than one series is shown on a chart, do not hide the legend. - data: - chart_heading: Page views chart - h_axis_title: Day - v_axis_title: Views - chart_overview: This chart shows page views for January in different years. - keys: - - 1st - - 2nd - - 3rd - - 4th - - 5th - - 6th - - 7th - - 8th - - 9th - - 10th - rows: - - label: January 2015 - values: - - 5 - - 119 - - 74 - - 82 - - 27 - - 45 - - 11 - - 21 - - 67 - - 43 - - label: January 2016 - values: - - 5 - - 8 - - 37 - - 50 - - 43 - - 29 - - 67 - - 61 - - 14 - - 91 - - label: January 2017 - values: - - 31 - - 81 - - 12 - - 15 - - 52 - - 61 - - 143 - - 27 - - 18 - - 34 - hide_legend: - data: - chart_heading: Page views chart - h_axis_title: Day - v_axis_title: Views - chart_overview: This chart shows page views for January 2015. - hide_legend: true - keys: - - "2015-01-01" - - "2015-01-02" - - "2015-01-03" - - "2015-01-04" - - "2015-01-05" - - "2015-01-06" - - "2015-01-07" - - "2015-01-08" - - "2015-01-09" - - "2015-01-10" - rows: - - label: January 2015 - values: - - 500 - - 1190 - - 740 - - 820 - - 270 - - 450 - - 110 - - 210 - - 670 - - 430 - with_line_colours_and_styles: - description: Note that line styles and colours currently only work on line charts. - data: - chart_heading: Page views chart - h_axis_title: Day - v_axis_title: Views - chart_overview: This chart shows page views for January in different years. - line_colours: - - orange - - blue - - "#88AA11" - line_styles: - - solid - - dotted - - solid - keys: - - 1st - - 2nd - - 3rd - rows: - - label: January 2015 - values: - - 110 - - 119 - - 105 - - label: January 2016 - values: - - 71 - - 68 - - 75 - - label: January 2017 - values: - - 21 - - 42 - - 18 - bar_chart: - data: - chart_heading: Hats owned - h_axis_title: Day - v_axis_title: Views - chart_overview: This chart shows page views for January 2015. - chart_type: "bar" - hide_legend: true - keys: - - Jon - - Ash - - James - - Phil - rows: - - label: Hats owned - values: - - 3 - - 1 - - 1 - - 2 - column_chart: - data: - chart_heading: Hats owned - h_axis_title: Day - v_axis_title: Views - chart_overview: This chart shows page views for January 2015. - chart_type: "column" - hide_legend: true - keys: - - Jon - - Ash - - James - - Phil - rows: - - label: Hats owned - values: - - 3 - - 1 - - 1 - - 2 - format_axis_labels: - description: | - Axis labels can be forced into date or currency format as shown. - - 'currency' will add a currency symbol (£) at the start of the labels. - - 'percent' will add a percent (%) to the end of the labels. - - 'date' will force a standard date format of `YYYY-MM-DD` to the labels, where they are in an undesirable date format. This can be useful if there are a lot of labels on the axes because the chart can do strange truncation sometimes. - data: - chart_heading: Cost per day - h_axis_title: Day - v_axis_title: Cost - chart_overview: This chart shows cost per day. - v_axis_format: currency - h_axis_format: date - keys: - - 2024 Jan 1 - - 2024 Jan 2 - - 2024 Jan 3 - - 2024 Jan 4 - - 2024 Jan 5 - - 2024 Jan 6 - rows: - - label: Cost - values: - - 14 - - 29 - - 45 - - 63 - - 54 - - 22 - vertical table: - description: Reorient the table to better suit the output of some data sets. - data: - chart_heading: Page views chart - table_direction: vertical - h_axis_title: Day - v_axis_title: Views - chart_overview: This chart shows page views for January in different years. - 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 - with_a_different_point_size: - description: For some charts it may be better to reduce the point size so that the line is clearer. However it is recommended that the point size is larger to make it easier for users to move the mouse over them. - data: - chart_heading: Page views chart - h_axis_title: Day - v_axis_title: Views - chart_overview: This chart shows page views for January 2015. - point_size: 0 - keys: - - "2015-01-01" - - "2015-01-02" - - "2015-01-03" - - "2015-01-04" - - "2015-01-05" - - "2015-01-06" - - "2015-01-07" - - "2015-01-08" - - "2015-01-09" - - "2015-01-10" - rows: - - label: January 2015 - values: - - 600 - - 690 - - 740 - - 820 - - 570 - - 950 - - 810 - - 610 - - 770 - - 530 - scale_y_axis_based_on_data: - description: | - By default the Y-axis will always start at zero, but this may not always be required. - - If there are empty items in the data the chart line will either discontinue or leave a gap, as shown. - data: - chart_heading: Page views chart - h_axis_title: Day - v_axis_title: Views - chart_overview: This chart shows page views for January 2015. - hide_legend: true - y_axis_auto_adjust: true - keys: - - "2015-01-01" - - "2015-01-02" - - "2015-01-03" - - "2015-01-04" - - "2015-01-05" - - "2015-01-06" - - "2015-01-07" - - "2015-01-08" - - "2015-01-09" - - "2015-01-10" - - "2015-01-11" - - "2015-01-12" - - "2015-01-13" - rows: - - label: January 2015 - values: - - 1500 - - 1190 - - 1740 - - 1820 - - 1270 - - - - - - 1450 - - 1110 - - 1210 - - 1670 - - 1430 - - 1352 - with_a_different_heading_level: - description: Use a different heading level for the chart heading. It defaults to a H2. - data: - chart_heading: Page views chart - chart_heading_level: 4 - h_axis_title: Day - v_axis_title: Views - chart_overview: This chart shows page views for January in different years. - 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 - with_a_download_link: - description: Add a download link to the original data. Doesn't do anything clever, just creates a link to the URL passed. - data: - chart_heading: Page views chart - h_axis_title: Day - v_axis_title: Views - link: 'https://www.gov.uk' - chart_overview: This chart shows page views for January in different years. - 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 - with_margin_bottom: - description: The component accepts a number for margin bottom from `0` to `9` (`0px` to `60px`) using the [GOV.UK Frontend spacing scale](https://design-system.service.gov.uk/styles/spacing/#the-responsive-spacing-scale). It defaults to having a bottom margin of 15px. - data: - chart_heading: Page views chart - h_axis_title: Day - v_axis_title: Views - margin_bottom: 9 - chart_overview: This chart shows page views for January in different years. - 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 - minimal_version: - description: | - The minimal version presents a simplified version of the chart. This should only be used where there is not enough space to display a full chart, and the user is then given an option to see more information about the chart, for example by including a link next to the chart component. This must be part of the page, as this is not provided by the component itself. - - Specifically, minimal mode: - - - hides the chart heading - - removes the legend and X and Y axis values - - removes the data table and link to the data (if supplied) beneath the chart - - removes the part of the visually hidden accessibility message that links to the table - - removes the ability to interact with the chart (no hover popups or clicks) - - sets the size of the points on the chart to zero - data: - chart_heading: Page views - h_axis_title: Day - v_axis_title: Views - minimal: true - chart_overview: This is a graph of views per day - 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 - 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 - 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 - with_hidden_heading: - description: | - The heading element is optional, allowing a heading to be set outside the component. Hiding the heading doesn't remove the need to populate `chart_heading` with text, as `chart_heading` is needed for accessibility. - data: - chart_heading: Page views - hide_heading: true - h_axis_title: Day - v_axis_title: Views - chart_overview: This is a graph of views per day - 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 - diff --git a/config/locales/ar.yml b/config/locales/ar.yml index d256e86b0b..bc769548ef 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -36,11 +36,6 @@ ar: type: characters: أحرف words: كلمات - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/az.yml b/config/locales/az.yml index 41ebadd774..ee2c23ab6e 100644 --- a/config/locales/az.yml +++ b/config/locales/az.yml @@ -32,11 +32,6 @@ az: type: characters: simvol words: söz - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/be.yml b/config/locales/be.yml index 4ae6eb9ec0..265645a223 100644 --- a/config/locales/be.yml +++ b/config/locales/be.yml @@ -34,11 +34,6 @@ be: type: characters: знакаў words: словаў - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 8a108d7933..673aa4ac88 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -32,11 +32,6 @@ bg: type: characters: символа words: думи - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/bn.yml b/config/locales/bn.yml index 82ee0aa438..ac27237f6d 100644 --- a/config/locales/bn.yml +++ b/config/locales/bn.yml @@ -32,11 +32,6 @@ bn: type: characters: ক্যারেক্টার words: শব্দসমষ্টি - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 40f8b20620..a9126c851f 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -33,11 +33,6 @@ cs: type: characters: znaky words: slova - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/cy.yml b/config/locales/cy.yml index a5e6a6cb76..02d8c69249 100644 --- a/config/locales/cy.yml +++ b/config/locales/cy.yml @@ -36,11 +36,6 @@ cy: type: characters: nodau words: geiriau - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/da.yml b/config/locales/da.yml index 0926a8392e..bc5ff79d95 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -32,11 +32,6 @@ da: type: characters: Tegn words: ord - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/de.yml b/config/locales/de.yml index bdaca69a25..1559f6dcc5 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -32,11 +32,6 @@ de: type: characters: Zeichen words: Wörter - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/dr.yml b/config/locales/dr.yml index 0d3856061a..3de2d61db6 100644 --- a/config/locales/dr.yml +++ b/config/locales/dr.yml @@ -35,11 +35,6 @@ dr: type: characters: ارقام words: کلمات - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/el.yml b/config/locales/el.yml index dd6019ca89..06d2dcd6a7 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -32,11 +32,6 @@ el: type: characters: χαρακτήρες words: λέξεις - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/en.yml b/config/locales/en.yml index 7d8f1beebc..f68649c473 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -32,11 +32,6 @@ en: type: characters: characters words: words - chart: - table_dropdown: View data as a table - accessibility_html: This chart is a visual representation of the data available in the table. - accessibility_link: Skip to "%{chart_heading}" data table - accessibility_heading: Data table for "%{chart_heading}" chat_entry: heading: Ask GOV.UK Chat description: Get quick, tailored answers to your business questions with GOV.UK’s new AI tool diff --git a/config/locales/es-419.yml b/config/locales/es-419.yml index 6bbeaee799..d0ae2bd9bb 100644 --- a/config/locales/es-419.yml +++ b/config/locales/es-419.yml @@ -32,11 +32,6 @@ es-419: type: characters: caracteres words: palabras - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/es.yml b/config/locales/es.yml index 5d8856329d..2d736f683f 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -32,11 +32,6 @@ es: type: characters: caracteres words: palabras - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/et.yml b/config/locales/et.yml index 3f7904d286..7aabbc71a0 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -32,11 +32,6 @@ et: type: characters: tähemärki words: sõnu - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/fa.yml b/config/locales/fa.yml index bcb754647d..b09c2509ee 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -32,11 +32,6 @@ fa: type: characters: کاراکتر words: کلمه - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 0c68504070..dae39b236b 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -32,11 +32,6 @@ fi: type: characters: merkkejä words: sanoja - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 85d8a3ea96..53b141a8ce 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -32,11 +32,6 @@ fr: type: characters: caractères words: mots - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/gd.yml b/config/locales/gd.yml index fec02fcf92..12a1dad38e 100644 --- a/config/locales/gd.yml +++ b/config/locales/gd.yml @@ -34,11 +34,6 @@ gd: type: characters: Figiúr words: Carachtar - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/gu.yml b/config/locales/gu.yml index a7b7f56f07..994d4b64bd 100644 --- a/config/locales/gu.yml +++ b/config/locales/gu.yml @@ -32,11 +32,6 @@ gu: type: characters: અક્ષરો words: શબ્દો - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/he.yml b/config/locales/he.yml index 5853491375..6aa51b0c46 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -32,11 +32,6 @@ he: type: characters: תווים words: מילים - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/hi.yml b/config/locales/hi.yml index 7a8ed49371..b73898c848 100644 --- a/config/locales/hi.yml +++ b/config/locales/hi.yml @@ -32,11 +32,6 @@ hi: type: characters: अक्षर words: शब्द - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/hr.yml b/config/locales/hr.yml index e7971313f2..4e41279339 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -33,11 +33,6 @@ hr: type: characters: znakova words: riječi - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/hu.yml b/config/locales/hu.yml index f385436f49..83878d53ae 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -32,11 +32,6 @@ hu: type: characters: karakterek words: szavak - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/hy.yml b/config/locales/hy.yml index 27f4ddacb5..51aa7bea7d 100644 --- a/config/locales/hy.yml +++ b/config/locales/hy.yml @@ -34,11 +34,6 @@ hy: type: characters: նիշ words: բառ - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/id.yml b/config/locales/id.yml index e7ed79da1b..72636a80ae 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -31,11 +31,6 @@ id: type: characters: karakter words: kata - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/is.yml b/config/locales/is.yml index addf04f07a..42d471cdf3 100644 --- a/config/locales/is.yml +++ b/config/locales/is.yml @@ -32,11 +32,6 @@ is: type: characters: stafi words: orð - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/it.yml b/config/locales/it.yml index 33514b9ae9..f5084bc5bd 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -32,11 +32,6 @@ it: type: characters: caratteri words: parole - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/ja.yml b/config/locales/ja.yml index de98f85877..9a84eeb50a 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -31,11 +31,6 @@ ja: type: characters: 文字 words: 単語 - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/ka.yml b/config/locales/ka.yml index bd8fe522fe..9501491d27 100644 --- a/config/locales/ka.yml +++ b/config/locales/ka.yml @@ -32,11 +32,6 @@ ka: type: characters: სიმბოლოები words: სიტყვები - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/kk.yml b/config/locales/kk.yml index 63eec21b8e..6bbeaf311c 100644 --- a/config/locales/kk.yml +++ b/config/locales/kk.yml @@ -32,11 +32,6 @@ kk: type: characters: таңба words: сөз - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/ko.yml b/config/locales/ko.yml index cae52a674c..5e85828b86 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -31,11 +31,6 @@ ko: type: characters: words: - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/lt.yml b/config/locales/lt.yml index cdedb86d62..6c94b8377e 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -33,11 +33,6 @@ lt: type: characters: spaudos ženklų words: žodžių - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/lv.yml b/config/locales/lv.yml index 43d0c888e6..b12c936758 100644 --- a/config/locales/lv.yml +++ b/config/locales/lv.yml @@ -32,11 +32,6 @@ lv: type: characters: rakstzīmes words: vārdi - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/ms.yml b/config/locales/ms.yml index 100d01cf02..817464a023 100644 --- a/config/locales/ms.yml +++ b/config/locales/ms.yml @@ -31,11 +31,6 @@ ms: type: characters: aksara words: perkataan - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/mt.yml b/config/locales/mt.yml index 5fed8d2b03..fb57d6623f 100644 --- a/config/locales/mt.yml +++ b/config/locales/mt.yml @@ -34,11 +34,6 @@ mt: type: characters: karattri words: kliem - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index c0ee246bc4..30f2d53776 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -32,11 +32,6 @@ nl: type: characters: karakters words: woorden - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/no.yml b/config/locales/no.yml index 269da6799c..6aae564506 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -32,11 +32,6 @@ type: characters: tegn words: ord - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/pa-pk.yml b/config/locales/pa-pk.yml index 54ed349e3c..7bd12e2382 100644 --- a/config/locales/pa-pk.yml +++ b/config/locales/pa-pk.yml @@ -32,11 +32,6 @@ pa-pk: type: characters: کردار words: الفاظ - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/pa.yml b/config/locales/pa.yml index 7b43d1e2f5..559733707d 100644 --- a/config/locales/pa.yml +++ b/config/locales/pa.yml @@ -32,11 +32,6 @@ pa: type: characters: ਅੱਖਰ words: ਸ਼ਬਦ - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 126216374b..4b05ff631d 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -34,11 +34,6 @@ pl: type: characters: znaków words: słów - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/ps.yml b/config/locales/ps.yml index a9c82be466..ca93cb9f80 100644 --- a/config/locales/ps.yml +++ b/config/locales/ps.yml @@ -32,11 +32,6 @@ ps: type: characters: کرکټرونه words: ټکي - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 755f3a7794..bbed799d87 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -32,11 +32,6 @@ pt: type: characters: carateres words: palavras - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/ro.yml b/config/locales/ro.yml index d18e52e4c2..da43c25e29 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -33,11 +33,6 @@ ro: type: characters: caractere words: cuvinte - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/ru.yml b/config/locales/ru.yml index e79f253d01..f6b98bdc57 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -34,11 +34,6 @@ ru: type: characters: символов words: слов - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/si.yml b/config/locales/si.yml index 07fe2f522d..00de1366f8 100644 --- a/config/locales/si.yml +++ b/config/locales/si.yml @@ -32,11 +32,6 @@ si: type: characters: අක්ෂර words: වචන - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/sk.yml b/config/locales/sk.yml index a0a8d60bb1..1158ed975a 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -33,11 +33,6 @@ sk: type: characters: znakov words: slov - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/sl.yml b/config/locales/sl.yml index c532386b4d..b2cc14590f 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -36,11 +36,6 @@ sl: type: characters: znaki words: besede - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/so.yml b/config/locales/so.yml index 8b57fce6fd..7f3ff48bf7 100644 --- a/config/locales/so.yml +++ b/config/locales/so.yml @@ -32,11 +32,6 @@ so: type: characters: dabeecadaha words: kalmadaha - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/sq.yml b/config/locales/sq.yml index 4f2999f3b1..78c1e42be8 100644 --- a/config/locales/sq.yml +++ b/config/locales/sq.yml @@ -32,11 +32,6 @@ sq: type: characters: karaktere words: fjalë - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 2c6101671a..bd833cae50 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -33,11 +33,6 @@ sr: type: characters: znakova words: reči - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 126265f5ca..dcc87fcd1f 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -32,11 +32,6 @@ sv: type: characters: tecken words: ord - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/sw.yml b/config/locales/sw.yml index 8b408689c5..8fade90108 100644 --- a/config/locales/sw.yml +++ b/config/locales/sw.yml @@ -32,11 +32,6 @@ sw: type: characters: herufi words: maneno - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/ta.yml b/config/locales/ta.yml index bc75c024ee..7b131a412d 100644 --- a/config/locales/ta.yml +++ b/config/locales/ta.yml @@ -32,11 +32,6 @@ ta: type: characters: எழுத்துருக்கள் words: சொற்கள் - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/th.yml b/config/locales/th.yml index 451f45f29e..242c698147 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -31,11 +31,6 @@ th: type: characters: ตัวอักษร words: คำ - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/tk.yml b/config/locales/tk.yml index 9e4461471c..22e212b1d4 100644 --- a/config/locales/tk.yml +++ b/config/locales/tk.yml @@ -32,11 +32,6 @@ tk: type: characters: şekiller words: sözler - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 7f2efd573a..6de227ac4b 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -32,11 +32,6 @@ tr: type: characters: karakter words: kelime - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 9f3f9a3fdc..6d220fa40f 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -34,11 +34,6 @@ uk: type: characters: символів words: слів - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/ur.yml b/config/locales/ur.yml index 13f254059a..8f0d006bf2 100644 --- a/config/locales/ur.yml +++ b/config/locales/ur.yml @@ -32,11 +32,6 @@ ur: type: characters: حروف words: الفاظ - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/uz.yml b/config/locales/uz.yml index e141d284e4..9c8f06cc7d 100644 --- a/config/locales/uz.yml +++ b/config/locales/uz.yml @@ -32,11 +32,6 @@ uz: type: characters: белгилар words: сўзлар - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/vi.yml b/config/locales/vi.yml index 68d7ac320a..8fefd66901 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -31,11 +31,6 @@ vi: type: characters: ký tự words: từ - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/zh-hk.yml b/config/locales/zh-hk.yml index c4d04dd28a..0e18410e6c 100644 --- a/config/locales/zh-hk.yml +++ b/config/locales/zh-hk.yml @@ -31,11 +31,6 @@ zh-hk: type: characters: 字元 words: 字彙 - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/zh-tw.yml b/config/locales/zh-tw.yml index 2ea3bbc796..8e42cb768a 100644 --- a/config/locales/zh-tw.yml +++ b/config/locales/zh-tw.yml @@ -31,11 +31,6 @@ zh-tw: type: characters: 字元 words: 字 - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 00b944a0da..bdf1f25f99 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -31,11 +31,6 @@ zh: type: characters: 字符 words: 单词 - chart: - accessibility_heading: - accessibility_html: - accessibility_link: - table_dropdown: chat_entry: description: heading: diff --git a/govuk_publishing_components.gemspec b/govuk_publishing_components.gemspec index f19b1868e1..d6f36a9f46 100644 --- a/govuk_publishing_components.gemspec +++ b/govuk_publishing_components.gemspec @@ -14,9 +14,8 @@ Gem::Specification.new do |s| s.license = "MIT" s.required_ruby_version = ">= 3.2" - s.files = Dir["{node_modules/accessible-autocomplete,node_modules/govuk-frontend,node_modules/axe-core,node_modules/sortablejs,node_modules/govuk-single-consent,node_modules/chartkick,app,config,db,lib}/**/*", "LICENCE.md", "README.md"] + s.files = Dir["{node_modules/accessible-autocomplete,node_modules/govuk-frontend,node_modules/axe-core,node_modules/sortablejs,node_modules/govuk-single-consent,app,config,db,lib}/**/*", "LICENCE.md", "README.md"] - s.add_dependency "chartkick" s.add_dependency "govuk_app_config" s.add_dependency "govuk_personalisation", ">= 0.7.0" s.add_dependency "kramdown" diff --git a/lib/govuk_publishing_components.rb b/lib/govuk_publishing_components.rb index 97dc3852f0..55e6ab342b 100644 --- a/lib/govuk_publishing_components.rb +++ b/lib/govuk_publishing_components.rb @@ -15,7 +15,6 @@ require "govuk_publishing_components/presenters/breadcrumbs_helper" require "govuk_publishing_components/presenters/breadcrumb_selector" require "govuk_publishing_components/presenters/button_helper" -require "govuk_publishing_components/presenters/chart_helper" require "govuk_publishing_components/presenters/contextual_navigation" require "govuk_publishing_components/presenters/devolved_nations_helper" require "govuk_publishing_components/presenters/emergency_banner_helper" diff --git a/lib/govuk_publishing_components/presenters/chart_helper.rb b/lib/govuk_publishing_components/presenters/chart_helper.rb deleted file mode 100644 index 8ddda15a20..0000000000 --- a/lib/govuk_publishing_components/presenters/chart_helper.rb +++ /dev/null @@ -1,112 +0,0 @@ -module GovukPublishingComponents - module Presenters - class ChartHelper - 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] - @text_position = "none" if @minimal - @y_axis_view_window_min = 0 - @y_axis_view_window_min = "auto" if options[:y_axis_auto_adjust] - @line_colours = options[:line_colours] - @line_styles = options[:line_styles] - - @h_axis_format = "YYYY-MM-dd" if options[:h_axis_format] == "date" - @h_axis_format = "£#" if options[:h_axis_format] == "currency" - @h_axis_format = "#'\%'" if options[:h_axis_format] == "percent" - - @v_axis_format = "YYYY-MM-dd" if options[:v_axis_format] == "date" - @v_axis_format = "£#" if options[:v_axis_format] == "currency" - @v_axis_format = "#'\%'" if options[:v_axis_format] == "percent" - end - - # config options are here: https://developers.google.com/chart/interactive/docs/gallery/linechart - def chart_options - { - chartArea: { width: "80%", height: "60%" }, - crosshair: { orientation: "vertical", trigger: "both", color: "#ccc" }, - curveType: "none", - enableInteractivity: @enable_interactivity, - legend: legend_options, - pointSize: @point_size, - height: @height, - tooltip: { isHtml: true }, - series: series_options, - hAxis: { - textStyle: set_font_16, - title: @h_axis_title, - titleTextStyle: set_font_19, - textPosition: @text_position, - format: @h_axis_format, - }, - vAxis: { - textStyle: set_font_16, - title: @v_axis_title, - titleTextStyle: set_font_19, - textPosition: @text_position, - format: @v_axis_format, - viewWindow: { - min: @y_axis_view_window_min, - }, - }, - } - end - - def chart_format_data - if !@rows.empty? && !@keys.empty? - @rows.map do |row| - { - name: row[:label], - data: @keys.zip(row[:values]), - } - end - end - end - - private - - def legend_options - return { position: "top", textStyle: set_font_16 } unless @hide_legend - - "none" - end - - def set_font_16 - { color: "#000", fontName: "GDS Transport", fontSize: "16", italic: false } - end - - def set_font_19 - { color: "#000", fontName: "GDS Transport", fontSize: "19", italic: false } - end - - def series_options - series = {} - if @line_colours - @line_colours.each_with_index do |item, index| - series[index] = {} unless series[index] - series[index][:color] = item - end - end - - if @line_styles - @line_styles.each_with_index do |item, index| - style = [2, 2] if item == "dotted" - series[index] = {} unless series[index] - series[index][:lineDashStyle] = style - end - end - - series - end - end - end -end diff --git a/package.json b/package.json index 9b360f2250..12bdb4132f 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "dependencies": { "accessible-autocomplete": "^3.0.1", "axe-core": "^4.10.2", - "chartkick": "^5.0.1", "govuk-frontend": "5.7.1", "govuk-single-consent": "^3.0.9", "sortablejs": "^1.15.6" diff --git a/spec/components/chart_spec.rb b/spec/components/chart_spec.rb deleted file mode 100644 index 615f30e23e..0000000000 --- a/spec/components/chart_spec.rb +++ /dev/null @@ -1,158 +0,0 @@ -require "rails_helper" - -describe "Chart", type: :view do - def component_name - "chart" - end - - before { allow(SecureRandom).to receive(:hex).and_return("1234") } - - let(:data) do - { - chart_heading: "Page views chart", - keys: (Date.new(2017, 12, 1)..Date.new(2017, 12, 12)).to_a, - rows: [ - { - label: "2017", - values: [5, nil, nil, 119, 74, 117, 50, 119, 61, 110, 12, 21, 121, 67], - }, - { - label: "2018", - values: [3, 8, 37, 435, 78, 4, 9, 61, 110, 12, 21, 121], - }, - ], - } - end - - it "does not render when no data is given" do - assert_empty render_component({ chart_heading: "" }) - end - - it "does not render if keys are missing" do - data[:keys] = [] - assert_empty render_component(data) - end - - it "does not render if row data is missing" do - data[:rows] = [] - assert_empty render_component(data) - end - - it "renders when given valid data" do - render_component(data) - assert_select '.gem-c-chart.govuk-\!-margin-bottom-3', 1 - assert_select ".govuk-details__summary-text", text: "View data as a table" - end - - it "renders the correct table data horizontally" do - data[:table_direction] = "horizontal" - render_component(data) - assert_select ".govuk-table__body .govuk-table__header:nth-child(1)", text: "2017" - assert_select ".govuk-table__cell--numeric", 26 - assert_select ".govuk-table__header", 14 - assert_select "td:first", text: "5" - assert_select "td:last", text: "121" - end - - it "renders the correct table data vertically" do - data[:table_direction] = "vertical" - render_component(data) - assert_select ".govuk-table__body .govuk-table__header:nth-child(1)", text: "2017-12-01" - assert_select ".govuk-table__cell--numeric", 24 - assert_select ".govuk-table__header", 14 - - assert_select "td:first", text: "5" - assert_select ".govuk-table__body tr:nth-of-type(4) td:first", text: "119" - assert_select "td:last", text: "121" - end - - it "calls the chart library" do - render_component(data) - assert_select "script", text: /new Chartkick.["LineChart"]/ - end - - it "displays a heading" do - data[:chart_heading] = "hello" - render_component(data) - - assert_select "h2.gem-c-heading", text: "hello" - end - - it "displays a heading with a custom heading level" do - data[:chart_heading] = "hello" - data[:chart_heading_level] = 4 - render_component(data) - - assert_select "h4.gem-c-heading", text: "hello" - end - - it "can be rendered without a visible heading" do - data[:hide_heading] = true - render_component(data) - - assert_select "h2.gem-c-heading", false - end - - it "can include an overview" do - overview = "This chart shows a gradual decline in the numbers of hedgehogs using social media since 2008." - data[:chart_overview] = overview - render_component(data) - assert_select ".gem-c-chart__a11y-note-1", text: overview - assert_select ".gem-c-chart__a11y-note-2", text: "This chart is a visual representation of the data available in the table." - assert_select ".gem-c-chart__a11y-note-link a[href='#table-id-1234']", text: "Skip to \"Page views chart\" data table" - end - - it "includes an accessible caption for data tables" do - render_component(data) - assert_select "#data-table-caption-1234", text: "Data table for \"Page views chart\"" - end - - it "can include a download link" do - data[:link] = "https://www.gov.uk" - render_component(data) - - assert_select '.govuk-link[href="https://www.gov.uk"]', text: "Download chart data" - end - - it "can have a different bottom margin" do - data[:margin_bottom] = 0 - render_component(data) - - assert_select '.gem-c-chart.govuk-\!-margin-bottom-0' - end - - it "renders a minimal version" do - data[:minimal] = true - data[:link] = "https://should.not.be.shown" - data[:chart_overview] = "This is a chart showing a rise in sea levels in the last ten years" - render_component(data) - - assert_select ".gem-c-chart.gem-c-chart--minimal" - assert_select ".gem-c-chart__chart[aria-hidden='true']" - assert_select '.gem-c-chart .govuk-link[href="https://should.not.be.shown"]', false - assert_select ".gem-c-chart__chart .govuk-visually-hidden", false - end - - it "only calls an external script once" do - render_component(data) - data[:classes] = "" # need to 'reset' this otherwise it carries from the first component and breaks shared_helper - render_component(data) - - assert_select 'script[src="https://www.gstatic.com/charts/loader.js"]', count: 1 - end - - it "throws an error if a heading is not supplied" do - data[:chart_heading] = nil - expect { - render_component(data) - }.to raise_error("A chart heading must be provided for accessibility purposes.") - end - - it "does not throw an error if a heading is not supplied in minimal mode" do - data[:chart_heading] = nil - data[:minimal] = true - expect { - render_component(data) - }.not_to raise_error("A chart heading must be provided for accessibility purposes.") - end -end diff --git a/spec/lib/govuk_publishing_components/app_helpers/asset_helper_spec.rb b/spec/lib/govuk_publishing_components/app_helpers/asset_helper_spec.rb index b15434889a..d38e1441b8 100644 --- a/spec/lib/govuk_publishing_components/app_helpers/asset_helper_spec.rb +++ b/spec/lib/govuk_publishing_components/app_helpers/asset_helper_spec.rb @@ -19,7 +19,7 @@ def request end it "detect the total number of stylesheet paths" do - expect(get_component_css_paths.count).to eql(82) + expect(get_component_css_paths.count).to eql(81) end it "initialize empty asset helper" do diff --git a/spec/lib/govuk_publishing_components/components/chart_helper_spec.rb b/spec/lib/govuk_publishing_components/components/chart_helper_spec.rb deleted file mode 100644 index 1e04c87e34..0000000000 --- a/spec/lib/govuk_publishing_components/components/chart_helper_spec.rb +++ /dev/null @@ -1,183 +0,0 @@ -RSpec.describe GovukPublishingComponents::Presenters::ChartHelper do - describe "Chart component helper" do - required_params = {} - expected = {} - - before(:each) do - required_params = { - h_axis_title: "Day", - v_axis_title: "Views", - } - - expected = { - chartArea: { width: "80%", height: "60%" }, - crosshair: { orientation: "vertical", trigger: "both", color: "#ccc" }, - curveType: "none", - enableInteractivity: true, - legend: { - position: "top", - textStyle: { color: "#000", fontName: "GDS Transport", fontSize: "16", italic: false }, - }, - pointSize: 10, - height: 400, - tooltip: { isHtml: true }, - series: {}, - hAxis: { - textStyle: { color: "#000", fontName: "GDS Transport", fontSize: "16", italic: false }, - title: "Day", - titleTextStyle: { color: "#000", fontName: "GDS Transport", fontSize: "19", italic: false }, - textPosition: nil, - format: nil, - }, - vAxis: { - textStyle: { color: "#000", fontName: "GDS Transport", fontSize: "16", italic: false }, - title: "Views", - titleTextStyle: { color: "#000", fontName: "GDS Transport", fontSize: "19", italic: false }, - textPosition: nil, - format: nil, - viewWindow: { - min: 0, - }, - }, - } - end - - it "returns default chart options" do - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params) - options = chart_helper.chart_options - expect(options).to eql(expected) - end - - it "returns expected chart options when minimal is true" do - required_params[:minimal] = true - 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 - expect(options).to eql(expected) - end - - it "returns expected options when hide_legend is true" do - required_params[:hide_legend] = true - expected[:legend] = "none" - - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params) - options = chart_helper.chart_options - expect(options).to eql(expected) - end - - it "returns expected options when point size is changed" do - required_params[:point_size] = 1 - expected[:pointSize] = 1 - - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params) - options = chart_helper.chart_options - expect(options).to eql(expected) - end - - it "returns expected options when height is changed" do - required_params[:height] = 300 - expected[:height] = 300 - - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params) - options = chart_helper.chart_options - expect(options).to eql(expected) - end - - it "sets the y axis scale correctly" do - required_params[:y_axis_auto_adjust] = true - expected[:vAxis][:viewWindow][:min] = "auto" - - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params) - options = chart_helper.chart_options - expect(options).to eql(expected) - end - - it "formats passed data correctly" do - required_params[:rows] = [ - { - label: "January", - values: [1, 2, 3], - }, - { - label: "February", - values: [3, 4, 5], - }, - ] - required_params[:keys] = %w[1st 2nd 3rd] - expected = [ - { - data: [ - ["1st", 1], - ["2nd", 2], - ["3rd", 3], - ], - name: "January", - }, - { - data: [ - ["1st", 3], - ["2nd", 4], - ["3rd", 5], - ], - name: "February", - }, - ] - - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params) - data = chart_helper.chart_format_data - expect(data).to eql(expected) - end - - it "returns expected options when line colours and styles are changed" do - required_params[:line_colours] = %w[red blue] - required_params[:line_styles] = %w[normal dotted normal] - expected[:series] = { - 0 => { color: "red", lineDashStyle: nil }, - 1 => { color: "blue", lineDashStyle: [2, 2] }, - 2 => { lineDashStyle: nil }, - } - - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params) - options = chart_helper.chart_options - expect(options).to eql(expected) - end - - it "returns expected options when axis label format is changed to date" do - required_params[:h_axis_format] = "date" - required_params[:v_axis_format] = "date" - expected[:hAxis][:format] = "YYYY-MM-dd" - expected[:vAxis][:format] = "YYYY-MM-dd" - - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params) - options = chart_helper.chart_options - expect(options).to eql(expected) - end - - it "returns expected options when axis label format is changed to currency" do - required_params[:h_axis_format] = "currency" - required_params[:v_axis_format] = "currency" - expected[:hAxis][:format] = "£#" - expected[:vAxis][:format] = "£#" - - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params) - options = chart_helper.chart_options - expect(options).to eql(expected) - end - - it "returns expected options when axis label format is changed to percent" do - required_params[:h_axis_format] = "percent" - required_params[:v_axis_format] = "percent" - expected[:hAxis][:format] = "#'\%'" - expected[:vAxis][:format] = "#'\%'" - - chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(required_params) - options = chart_helper.chart_options - expect(options).to eql(expected) - end - end -end diff --git a/yarn.lock b/yarn.lock index d3c39b0747..fffd935f3d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -71,11 +71,6 @@ wrap-ansi "^8.1.0" wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" -"@kurkle/color@^0.3.0": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@kurkle/color/-/color-0.3.2.tgz#5acd38242e8bde4f9986e7913c8fdf49d3aa199f" - integrity sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw== - "@nodelib/fs.scandir@2.1.4": version "2.1.4" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69" @@ -558,27 +553,6 @@ chalk@^4.0.0, chalk@^4.0.2: ansi-styles "^4.1.0" supports-color "^7.1.0" -chart.js@4: - version "4.4.4" - resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-4.4.4.tgz#b682d2e7249f7a0cbb1b1d31c840266ae9db64b7" - integrity sha512-emICKGBABnxhMjUjlYRR12PmOXhJ2eJjEHL2/dZlWjxRAZT1D8xplLFq5M0tMQK8ja+wBS/tuVEJB5C6r7VxJA== - dependencies: - "@kurkle/color" "^0.3.0" - -chartjs-adapter-date-fns@>=3: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chartjs-adapter-date-fns/-/chartjs-adapter-date-fns-3.0.0.tgz#c25f63c7f317c1f96f9a7c44bd45eeedb8a478e5" - integrity sha512-Rs3iEB3Q5pJ973J93OBTpnP7qoGwvq3nUnoMdtxO+9aoJof7UFcRbWcIDteXuYd1fgAvct/32T9qaLyLuZVwCg== - -chartkick@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/chartkick/-/chartkick-5.0.1.tgz#f557ff8560f974343dc65c7fc34ce1e8326d8ee7" - integrity sha512-4F3tWI3eBQgnjCYZIZ+fHOaJuNyxeyhDE2Tm+voOWB19hDjSJceys/spzN52DOn8bWepNESGXvPVTGU1jeFsbA== - optionalDependencies: - chart.js "4" - chartjs-adapter-date-fns ">=3" - date-fns ">=2" - color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -687,11 +661,6 @@ cssesc@^3.0.0: resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee" integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== -date-fns@>=2: - version "4.1.0" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-4.1.0.tgz#64b3d83fff5aa80438f5b1a633c2e83b8a1c2d14" - integrity sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg== - debug@2.6.9, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"