govuk_publishing_components 66.6.1 → 66.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/chart.js +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/all-components.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_attachment.scss +8 -11
- data/app/assets/stylesheets/govuk_publishing_components/components/_chart.scss +60 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +3 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/mixins/_high-contrast-outline.scss +8 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/mixins/_index.scss +1 -0
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +1 -0
- data/app/views/govuk_publishing_components/components/_chart.html.erb +131 -0
- data/app/views/govuk_publishing_components/components/_service_navigation.html.erb +5 -3
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_tabs.html.erb +4 -4
- data/app/views/govuk_publishing_components/components/docs/chart.yml +425 -0
- data/app/views/govuk_publishing_components/components/docs/service_navigation.yml +11 -0
- data/app/views/govuk_publishing_components/components/docs/tabs.yml +8 -7
- data/config/locales/ar.yml +8 -0
- data/config/locales/az.yml +8 -0
- data/config/locales/be.yml +8 -0
- data/config/locales/bg.yml +8 -0
- data/config/locales/bn.yml +8 -0
- data/config/locales/cs.yml +8 -0
- data/config/locales/cy.yml +8 -0
- data/config/locales/da.yml +8 -0
- data/config/locales/de.yml +8 -0
- data/config/locales/dr.yml +8 -0
- data/config/locales/el.yml +8 -0
- data/config/locales/en.yml +8 -0
- data/config/locales/es-419.yml +8 -0
- data/config/locales/es.yml +8 -0
- data/config/locales/et.yml +8 -0
- data/config/locales/fa.yml +8 -0
- data/config/locales/fi.yml +8 -0
- data/config/locales/fr.yml +8 -0
- data/config/locales/gd.yml +8 -0
- data/config/locales/gu.yml +8 -0
- data/config/locales/he.yml +8 -0
- data/config/locales/hi.yml +8 -0
- data/config/locales/hr.yml +8 -0
- data/config/locales/hu.yml +8 -0
- data/config/locales/hy.yml +8 -0
- data/config/locales/id.yml +8 -0
- data/config/locales/is.yml +8 -0
- data/config/locales/it.yml +8 -0
- data/config/locales/ja.yml +8 -0
- data/config/locales/ka.yml +8 -0
- data/config/locales/kk.yml +8 -0
- data/config/locales/ko.yml +8 -0
- data/config/locales/ku.yml +8 -0
- data/config/locales/ky.yml +8 -0
- data/config/locales/lt.yml +8 -0
- data/config/locales/lv.yml +8 -0
- data/config/locales/ms.yml +8 -0
- data/config/locales/mt.yml +8 -0
- data/config/locales/ne.yml +8 -0
- data/config/locales/nl.yml +8 -0
- data/config/locales/no.yml +8 -0
- data/config/locales/pa-pk.yml +8 -0
- data/config/locales/pa.yml +8 -0
- data/config/locales/pl.yml +8 -0
- data/config/locales/ps.yml +8 -0
- data/config/locales/pt.yml +8 -0
- data/config/locales/ro.yml +8 -0
- data/config/locales/ru.yml +8 -0
- data/config/locales/si.yml +8 -0
- data/config/locales/sk.yml +8 -0
- data/config/locales/sl.yml +8 -0
- data/config/locales/so.yml +8 -0
- data/config/locales/sq.yml +8 -0
- data/config/locales/sr.yml +8 -0
- data/config/locales/sv.yml +8 -0
- data/config/locales/sw.yml +8 -0
- data/config/locales/ta.yml +8 -0
- data/config/locales/th.yml +8 -0
- data/config/locales/ti.yml +8 -0
- data/config/locales/tk.yml +8 -0
- data/config/locales/tr.yml +8 -0
- data/config/locales/uk.yml +8 -0
- data/config/locales/ur.yml +8 -0
- data/config/locales/uz.yml +8 -0
- data/config/locales/vi.yml +8 -0
- data/config/locales/zh-hk.yml +8 -0
- data/config/locales/zh-tw.yml +8 -0
- data/config/locales/zh.yml +8 -0
- data/lib/govuk_publishing_components/presenters/chart_helper.rb +123 -0
- data/lib/govuk_publishing_components/presenters/select_helper.rb +3 -3
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +1 -0
- data/node_modules/chartkick/LICENSE.txt +22 -0
- data/node_modules/chartkick/README.md +593 -0
- data/node_modules/chartkick/chart.js/chart.esm.js +5 -0
- data/node_modules/chartkick/chart.js/package.json +6 -0
- data/node_modules/chartkick/dist/chartkick.esm.js +2562 -0
- data/node_modules/chartkick/dist/chartkick.js +2570 -0
- data/node_modules/chartkick/dist/chartkick.min.js +2 -0
- data/node_modules/chartkick/highcharts/highcharts.esm.js +4 -0
- data/node_modules/chartkick/highcharts/package.json +6 -0
- data/node_modules/chartkick/package.json +50 -0
- metadata +18 -2
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
module GovukPublishingComponents
|
|
2
|
+
module Presenters
|
|
3
|
+
class ChartHelper
|
|
4
|
+
def initialize(options)
|
|
5
|
+
@rows = options[:rows]
|
|
6
|
+
@keys = options[:keys]
|
|
7
|
+
@enable_interactivity = true
|
|
8
|
+
@hide_legend = options[:hide_legend]
|
|
9
|
+
if @rows && (@rows.length > 1)
|
|
10
|
+
@hide_legend = false
|
|
11
|
+
end
|
|
12
|
+
@point_size = 8
|
|
13
|
+
@height = options[:height] || 400
|
|
14
|
+
@h_axis_title = options[:h_axis_title]
|
|
15
|
+
@v_axis_title = options[:v_axis_title]
|
|
16
|
+
@y_axis_view_window_min = 0
|
|
17
|
+
@y_axis_view_window_min = "auto" if options[:y_axis_auto_adjust]
|
|
18
|
+
@line_colours = options[:line_colours]
|
|
19
|
+
@line_styles = options[:line_styles]
|
|
20
|
+
|
|
21
|
+
@h_axis_format = "YYYY-MM-dd" if options[:h_axis_format] == "date"
|
|
22
|
+
@h_axis_format = "£#" if options[:h_axis_format] == "currency"
|
|
23
|
+
@h_axis_format = "#'\%'" if options[:h_axis_format] == "percent"
|
|
24
|
+
|
|
25
|
+
@v_axis_format = "YYYY-MM-dd" if options[:v_axis_format] == "date"
|
|
26
|
+
@v_axis_format = "£#" if options[:v_axis_format] == "currency"
|
|
27
|
+
@v_axis_format = "#'\%'" if options[:v_axis_format] == "percent"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# config options are here: https://developers.google.com/chart/interactive/docs/gallery/linechart
|
|
31
|
+
def chart_options
|
|
32
|
+
{
|
|
33
|
+
chartArea: { width: "80%", height: "60%" },
|
|
34
|
+
crosshair: { orientation: "vertical", trigger: "both", color: "#ccc" },
|
|
35
|
+
curveType: "none",
|
|
36
|
+
enableInteractivity: @enable_interactivity,
|
|
37
|
+
legend: legend_options,
|
|
38
|
+
pointSize: @point_size,
|
|
39
|
+
height: @height,
|
|
40
|
+
tooltip: { isHtml: true },
|
|
41
|
+
series: series_options,
|
|
42
|
+
hAxis: {
|
|
43
|
+
textStyle: set_font_16,
|
|
44
|
+
title: @h_axis_title,
|
|
45
|
+
titleTextStyle: set_font_19,
|
|
46
|
+
format: @h_axis_format,
|
|
47
|
+
},
|
|
48
|
+
vAxis: {
|
|
49
|
+
textStyle: set_font_16,
|
|
50
|
+
title: @v_axis_title,
|
|
51
|
+
titleTextStyle: set_font_19,
|
|
52
|
+
format: @v_axis_format,
|
|
53
|
+
viewWindow: {
|
|
54
|
+
min: @y_axis_view_window_min,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def brand_colours
|
|
61
|
+
# The following accessible colour palette has been developed to meet the colour contrast requirements for adjacent colours (as set out in WCAG 2.1)
|
|
62
|
+
# For charts, the palette should be used instead of the GOV.UK colour palette - https://design-system.service.gov.uk/styles/colour/
|
|
63
|
+
# https://gss.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/#section-5
|
|
64
|
+
|
|
65
|
+
gss_colour_dark_blue = "#12436d"
|
|
66
|
+
gss_colour_turquoise = "#1bbbaf"
|
|
67
|
+
gss_colour_dark_pink = "#801650"
|
|
68
|
+
gss_colour_orange = "#f46a25"
|
|
69
|
+
gss_colour_dark_grey = "#3d3d3d"
|
|
70
|
+
gss_colour_plum = "#a285d1"
|
|
71
|
+
|
|
72
|
+
[gss_colour_dark_blue, gss_colour_turquoise, gss_colour_dark_pink, gss_colour_orange, gss_colour_dark_grey, gss_colour_plum]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def chart_format_data
|
|
76
|
+
if !@rows.empty? && !@keys.empty?
|
|
77
|
+
@rows.map do |row|
|
|
78
|
+
{
|
|
79
|
+
name: row[:label],
|
|
80
|
+
data: @keys.zip(row[:values]),
|
|
81
|
+
}
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
private
|
|
87
|
+
|
|
88
|
+
def legend_options
|
|
89
|
+
return { position: "top", textStyle: set_font_16 } unless @hide_legend
|
|
90
|
+
|
|
91
|
+
"none"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def set_font_16
|
|
95
|
+
{ color: "#000", fontName: "GDS Transport", fontSize: "16", italic: false }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def set_font_19
|
|
99
|
+
{ color: "#000", fontName: "GDS Transport", fontSize: "19", italic: false }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def series_options
|
|
103
|
+
series = {}
|
|
104
|
+
if @line_colours
|
|
105
|
+
@line_colours.each_with_index do |item, index|
|
|
106
|
+
series[index] = {} unless series[index]
|
|
107
|
+
series[index][:color] = item
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if @line_styles
|
|
112
|
+
@line_styles.each_with_index do |item, index|
|
|
113
|
+
style = [2, 2] if item == "dotted"
|
|
114
|
+
series[index] = {} unless series[index]
|
|
115
|
+
series[index][:lineDashStyle] = style
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
series
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -3,7 +3,7 @@ module GovukPublishingComponents
|
|
|
3
3
|
class SelectHelper
|
|
4
4
|
include ActionView::Helpers::FormOptionsHelper
|
|
5
5
|
|
|
6
|
-
attr_reader :
|
|
6
|
+
attr_reader :options_markup, :error_items, :error_id, :hint, :hint_id, :describedby
|
|
7
7
|
|
|
8
8
|
def initialize(local_assigns)
|
|
9
9
|
@options = local_assigns[:options] || []
|
|
@@ -40,9 +40,9 @@ module GovukPublishingComponents
|
|
|
40
40
|
private
|
|
41
41
|
|
|
42
42
|
def get_options
|
|
43
|
-
return if options.nil?
|
|
43
|
+
return if @options.nil?
|
|
44
44
|
|
|
45
|
-
options.map do |option|
|
|
45
|
+
@options.map do |option|
|
|
46
46
|
@selected_option = option[:value] if option[:selected]
|
|
47
47
|
[
|
|
48
48
|
option[:text],
|
|
@@ -14,6 +14,7 @@ require "govuk_publishing_components/presenters/big_number_helper"
|
|
|
14
14
|
require "govuk_publishing_components/presenters/breadcrumbs_helper"
|
|
15
15
|
require "govuk_publishing_components/presenters/breadcrumb_selector"
|
|
16
16
|
require "govuk_publishing_components/presenters/button_helper"
|
|
17
|
+
require "govuk_publishing_components/presenters/chart_helper"
|
|
17
18
|
require "govuk_publishing_components/presenters/contextual_navigation"
|
|
18
19
|
require "govuk_publishing_components/presenters/devolved_nations_helper"
|
|
19
20
|
require "govuk_publishing_components/presenters/emergency_banner_helper"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013-2023 Andrew Kane
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|