@ons/design-system 72.8.0 → 72.9.1

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.
@@ -5,7 +5,7 @@
5
5
  {% set placeholderSrcset = (params.image.placeholderUrl if params.image.placeholderUrl else "") + "/img/small/placeholder-card.png 1x, " + (params.image.placeholderUrl if params.image.placeholderUrl else "") + "/img/large/placeholder-card.png 2x" %}
6
6
 
7
7
  <div class="ons-card {% if params.variant == "feature" %}ons-card--feature ons-u-flex-grow{% endif %}">
8
- <a href="{{ params.title.url }}" class="ons-card__link {% if params.title.subtitle %}ons-u-mb-xs{% endif %}">
8
+ {% set imageBlock %}
9
9
  {%- if params.image -%}
10
10
  {% if params.image.smallSrc %}
11
11
  <img
@@ -29,10 +29,23 @@
29
29
  />
30
30
  {% endif %}
31
31
  {%- endif -%}
32
+ {% endset %}
33
+
34
+ {% set titleBlock %}
32
35
  {{ openingHeadingTag | safe }}
33
36
  class="ons-card__title {{ params.title.classes | default('ons-u-fs-m') }}" id="{{ params.title.id }}"> {{ params.title.text }}
34
37
  {{ closingHeadingTag | safe }}
35
- </a>
38
+ {% endset %}
39
+
40
+ {% if params.title.url %}
41
+ <a href="{{ params.title.url }}" class="ons-card__link {% if params.title.subtitle %}ons-u-mb-xs{% endif %}">
42
+ {{ imageBlock | safe }}
43
+ {{ titleBlock | safe }}
44
+ </a>
45
+ {% else %}
46
+ {{ imageBlock | safe }}
47
+ {{ titleBlock | safe }}
48
+ {% endif %}
36
49
 
37
50
  {% if params.title.subtitle %}
38
51
  <p class="ons-card__subtitle ons-u-fs-s">{{ params.title.subtitle }}</p>
@@ -9,7 +9,6 @@
9
9
  "title": {
10
10
  "id": 'card-set-1',
11
11
  "text": 'Deaths registered annually',
12
- "url": '#0',
13
12
  "subtitle": 'England and Wales'
14
13
  },
15
14
  "body":{
@@ -28,7 +27,6 @@
28
27
  "title": {
29
28
  "id": 'card-set-2',
30
29
  "text": 'Alcohol-specific deaths',
31
- "url": '#0',
32
30
  "subtitle": 'UK'
33
31
  },
34
32
  "body":{
@@ -47,8 +45,7 @@
47
45
  "title": {
48
46
  "id": 'card-set-3',
49
47
  "text": 'Suicides registered',
50
- "subtitle": 'England and Wales',
51
- "url": '#0'
48
+ "subtitle": 'England and Wales'
52
49
  },
53
50
  "body":{
54
51
  "id": 'text3',
@@ -83,3 +83,8 @@
83
83
  display: block !important;
84
84
  white-space: nowrap !important;
85
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,8 @@
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
+ {% set supportedChartTypesWithLine = ['column'] %}
5
6
 
6
7
  {% if params.headingLevel and params.headingLevel >= 1 and params.headingLevel <= 4 %}
7
8
  {% set headingLevel = params.headingLevel %}
@@ -22,7 +23,6 @@
22
23
  data-highcharts-title="{{ params.title }}"
23
24
  data-highcharts-id="{{ params.id }}"
24
25
  {% if params.useStackedLayout %}data-highcharts-use-stacked-layout="{{ params.useStackedLayout }}"{% endif %}
25
- id="{{ params.id }}"
26
26
  {% if params.percentageHeightDesktop and params.chartType != 'bar' %}
27
27
  data-highcharts-percentage-height-desktop="{{ params.percentageHeightDesktop }}"
28
28
  {% endif %}
@@ -42,32 +42,34 @@
42
42
  data-highcharts-y-axis-tick-interval-desktop="{{ params.yAxis.tickIntervalDesktop }}"
43
43
  {% endif %}
44
44
  >
45
- {% if params.chartType in supportedChartTypes %}
46
- <figure class="ons-chart">
47
- {{ openingTitleTag | safe }} class="ons-chart__title">{{ params.title }}{{ closingTitleTag | safe }}
48
- {{ openingSubtitleTag | safe }}
49
- class="ons-chart__subtitle">{{ params.subtitle }}{{ closingSubtitleTag | safe }}
50
- {% if params.description %}
51
- <p class="ons-u-vh">{{ params.description }}</p>
52
- {% endif %}
45
+ <figure class="ons-chart">
46
+ {{ openingTitleTag | safe }} class="ons-chart__title">{{ params.title }}{{ closingTitleTag | safe }}
47
+ {{ openingSubtitleTag | safe }}
48
+ class="ons-chart__subtitle">{{ params.subtitle }}{{ closingSubtitleTag | safe }}
49
+ {% if params.description %}
50
+ <p class="ons-u-vh">{{ params.description }}</p>
51
+ {% endif %}
52
+ {% if params.chartType in supportedChartTypes %}
53
53
  <div data-highcharts-chart></div>
54
- {#
55
- Footnotes for the annotations at mobile
56
- Hidden from screen readers because the full text will be read out where they appear in the chart
57
- #}
58
- <ul class="ons-chart__footnotes" aria-hidden="true">
59
- {% for annotation in params.annotations %}
60
- <li class="ons-chart__footnote_item">
61
- <span class="ons-chart__footnote-number">{{ loop.index }}</span>
62
- {{ annotation.text }}
63
- </li>
64
- {% endfor %}
65
- </ul>
66
- {% if params.caption %}
67
- <figcaption class="ons-chart__caption">{{ params.caption }}</figcaption>
68
- {% endif %}
69
- </figure>
70
- {% endif %}
54
+ {% else %}
55
+ <p data-invalid-chart-type><b>Chart type "{{ params.chartType }}" is not supported</b></p>
56
+ {% endif %}
57
+ {#
58
+ Footnotes for the annotations at mobile
59
+ Hidden from screen readers because the full text will be read out where they appear in the chart
60
+ #}
61
+ <ul class="ons-chart__footnotes" aria-hidden="true">
62
+ {% for annotation in params.annotations %}
63
+ <li class="ons-chart__footnote_item">
64
+ <span class="ons-chart__footnote-number">{{ loop.index }}</span>
65
+ {{ annotation.text }}
66
+ </li>
67
+ {% endfor %}
68
+ </ul>
69
+ {% if params.caption %}
70
+ <figcaption class="ons-chart__caption">{{ params.caption }}</figcaption>
71
+ {% endif %}
72
+ </figure>
71
73
 
72
74
  {% if params.download.title and params.download.itemsList | length > 0 %}
73
75
  {{ openingDownloadTitleTag | safe }}
@@ -79,6 +81,7 @@
79
81
  })
80
82
  }}
81
83
  {% endif %}
84
+ {% if params.chartType in supportedChartTypes %}
82
85
  {% set series = [] %}
83
86
  {% for item in params.series %}
84
87
  {%
@@ -91,7 +94,8 @@
91
94
  "dataLabels": {
92
95
  "enabled": item.dataLabels if item.dataLabels else false
93
96
  },
94
- "type": item.type if item.type and item.type == 'line' else params.chartType
97
+ "connectNulls": item.connectNulls if item.connectNulls else false,
98
+ "type": item.type if item.type and item.type == 'line' and params.chartType in supportedChartTypesWithLine else params.chartType
95
99
  }
96
100
  %}
97
101
  {# Use `set` tag to avoid printing the return value of extend #}
@@ -126,9 +130,10 @@
126
130
 
127
131
  <!-- Set scripts to pass the config values as json to the javascript -->
128
132
  <!-- prettier-ignore-start -->
129
- <script type="application/json" data-highcharts-config--{{ params.id }}>
130
- {{ config | tojson }}
131
- </script>
133
+ <script type="application/json" data-highcharts-config--{{ params.id }}>
134
+ {{ config | tojson }}
135
+ </script>
136
+ {% endif %}
132
137
  {% if params.annotations %}
133
138
  <script type="application/json" data-highcharts-annotations--{{ params.id }}>
134
139
  {{ params.annotations | tojson }}
@@ -13,8 +13,10 @@ import {
13
13
  EXAMPLE_LINE_CHART_WITH_ANNOTATIONS_PARAMS,
14
14
  EXAMPLE_BAR_CHART_WITH_ANNOTATIONS_PARAMS,
15
15
  EXAMPLE_COLUMN_CHART_WITH_ANNOTATIONS_PARAMS,
16
- EXAMPLE_BAR_WITH_LINE_CHART_PARAMS,
17
16
  EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
17
+ EXAMPLE_SCATTER_CHART_PARAMS,
18
+ EXAMPLE_AREA_CHART_PARAMS,
19
+ EXAMPLE_INVALID_CHART_PARAMS,
18
20
  } from './_test-examples';
19
21
 
20
22
  describe('Macro: Chart', () => {
@@ -28,6 +30,10 @@ describe('Macro: Chart', () => {
28
30
  expect(results).toHaveNoViolations();
29
31
  });
30
32
 
33
+ test('THEN: it renders the title', () => {
34
+ expect($('.ons-chart__title').text()).toBe('Example Line Chart');
35
+ });
36
+
31
37
  test('THEN: it renders the subtitle', () => {
32
38
  expect($('.ons-chart__subtitle').text()).toBe('A sample subtitle');
33
39
  });
@@ -153,6 +159,9 @@ describe('Macro: Chart', () => {
153
159
  expect(configScript).toContain('"data":[5,15,25]');
154
160
  expect(configScript).toContain('"name":"Category 2"');
155
161
  expect(configScript).toContain('"data":[10,20,30]');
162
+ expect(configScript).toContain('"connectNulls":true');
163
+ expect(configScript).toContain('"marker":{"enabled":true}');
164
+ expect(configScript).toContain('"dataLabels":{"enabled":true}');
156
165
  });
157
166
  });
158
167
  });
@@ -615,27 +624,27 @@ describe('Macro: Chart', () => {
615
624
  });
616
625
  });
617
626
 
618
- describe('FOR: Bar Chart with Line', () => {
627
+ describe('FOR: Column Chart with Line', () => {
619
628
  describe('GIVEN: Params: required', () => {
620
629
  describe('WHEN: required params are provided', () => {
621
- const $ = cheerio.load(renderComponent('chart', EXAMPLE_BAR_WITH_LINE_CHART_PARAMS));
622
- const configScript = $(`script[data-highcharts-config--bar-chart-123]`).html();
630
+ const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS));
631
+ const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
623
632
 
624
633
  test('THEN: it passes jest-axe checks', async () => {
625
634
  const results = await axe($.html());
626
635
  expect(results).toHaveNoViolations();
627
636
  });
628
637
 
629
- test('THEN: it includes one series of type "bar" and another of type "line"', () => {
630
- expect(configScript).toContain('"type":"bar"');
638
+ test('THEN: it includes one series of type "column" and another of type "line"', () => {
639
+ expect(configScript).toContain('"type":"column"');
631
640
  expect(configScript).toContain('"type":"line"');
632
641
  });
633
642
 
634
643
  test('THEN: it renders the chart container with correct data attributes', () => {
635
- expect($('[data-highcharts-base-chart]').attr('data-highcharts-type')).toBe('bar');
644
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-type')).toBe('column');
636
645
  expect($('[data-highcharts-base-chart]').attr('data-highcharts-theme')).toBe('alternate');
637
- expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Bar Chart');
638
- expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('bar-chart-123');
646
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Column Chart');
647
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('column-chart-123');
639
648
  });
640
649
 
641
650
  test('THEN: it includes the Highcharts JSON config', () => {
@@ -647,10 +656,10 @@ describe('Macro: Chart', () => {
647
656
 
648
657
  describe('GIVEN: Params: Legend', () => {
649
658
  describe('WHEN: legend is enabled', () => {
650
- const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_BAR_WITH_LINE_CHART_PARAMS, legend: false }));
659
+ const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS, legend: false }));
651
660
 
652
661
  test('THEN: it renders the legend', () => {
653
- const configScript = $(`script[data-highcharts-config--bar-chart-123]`).html();
662
+ const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
654
663
  expect(configScript).toContain('"enabled":false');
655
664
  });
656
665
  });
@@ -660,7 +669,7 @@ describe('Macro: Chart', () => {
660
669
  describe('WHEN: caption is provided', () => {
661
670
  const $ = cheerio.load(
662
671
  renderComponent('chart', {
663
- ...EXAMPLE_BAR_WITH_LINE_CHART_PARAMS,
672
+ ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
664
673
  caption: 'This is an example caption for the chart.',
665
674
  }),
666
675
  );
@@ -675,7 +684,7 @@ describe('Macro: Chart', () => {
675
684
  describe('WHEN: description is provided', () => {
676
685
  const $ = cheerio.load(
677
686
  renderComponent('chart', {
678
- ...EXAMPLE_BAR_WITH_LINE_CHART_PARAMS,
687
+ ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
679
688
  description: 'An accessible description for screen readers.',
680
689
  }),
681
690
  );
@@ -686,32 +695,11 @@ describe('Macro: Chart', () => {
686
695
  });
687
696
  });
688
697
 
689
- describe('GIVEN: Params: Series: Type', () => {
690
- describe('WHEN: a series has an invalid type', () => {
691
- const invalidTypeParams = {
692
- ...EXAMPLE_BAR_WITH_LINE_CHART_PARAMS,
693
- series: [
694
- { name: 'Invalid Series', data: [5, 15, 25], type: 'scatter' },
695
- { name: 'Valid Line Series', data: [10, 20, 30], type: 'line' },
696
- ],
697
- };
698
-
699
- const $ = cheerio.load(renderComponent('chart', invalidTypeParams));
700
- const configScript = $(`script[data-highcharts-config--bar-chart-123]`).html();
701
-
702
- test('THEN: it defaults non-line series type to the chartType', () => {
703
- expect(configScript).not.toContain('"type":"scatter"');
704
- expect(configScript).toContain('"type":"bar"');
705
- expect(configScript).toContain('"type":"line"');
706
- });
707
- });
708
- });
709
-
710
698
  describe('GIVEN: Params: Download', () => {
711
- describe('WHEN: download object are provided', () => {
699
+ describe('WHEN: download object is provided', () => {
712
700
  const $ = cheerio.load(
713
701
  renderComponent('chart', {
714
- ...EXAMPLE_BAR_WITH_LINE_CHART_PARAMS,
702
+ ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
715
703
  download: {
716
704
  title: 'Download Chart Data',
717
705
  itemsList: [
@@ -733,29 +721,86 @@ describe('Macro: Chart', () => {
733
721
  });
734
722
  });
735
723
  });
724
+
725
+ describe('GIVEN: Params: Series: Type', () => {
726
+ describe('WHEN: a series has an invalid type', () => {
727
+ const invalidTypeParams = {
728
+ ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
729
+ series: [
730
+ { name: 'Invalid Series', data: [5, 15, 25], type: 'scatter' },
731
+ { name: 'Valid Line Series', data: [10, 20, 30], type: 'line' },
732
+ ],
733
+ };
734
+
735
+ const $ = cheerio.load(renderComponent('chart', invalidTypeParams));
736
+ const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
737
+
738
+ test('THEN: it defaults non-line series type to the chartType', () => {
739
+ expect(configScript).not.toContain('"type":"scatter"');
740
+ expect(configScript).toContain('"type":"column"');
741
+ expect(configScript).toContain('"type":"line"');
742
+ });
743
+ });
744
+ });
745
+
746
+ describe('GIVEN: Params: ChartType', () => {
747
+ describe('WHEN: chartType is not compatible with line series', () => {
748
+ const params = {
749
+ ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
750
+ chartType: 'bar',
751
+ };
752
+
753
+ const $ = cheerio.load(renderComponent('chart', params));
754
+ const configScript = $('script[data-highcharts-config--column-chart-123]').html();
755
+
756
+ test('THEN: it falls back to chartType and does not include "line" series', () => {
757
+ expect(configScript).not.toContain('"type":"line"');
758
+ expect(configScript).toContain('"type":"bar"');
759
+ });
760
+ });
761
+ });
736
762
  });
737
763
 
738
- describe('FOR: Column Chart with Line', () => {
764
+ describe('FOR: Scatter chart', () => {
739
765
  describe('GIVEN: Params: required', () => {
740
766
  describe('WHEN: required params are provided', () => {
741
- const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS));
742
- const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
767
+ const $ = cheerio.load(renderComponent('chart', EXAMPLE_SCATTER_CHART_PARAMS));
743
768
 
744
769
  test('THEN: it passes jest-axe checks', async () => {
745
770
  const results = await axe($.html());
746
771
  expect(results).toHaveNoViolations();
747
772
  });
748
773
 
749
- test('THEN: it includes one series of type "column" and another of type "line"', () => {
750
- expect(configScript).toContain('"type":"column"');
751
- expect(configScript).toContain('"type":"line"');
774
+ test('THEN: it renders the chart container with correct data attributes', () => {
775
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-type')).toBe('scatter');
776
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-theme')).toBe('primary');
777
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Scatter Chart');
778
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('scatter-chart-123');
779
+ });
780
+ });
781
+ });
782
+ });
783
+
784
+ describe('FOR: Area Chart', () => {
785
+ describe('GIVEN: Params: required', () => {
786
+ describe('WHEN: required params are provided', () => {
787
+ const $ = cheerio.load(renderComponent('chart', EXAMPLE_AREA_CHART_PARAMS));
788
+ const configScript = $(`script[data-highcharts-config--area-chart-123]`).html();
789
+
790
+ test('THEN: it passes jest-axe checks', async () => {
791
+ const results = await axe($.html());
792
+ expect(results).toHaveNoViolations();
793
+ });
794
+
795
+ test('THEN: it includes at least one area series', () => {
796
+ expect(configScript).toContain('"type":"area"');
752
797
  });
753
798
 
754
799
  test('THEN: it renders the chart container with correct data attributes', () => {
755
- expect($('[data-highcharts-base-chart]').attr('data-highcharts-type')).toBe('column');
756
- expect($('[data-highcharts-base-chart]').attr('data-highcharts-theme')).toBe('alternate');
757
- expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Column Chart');
758
- expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('column-chart-123');
800
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-type')).toBe('area');
801
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-theme')).toBe('primary');
802
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Area Chart');
803
+ expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('area-chart-123');
759
804
  });
760
805
 
761
806
  test('THEN: it includes the Highcharts JSON config', () => {
@@ -767,10 +812,10 @@ describe('Macro: Chart', () => {
767
812
 
768
813
  describe('GIVEN: Params: Legend', () => {
769
814
  describe('WHEN: legend is enabled', () => {
770
- const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS, legend: false }));
815
+ const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_AREA_CHART_PARAMS, legend: false }));
771
816
 
772
817
  test('THEN: it renders the legend', () => {
773
- const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
818
+ const configScript = $(`script[data-highcharts-config--area-chart-123]`).html();
774
819
  expect(configScript).toContain('"enabled":false');
775
820
  });
776
821
  });
@@ -780,7 +825,7 @@ describe('Macro: Chart', () => {
780
825
  describe('WHEN: caption is provided', () => {
781
826
  const $ = cheerio.load(
782
827
  renderComponent('chart', {
783
- ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
828
+ ...EXAMPLE_AREA_CHART_PARAMS,
784
829
  caption: 'This is an example caption for the chart.',
785
830
  }),
786
831
  );
@@ -795,7 +840,7 @@ describe('Macro: Chart', () => {
795
840
  describe('WHEN: description is provided', () => {
796
841
  const $ = cheerio.load(
797
842
  renderComponent('chart', {
798
- ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
843
+ ...EXAMPLE_AREA_CHART_PARAMS,
799
844
  description: 'An accessible description for screen readers.',
800
845
  }),
801
846
  );
@@ -807,10 +852,10 @@ describe('Macro: Chart', () => {
807
852
  });
808
853
 
809
854
  describe('GIVEN: Params: Download', () => {
810
- describe('WHEN: download object is provided', () => {
855
+ describe('WHEN: download object are provided', () => {
811
856
  const $ = cheerio.load(
812
857
  renderComponent('chart', {
813
- ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
858
+ ...EXAMPLE_AREA_CHART_PARAMS,
814
859
  download: {
815
860
  title: 'Download Chart Data',
816
861
  itemsList: [
@@ -832,24 +877,44 @@ describe('Macro: Chart', () => {
832
877
  });
833
878
  });
834
879
  });
880
+ });
835
881
 
836
- describe('GIVEN: Params: Series: Type', () => {
837
- describe('WHEN: a series has an invalid type', () => {
838
- const invalidTypeParams = {
839
- ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
840
- series: [
841
- { name: 'Invalid Series', data: [5, 15, 25], type: 'scatter' },
842
- { name: 'Valid Line Series', data: [10, 20, 30], type: 'line' },
843
- ],
844
- };
882
+ describe('FOR: Invalid Chart', () => {
883
+ describe('GIVEN: Invalid chart type', () => {
884
+ describe('WHEN: an invalid chart type is provided', () => {
885
+ const $ = cheerio.load(renderComponent('chart', EXAMPLE_INVALID_CHART_PARAMS));
845
886
 
846
- const $ = cheerio.load(renderComponent('chart', invalidTypeParams));
847
- const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
887
+ test('THEN: it does not render the chart', () => {
888
+ expect($('[data-highcharts-chart]').length).toBe(0);
889
+ });
848
890
 
849
- test('THEN: it defaults non-line series type to the chartType', () => {
850
- expect(configScript).not.toContain('"type":"scatter"');
851
- expect(configScript).toContain('"type":"column"');
852
- expect(configScript).toContain('"type":"line"');
891
+ test('THEN: it renders the error message', () => {
892
+ expect($('[data-invalid-chart-type]').text()).toBe('Chart type "invalid" is not supported');
893
+ });
894
+
895
+ test('THEN: it does not include the Highcharts JSON config', () => {
896
+ const configScript = $(`script[data-highcharts-config--invalid-chart-123]`).html();
897
+ expect(configScript).toBeNull();
898
+ });
899
+
900
+ test('THEN: it still renders the title', () => {
901
+ expect($('.ons-chart__title').text()).toBe('Example Invalid Chart');
902
+ });
903
+
904
+ test('THEN: it still renders the subtitle', () => {
905
+ expect($('.ons-chart__subtitle').text()).toBe('A sample subtitle');
906
+ });
907
+
908
+ test('THEN: it still renders the description', () => {
909
+ expect($('.ons-u-vh').text()).toBe('A detailed description');
910
+ });
911
+
912
+ test('THEN: it still renders the caption', () => {
913
+ expect($('figcaption').text()).toBe('A detailed caption');
914
+ });
915
+
916
+ test('THEN: it still renders the download', () => {
917
+ expect($('.ons-chart__download-title').text()).toBe('Download this chart');
853
918
  });
854
919
  });
855
920
  });
@@ -16,7 +16,7 @@ class AnnotationsOptions {
16
16
  padding: 3,
17
17
  style: {
18
18
  color: this.constants.labelColor,
19
- fontSize: this.constants.desktopFontSize,
19
+ fontSize: this.constants.defaultFontSize,
20
20
  width: 150,
21
21
  textAlign: 'left',
22
22
  },
@@ -0,0 +1,27 @@
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
+ lineWidth: 0,
16
+ },
17
+ series: {
18
+ marker: {
19
+ enabled: false,
20
+ },
21
+ },
22
+ },
23
+ };
24
+ };
25
+ }
26
+
27
+ 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.mobileFontSize,
29
+ fontSize: this.constants.defaultFontSize,
30
30
  },
31
31
  },
32
32
  },
@@ -119,15 +119,15 @@ class BarChart {
119
119
  // The design system does not include a semibold font weight, so we use 700 (bold) as an alternative.
120
120
  fontWeight: '700',
121
121
  color: this.constants.labelColor,
122
- fontSize: this.constants.mobileFontSize,
122
+ fontSize: this.constants.defaultFontSize,
123
123
  },
124
124
  });
125
125
 
126
126
  // This updates the height of the vertical axis and overall chart to fit the number of categories
127
127
  // Note that the vertical axis on a bar chart is the x axis
128
- updateBarChartHeight = (config, currentChart, useStackedLayout, numberOfExtraLines) => {
128
+ updateBarChartHeight = (config, currentChart, useStackedLayout) => {
129
129
  const numberOfCategories = config.xAxis.categories.length;
130
- const numberOfSeries = currentChart.series.length - numberOfExtraLines; // Get number of bar series
130
+ const numberOfSeries = currentChart.series.length; // Get number of bar series
131
131
  let barHeight = 30; // Height of each individual bar - set in bar-chart-plot-options
132
132
  let groupSpacing = 0; // Space we want between category groups, or between series groups for cluster charts
133
133
  let categoriesTotalHeight = 0;