@ons/design-system 72.6.0 → 72.9.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.
- package/components/breadcrumbs/_breadcrumbs.scss +1 -0
- package/components/chart/_chart.scss +10 -0
- package/components/chart/_macro.njk +50 -32
- package/components/chart/_macro.spec.js +201 -0
- package/components/chart/annotations-options.js +1 -1
- package/components/chart/area-chart.js +26 -0
- package/components/chart/bar-chart.js +11 -2
- package/components/chart/chart-constants.js +84 -3
- package/components/chart/chart.js +43 -10
- package/components/chart/column-chart.js +33 -24
- package/components/chart/common-chart-options.js +14 -35
- package/components/chart/example-area-chart.njk +68 -0
- package/components/chart/example-clustered-column-chart.njk +2 -1
- package/components/chart/example-column-chart-with-annotations.njk +2 -1
- package/components/chart/example-column-chart.njk +2 -1
- package/components/chart/example-column-with-line-chart.njk +5 -2
- package/components/chart/example-line-chart-with-markers.njk +138 -0
- package/components/chart/example-line-chart.njk +3 -1
- package/components/chart/example-scatter-chart.njk +94 -0
- package/components/chart/line-chart.js +18 -23
- package/components/chart/scatter-chart.js +34 -0
- package/components/details/details.js +5 -0
- package/components/details-panel/_details-panel.scss +107 -0
- package/components/details-panel/_macro.njk +41 -0
- package/components/details-panel/_macro.spec.js +54 -0
- package/components/details-panel/example-details-panel-open.njk +29 -0
- package/components/details-panel/example-details-panel.njk +28 -0
- package/components/hero/_hero.scss +87 -60
- package/components/hero/_macro.njk +1 -1
- package/components/hero/example-hero-dark.njk +1 -1
- package/components/pagination/_macro.njk +1 -1
- package/components/pagination/_pagination.scss +7 -7
- package/components/summary/_macro.njk +2 -2
- package/components/summary/_macro.spec.js +37 -21
- package/components/summary/_summary.scss +5 -1
- package/components/summary/example-summary-grouped.njk +0 -12
- package/css/main.css +1 -1
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/main.scss +1 -0
- package/scss/vars/_colors.scss +1 -0
|
@@ -78,3 +78,13 @@
|
|
|
78
78
|
.highcharts-axis-title {
|
|
79
79
|
width: 100%;
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
.highcharts-xaxis-labels span {
|
|
83
|
+
display: block !important;
|
|
84
|
+
white-space: nowrap !important;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Enforce cursor as auto in the legend
|
|
88
|
+
.highcharts-a11y-proxy-group-legend button {
|
|
89
|
+
cursor: auto !important;
|
|
90
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{% from "components/list/_macro.njk" import onsList %}
|
|
2
2
|
|
|
3
3
|
{% macro onsChart(params) %}
|
|
4
|
-
{% set supportedChartTypes = ['line', 'bar', 'column'] %}
|
|
4
|
+
{% set supportedChartTypes = ['line', 'bar', 'column', 'scatter', 'area'] %}
|
|
5
5
|
|
|
6
6
|
{% if params.headingLevel and params.headingLevel >= 1 and params.headingLevel <= 4 %}
|
|
7
7
|
{% set headingLevel = params.headingLevel %}
|
|
@@ -22,40 +22,53 @@
|
|
|
22
22
|
data-highcharts-title="{{ params.title }}"
|
|
23
23
|
data-highcharts-id="{{ params.id }}"
|
|
24
24
|
{% if params.useStackedLayout %}data-highcharts-use-stacked-layout="{{ params.useStackedLayout }}"{% endif %}
|
|
25
|
-
id="{{ params.id }}"
|
|
26
25
|
{% if params.percentageHeightDesktop and params.chartType != 'bar' %}
|
|
27
26
|
data-highcharts-percentage-height-desktop="{{ params.percentageHeightDesktop }}"
|
|
28
27
|
{% endif %}
|
|
29
28
|
{% if params.percentageHeightMobile and params.chartType != 'bar' %}
|
|
30
29
|
data-highcharts-percentage-height-mobile="{{ params.percentageHeightMobile }}"
|
|
31
30
|
{% endif %}
|
|
31
|
+
{% if params.xAxis.tickIntervalMobile %}
|
|
32
|
+
data-highcharts-x-axis-tick-interval-mobile="{{ params.xAxis.tickIntervalMobile }}"
|
|
33
|
+
{% endif %}
|
|
34
|
+
{% if params.xAxis.tickIntervalDesktop %}
|
|
35
|
+
data-highcharts-x-axis-tick-interval-desktop="{{ params.xAxis.tickIntervalDesktop }}"
|
|
36
|
+
{% endif %}
|
|
37
|
+
{% if params.yAxis.tickIntervalMobile %}
|
|
38
|
+
data-highcharts-y-axis-tick-interval-mobile="{{ params.yAxis.tickIntervalMobile }}"
|
|
39
|
+
{% endif %}
|
|
40
|
+
{% if params.yAxis.tickIntervalDesktop %}
|
|
41
|
+
data-highcharts-y-axis-tick-interval-desktop="{{ params.yAxis.tickIntervalDesktop }}"
|
|
42
|
+
{% endif %}
|
|
32
43
|
>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
<figure class="ons-chart">
|
|
45
|
+
{{ openingTitleTag | safe }} class="ons-chart__title">{{ params.title }}{{ closingTitleTag | safe }}
|
|
46
|
+
{{ openingSubtitleTag | safe }}
|
|
47
|
+
class="ons-chart__subtitle">{{ params.subtitle }}{{ closingSubtitleTag | safe }}
|
|
48
|
+
{% if params.description %}
|
|
49
|
+
<p class="ons-u-vh">{{ params.description }}</p>
|
|
50
|
+
{% endif %}
|
|
51
|
+
{% if params.chartType in supportedChartTypes %}
|
|
41
52
|
<div data-highcharts-chart></div>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
{% else %}
|
|
54
|
+
<p data-invalid-chart-type><b>Chart type "{{ params.chartType }}" is not supported</b></p>
|
|
55
|
+
{% endif %}
|
|
56
|
+
{#
|
|
57
|
+
Footnotes for the annotations at mobile
|
|
58
|
+
Hidden from screen readers because the full text will be read out where they appear in the chart
|
|
59
|
+
#}
|
|
60
|
+
<ul class="ons-chart__footnotes" aria-hidden="true">
|
|
61
|
+
{% for annotation in params.annotations %}
|
|
62
|
+
<li class="ons-chart__footnote_item">
|
|
63
|
+
<span class="ons-chart__footnote-number">{{ loop.index }}</span>
|
|
64
|
+
{{ annotation.text }}
|
|
65
|
+
</li>
|
|
66
|
+
{% endfor %}
|
|
67
|
+
</ul>
|
|
68
|
+
{% if params.caption %}
|
|
69
|
+
<figcaption class="ons-chart__caption">{{ params.caption }}</figcaption>
|
|
70
|
+
{% endif %}
|
|
71
|
+
</figure>
|
|
59
72
|
|
|
60
73
|
{% if params.download.title and params.download.itemsList | length > 0 %}
|
|
61
74
|
{{ openingDownloadTitleTag | safe }}
|
|
@@ -67,10 +80,11 @@
|
|
|
67
80
|
})
|
|
68
81
|
}}
|
|
69
82
|
{% endif %}
|
|
83
|
+
{% if params.chartType in supportedChartTypes %}
|
|
70
84
|
{% set series = [] %}
|
|
71
85
|
{% for item in params.series %}
|
|
72
86
|
{%
|
|
73
|
-
set
|
|
87
|
+
set seriesItem = {
|
|
74
88
|
"name": item.name if item.name else '',
|
|
75
89
|
"data": item.data if item.data else [],
|
|
76
90
|
"marker": {
|
|
@@ -79,9 +93,12 @@
|
|
|
79
93
|
"dataLabels": {
|
|
80
94
|
"enabled": item.dataLabels if item.dataLabels else false
|
|
81
95
|
},
|
|
96
|
+
"connectNulls": item.connectNulls if item.connectNulls else false,
|
|
82
97
|
"type": item.type if item.type and item.type == 'line' else params.chartType
|
|
83
|
-
}
|
|
98
|
+
}
|
|
84
99
|
%}
|
|
100
|
+
{# Use `set` tag to avoid printing the return value of extend #}
|
|
101
|
+
{% set _ = extend(series, seriesItem) %}
|
|
85
102
|
{% endfor %}
|
|
86
103
|
{%
|
|
87
104
|
set config = {
|
|
@@ -112,9 +129,10 @@
|
|
|
112
129
|
|
|
113
130
|
<!-- Set scripts to pass the config values as json to the javascript -->
|
|
114
131
|
<!-- prettier-ignore-start -->
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
132
|
+
<script type="application/json" data-highcharts-config--{{ params.id }}>
|
|
133
|
+
{{ config | tojson }}
|
|
134
|
+
</script>
|
|
135
|
+
{% endif %}
|
|
118
136
|
{% if params.annotations %}
|
|
119
137
|
<script type="application/json" data-highcharts-annotations--{{ params.id }}>
|
|
120
138
|
{{ params.annotations | tojson }}
|
|
@@ -15,6 +15,9 @@ import {
|
|
|
15
15
|
EXAMPLE_COLUMN_CHART_WITH_ANNOTATIONS_PARAMS,
|
|
16
16
|
EXAMPLE_BAR_WITH_LINE_CHART_PARAMS,
|
|
17
17
|
EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
|
|
18
|
+
EXAMPLE_SCATTER_CHART_PARAMS,
|
|
19
|
+
EXAMPLE_AREA_CHART_PARAMS,
|
|
20
|
+
EXAMPLE_INVALID_CHART_PARAMS,
|
|
18
21
|
} from './_test-examples';
|
|
19
22
|
|
|
20
23
|
describe('Macro: Chart', () => {
|
|
@@ -28,6 +31,10 @@ describe('Macro: Chart', () => {
|
|
|
28
31
|
expect(results).toHaveNoViolations();
|
|
29
32
|
});
|
|
30
33
|
|
|
34
|
+
test('THEN: it renders the title', () => {
|
|
35
|
+
expect($('.ons-chart__title').text()).toBe('Example Line Chart');
|
|
36
|
+
});
|
|
37
|
+
|
|
31
38
|
test('THEN: it renders the subtitle', () => {
|
|
32
39
|
expect($('.ons-chart__subtitle').text()).toBe('A sample subtitle');
|
|
33
40
|
});
|
|
@@ -96,6 +103,38 @@ describe('Macro: Chart', () => {
|
|
|
96
103
|
});
|
|
97
104
|
});
|
|
98
105
|
|
|
106
|
+
describe('GIVEN: Params: Tick Interval', () => {
|
|
107
|
+
describe('WHEN: tick interval is provided', () => {
|
|
108
|
+
const $ = cheerio.load(
|
|
109
|
+
renderComponent('chart', {
|
|
110
|
+
...EXAMPLE_LINE_CHART_REQUIRED_PARAMS,
|
|
111
|
+
xAxis: {
|
|
112
|
+
...EXAMPLE_LINE_CHART_REQUIRED_PARAMS.xAxis,
|
|
113
|
+
tickIntervalMobile: 2,
|
|
114
|
+
tickIntervalDesktop: 5,
|
|
115
|
+
},
|
|
116
|
+
}),
|
|
117
|
+
);
|
|
118
|
+
test('THEN: it includes the tick interval in the config', () => {
|
|
119
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-x-axis-tick-interval-mobile')).toBe('2');
|
|
120
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-x-axis-tick-interval-desktop')).toBe('5');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe('WHEN: tick interval is not provided', () => {
|
|
124
|
+
const $ = cheerio.load(
|
|
125
|
+
renderComponent('chart', {
|
|
126
|
+
...EXAMPLE_LINE_CHART_REQUIRED_PARAMS,
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
test('THEN: it does not include the tick interval in the config', () => {
|
|
130
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-x-axis-tick-interval-mobile')).toBe(undefined);
|
|
131
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-x-axis-tick-interval-desktop')).toBe(undefined);
|
|
132
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-y-axis-tick-interval-desktop')).toBe(undefined);
|
|
133
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-y-axis-tick-interval-mobile')).toBe(undefined);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
99
138
|
describe('GIVEN: Params: Config', () => {
|
|
100
139
|
describe('WHEN: config params are provided', () => {
|
|
101
140
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_CONFIG_PARAMS));
|
|
@@ -121,6 +160,9 @@ describe('Macro: Chart', () => {
|
|
|
121
160
|
expect(configScript).toContain('"data":[5,15,25]');
|
|
122
161
|
expect(configScript).toContain('"name":"Category 2"');
|
|
123
162
|
expect(configScript).toContain('"data":[10,20,30]');
|
|
163
|
+
expect(configScript).toContain('"connectNulls":true');
|
|
164
|
+
expect(configScript).toContain('"marker":{"enabled":true}');
|
|
165
|
+
expect(configScript).toContain('"dataLabels":{"enabled":true}');
|
|
124
166
|
});
|
|
125
167
|
});
|
|
126
168
|
});
|
|
@@ -822,4 +864,163 @@ describe('Macro: Chart', () => {
|
|
|
822
864
|
});
|
|
823
865
|
});
|
|
824
866
|
});
|
|
867
|
+
|
|
868
|
+
describe('FOR: Scatter chart', () => {
|
|
869
|
+
describe('GIVEN: Params: required', () => {
|
|
870
|
+
describe('WHEN: required params are provided', () => {
|
|
871
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_SCATTER_CHART_PARAMS));
|
|
872
|
+
|
|
873
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
874
|
+
const results = await axe($.html());
|
|
875
|
+
expect(results).toHaveNoViolations();
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
test('THEN: it renders the chart container with correct data attributes', () => {
|
|
879
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-type')).toBe('scatter');
|
|
880
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-theme')).toBe('primary');
|
|
881
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Scatter Chart');
|
|
882
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('scatter-chart-123');
|
|
883
|
+
});
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
describe('FOR: Area Chart', () => {
|
|
889
|
+
describe('GIVEN: Params: required', () => {
|
|
890
|
+
describe('WHEN: required params are provided', () => {
|
|
891
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_AREA_CHART_PARAMS));
|
|
892
|
+
const configScript = $(`script[data-highcharts-config--area-chart-123]`).html();
|
|
893
|
+
|
|
894
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
895
|
+
const results = await axe($.html());
|
|
896
|
+
expect(results).toHaveNoViolations();
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
test('THEN: it includes at least one area series', () => {
|
|
900
|
+
expect(configScript).toContain('"type":"area"');
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
test('THEN: it renders the chart container with correct data attributes', () => {
|
|
904
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-type')).toBe('area');
|
|
905
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-theme')).toBe('primary');
|
|
906
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Area Chart');
|
|
907
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('area-chart-123');
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
test('THEN: it includes the Highcharts JSON config', () => {
|
|
911
|
+
expect(configScript).toContain('"text":"X Axis Title"');
|
|
912
|
+
expect(configScript).toContain('"text":"Y Axis Title"');
|
|
913
|
+
});
|
|
914
|
+
});
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
describe('GIVEN: Params: Legend', () => {
|
|
918
|
+
describe('WHEN: legend is enabled', () => {
|
|
919
|
+
const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_AREA_CHART_PARAMS, legend: false }));
|
|
920
|
+
|
|
921
|
+
test('THEN: it renders the legend', () => {
|
|
922
|
+
const configScript = $(`script[data-highcharts-config--area-chart-123]`).html();
|
|
923
|
+
expect(configScript).toContain('"enabled":false');
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
});
|
|
927
|
+
|
|
928
|
+
describe('GIVEN: Params: Caption', () => {
|
|
929
|
+
describe('WHEN: caption is provided', () => {
|
|
930
|
+
const $ = cheerio.load(
|
|
931
|
+
renderComponent('chart', {
|
|
932
|
+
...EXAMPLE_AREA_CHART_PARAMS,
|
|
933
|
+
caption: 'This is an example caption for the chart.',
|
|
934
|
+
}),
|
|
935
|
+
);
|
|
936
|
+
|
|
937
|
+
test('THEN: it renders the caption when provided', () => {
|
|
938
|
+
expect($('figcaption').text()).toBe('This is an example caption for the chart.');
|
|
939
|
+
});
|
|
940
|
+
});
|
|
941
|
+
});
|
|
942
|
+
|
|
943
|
+
describe('GIVEN: Params: Description', () => {
|
|
944
|
+
describe('WHEN: description is provided', () => {
|
|
945
|
+
const $ = cheerio.load(
|
|
946
|
+
renderComponent('chart', {
|
|
947
|
+
...EXAMPLE_AREA_CHART_PARAMS,
|
|
948
|
+
description: 'An accessible description for screen readers.',
|
|
949
|
+
}),
|
|
950
|
+
);
|
|
951
|
+
|
|
952
|
+
test('THEN: it renders the description for accessibility', () => {
|
|
953
|
+
expect($('.ons-u-vh').text()).toBe('An accessible description for screen readers.');
|
|
954
|
+
});
|
|
955
|
+
});
|
|
956
|
+
});
|
|
957
|
+
|
|
958
|
+
describe('GIVEN: Params: Download', () => {
|
|
959
|
+
describe('WHEN: download object are provided', () => {
|
|
960
|
+
const $ = cheerio.load(
|
|
961
|
+
renderComponent('chart', {
|
|
962
|
+
...EXAMPLE_AREA_CHART_PARAMS,
|
|
963
|
+
download: {
|
|
964
|
+
title: 'Download Chart Data',
|
|
965
|
+
itemsList: [
|
|
966
|
+
{ text: 'Download as PNG', url: 'https://example.com/chart.png' },
|
|
967
|
+
{ text: 'Download as CSV', url: 'https://example.com/chart.csv' },
|
|
968
|
+
],
|
|
969
|
+
},
|
|
970
|
+
}),
|
|
971
|
+
);
|
|
972
|
+
|
|
973
|
+
test('THEN: it renders the download section correctly', () => {
|
|
974
|
+
expect($('.ons-chart__download-title').text()).toBe('Download Chart Data');
|
|
975
|
+
|
|
976
|
+
const downloadLinks = $('.ons-chart__download-title').next().find('li a');
|
|
977
|
+
expect(downloadLinks.eq(0).text()).toBe('Download as PNG');
|
|
978
|
+
expect(downloadLinks.eq(0).attr('href')).toBe('https://example.com/chart.png');
|
|
979
|
+
expect(downloadLinks.eq(1).text()).toBe('Download as CSV');
|
|
980
|
+
expect(downloadLinks.eq(1).attr('href')).toBe('https://example.com/chart.csv');
|
|
981
|
+
});
|
|
982
|
+
});
|
|
983
|
+
});
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
describe('FOR: Invalid Chart', () => {
|
|
987
|
+
describe('GIVEN: Invalid chart type', () => {
|
|
988
|
+
describe('WHEN: an invalid chart type is provided', () => {
|
|
989
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_INVALID_CHART_PARAMS));
|
|
990
|
+
|
|
991
|
+
test('THEN: it does not render the chart', () => {
|
|
992
|
+
expect($('[data-highcharts-chart]').length).toBe(0);
|
|
993
|
+
});
|
|
994
|
+
|
|
995
|
+
test('THEN: it renders the error message', () => {
|
|
996
|
+
expect($('[data-invalid-chart-type]').text()).toBe('Chart type "invalid" is not supported');
|
|
997
|
+
});
|
|
998
|
+
|
|
999
|
+
test('THEN: it does not include the Highcharts JSON config', () => {
|
|
1000
|
+
const configScript = $(`script[data-highcharts-config--invalid-chart-123]`).html();
|
|
1001
|
+
expect(configScript).toBeNull();
|
|
1002
|
+
});
|
|
1003
|
+
|
|
1004
|
+
test('THEN: it still renders the title', () => {
|
|
1005
|
+
expect($('.ons-chart__title').text()).toBe('Example Invalid Chart');
|
|
1006
|
+
});
|
|
1007
|
+
|
|
1008
|
+
test('THEN: it still renders the subtitle', () => {
|
|
1009
|
+
expect($('.ons-chart__subtitle').text()).toBe('A sample subtitle');
|
|
1010
|
+
});
|
|
1011
|
+
|
|
1012
|
+
test('THEN: it still renders the description', () => {
|
|
1013
|
+
expect($('.ons-u-vh').text()).toBe('A detailed description');
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
test('THEN: it still renders the caption', () => {
|
|
1017
|
+
expect($('figcaption').text()).toBe('A detailed caption');
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
test('THEN: it still renders the download', () => {
|
|
1021
|
+
expect($('.ons-chart__download-title').text()).toBe('Download this chart');
|
|
1022
|
+
});
|
|
1023
|
+
});
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
825
1026
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class AreaChart {
|
|
2
|
+
getAreaChartOptions = () => {
|
|
3
|
+
return {
|
|
4
|
+
legend: {
|
|
5
|
+
symbolWidth: 12,
|
|
6
|
+
symbolHeight: 12,
|
|
7
|
+
},
|
|
8
|
+
plotOptions: {
|
|
9
|
+
area: {
|
|
10
|
+
fillOpacity: 1,
|
|
11
|
+
// Use a circle instead of the default blob plus line icon
|
|
12
|
+
// 'rectangle' counterintuitively gives a circle, because the legend icon has a border radius of half it's height by default
|
|
13
|
+
legendSymbol: 'rectangle',
|
|
14
|
+
stacking: 'normal',
|
|
15
|
+
},
|
|
16
|
+
series: {
|
|
17
|
+
marker: {
|
|
18
|
+
enabled: false,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default AreaChart;
|
|
@@ -26,7 +26,7 @@ class BarChart {
|
|
|
26
26
|
// The design system does not include a semibold font weight, so we use 700 (bold) as an alternative.
|
|
27
27
|
fontWeight: '700',
|
|
28
28
|
color: this.constants.labelColor,
|
|
29
|
-
fontSize: this.constants.
|
|
29
|
+
fontSize: this.constants.defaultFontSize,
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
},
|
|
@@ -40,6 +40,7 @@ class BarChart {
|
|
|
40
40
|
style: {
|
|
41
41
|
color: this.constants.categoryLabelColor,
|
|
42
42
|
},
|
|
43
|
+
useHTML: false,
|
|
43
44
|
},
|
|
44
45
|
// remove the tick marks for bar charts
|
|
45
46
|
tickWidth: 0,
|
|
@@ -48,6 +49,14 @@ class BarChart {
|
|
|
48
49
|
title: { align: 'high', textAlign: 'middle', reserveSpace: false, rotation: 0, y: -25, useHTML: true },
|
|
49
50
|
},
|
|
50
51
|
yAxis: {
|
|
52
|
+
labels: {
|
|
53
|
+
rotation: 0,
|
|
54
|
+
useHTML: true,
|
|
55
|
+
style: {
|
|
56
|
+
whiteSpace: 'nowrap',
|
|
57
|
+
color: this.constants.categoryLabelColor,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
51
60
|
title: {
|
|
52
61
|
// Override the y Axis title settings for bar charts where the y axis is horizontal
|
|
53
62
|
textAlign: 'right',
|
|
@@ -110,7 +119,7 @@ class BarChart {
|
|
|
110
119
|
// The design system does not include a semibold font weight, so we use 700 (bold) as an alternative.
|
|
111
120
|
fontWeight: '700',
|
|
112
121
|
color: this.constants.labelColor,
|
|
113
|
-
fontSize: this.constants.
|
|
122
|
+
fontSize: this.constants.defaultFontSize,
|
|
114
123
|
},
|
|
115
124
|
});
|
|
116
125
|
|
|
@@ -9,9 +9,90 @@ class ChartConstants {
|
|
|
9
9
|
categoryLabelColor: '#414042',
|
|
10
10
|
gridLineColor: '#d9d9d9',
|
|
11
11
|
zeroLineColor: '#b3b3b3',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
defaultFontSize: '0.875rem', // 14px
|
|
13
|
+
lineMarkerStyles: [
|
|
14
|
+
{
|
|
15
|
+
radius: 4,
|
|
16
|
+
symbol: 'circle',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
radius: 4,
|
|
20
|
+
symbol: 'square',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
radius: 5,
|
|
24
|
+
symbol: 'diamond',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
radius: 5,
|
|
28
|
+
symbol: 'triangle',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
radius: 5,
|
|
32
|
+
symbol: 'triangle-down',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
radius: 4,
|
|
36
|
+
symbol: 'circle',
|
|
37
|
+
fillColor: 'white',
|
|
38
|
+
lineWidth: 2.5,
|
|
39
|
+
lineColor: null,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
radius: 4,
|
|
43
|
+
symbol: 'square',
|
|
44
|
+
fillColor: 'white',
|
|
45
|
+
lineWidth: 2.5,
|
|
46
|
+
lineColor: null,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
radius: 5,
|
|
50
|
+
symbol: 'diamond',
|
|
51
|
+
fillColor: 'white',
|
|
52
|
+
lineWidth: 2.5,
|
|
53
|
+
lineColor: null,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
radius: 5,
|
|
57
|
+
symbol: 'triangle',
|
|
58
|
+
fillColor: 'white',
|
|
59
|
+
lineWidth: 2.5,
|
|
60
|
+
lineColor: null,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
radius: 5,
|
|
64
|
+
symbol: 'triangle-down',
|
|
65
|
+
fillColor: 'white',
|
|
66
|
+
lineWidth: 2.5,
|
|
67
|
+
lineColor: null,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
scatterMarkerStyles: [
|
|
71
|
+
{
|
|
72
|
+
radius: 5,
|
|
73
|
+
symbol: 'circle',
|
|
74
|
+
lineWidth: 1,
|
|
75
|
+
lineColor: '#ffffff',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
radius: 5,
|
|
79
|
+
symbol: 'square',
|
|
80
|
+
lineWidth: 1,
|
|
81
|
+
lineColor: '#ffffff',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
radius: 6,
|
|
85
|
+
symbol: 'diamond',
|
|
86
|
+
lineWidth: 1,
|
|
87
|
+
lineColor: '#ffffff',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
radius: 6,
|
|
91
|
+
symbol: 'triangle',
|
|
92
|
+
lineWidth: 1,
|
|
93
|
+
lineColor: '#ffffff',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
15
96
|
};
|
|
16
97
|
|
|
17
98
|
return constants;
|