@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.
- package/components/card/_macro.njk +15 -2
- package/components/card/example-card-set-with-headline-figures.njk +1 -4
- package/components/chart/_chart.scss +5 -0
- package/components/chart/_macro.njk +36 -31
- package/components/chart/_macro.spec.js +132 -67
- package/components/chart/annotations-options.js +1 -1
- package/components/chart/area-chart.js +27 -0
- package/components/chart/bar-chart.js +4 -4
- package/components/chart/chart-constants.js +84 -3
- package/components/chart/chart.js +39 -16
- package/components/chart/column-chart.js +33 -24
- package/components/chart/common-chart-options.js +6 -33
- package/components/chart/example-area-chart.njk +68 -0
- package/components/chart/example-column-with-line-chart.njk +3 -1
- package/components/chart/example-line-chart-with-markers.njk +138 -0
- 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/table-of-contents/_macro.njk +1 -11
- package/components/table-of-contents/example-table-of-contents-related-links-with-button.njk +1 -2
- 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/components/chart/example-bar-with-line-chart.njk +0 -64
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{% from "components/chart/_macro.njk" import onsChart %}
|
|
2
|
+
|
|
3
|
+
{{
|
|
4
|
+
onsChart({
|
|
5
|
+
"chartType": "scatter",
|
|
6
|
+
"description": "Example scatter chart",
|
|
7
|
+
"theme": "alternate",
|
|
8
|
+
"title": "Example scatter chart",
|
|
9
|
+
"subtitle": "Scatter chart subtitle",
|
|
10
|
+
"id": "id",
|
|
11
|
+
"headingLevel": 4,
|
|
12
|
+
"caption": "Source: Monthly Business Survey, Retails Sales Inquiry from the Office for National Statistics",
|
|
13
|
+
"download": {
|
|
14
|
+
'title': 'Download Figure 1 data',
|
|
15
|
+
'itemsList': [
|
|
16
|
+
{
|
|
17
|
+
"text": "Excel spreadsheet (XLSX format, 18KB)",
|
|
18
|
+
"url": "#"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"text": "Simple text file (CSV format, 25KB)",
|
|
22
|
+
"url": "#"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
|
|
26
|
+
"text": "Image (PNG format, 25KB)",
|
|
27
|
+
"url": "#"
|
|
28
|
+
}
|
|
29
|
+
]},
|
|
30
|
+
"xAxis": {
|
|
31
|
+
"title": "Height"
|
|
32
|
+
},
|
|
33
|
+
"yAxis": {
|
|
34
|
+
"title": "Weight"
|
|
35
|
+
},
|
|
36
|
+
"legend": 'true',
|
|
37
|
+
"series": [
|
|
38
|
+
{
|
|
39
|
+
"name": "Female",
|
|
40
|
+
"data": [
|
|
41
|
+
[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0],
|
|
42
|
+
[163.8, 54.5], [158.4, 50.8], [165.2, 57.3], [160.7, 52.4],
|
|
43
|
+
[162.3, 55.1], [166.8, 58.7], [159.8, 51.9], [164.5, 56.2],
|
|
44
|
+
[158.9, 50.3], [163.1, 53.8],
|
|
45
|
+
[161.8, 52.1], [167.1, 58.8], [159.2, 49.8], [157.4, 62.7],
|
|
46
|
+
[163.5, 54.9], [158.7, 51.2], [165.5, 57.8], [160.4, 52.7],
|
|
47
|
+
[162.7, 55.4], [166.4, 58.4], [159.4, 51.5], [164.8, 56.5],
|
|
48
|
+
[158.6, 50.6], [163.4, 53.5]
|
|
49
|
+
],
|
|
50
|
+
"marker": 'true'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "Male",
|
|
54
|
+
"data": [
|
|
55
|
+
[174.0, 65.6], [175.3, 71.8], [187.5, 80.7], [186.5, 72.6],
|
|
56
|
+
[178.2, 68.4], [182.7, 74.3], [176.8, 67.9], [188.4, 77.2],
|
|
57
|
+
[184.5, 73.8], [179.6, 70.5], [186.2, 79.4], [183.8, 75.1],
|
|
58
|
+
[177.4, 69.2], [185.9, 76.3],
|
|
59
|
+
[174.3, 66.1], [175.8, 71.4], [187.8, 80.2], [186.1, 72.9],
|
|
60
|
+
[178.7, 68.8], [182.2, 74.7], [176.4, 67.5], [188.0, 77.6],
|
|
61
|
+
[184.1, 73.4], [179.2, 70.8], [186.6, 79.8], [183.4, 75.4],
|
|
62
|
+
[177.8, 69.6], [185.5, 76.7]
|
|
63
|
+
],
|
|
64
|
+
"marker": 'true'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "Adolescent Male",
|
|
68
|
+
"data": [
|
|
69
|
+
[168.5, 58.2], [171.2, 62.4], [169.8, 59.7], [173.4, 63.8],
|
|
70
|
+
[170.6, 61.2], [172.8, 64.5], [167.9, 57.8], [174.2, 65.1],
|
|
71
|
+
[169.5, 60.3], [171.8, 63.2],
|
|
72
|
+
[168.8, 58.6], [171.5, 62.8], [169.2, 59.4], [173.7, 63.5],
|
|
73
|
+
[170.2, 61.6], [172.4, 64.2], [168.2, 58.1], [173.9, 64.8],
|
|
74
|
+
[169.8, 60.7], [171.4, 63.6]
|
|
75
|
+
],
|
|
76
|
+
"marker": 'true'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "Adolescent Female",
|
|
80
|
+
"data": [
|
|
81
|
+
[164.2, 54.8], [166.5, 57.2], [163.8, 53.9], [165.7, 56.4],
|
|
82
|
+
[162.9, 52.8], [167.2, 58.1], [164.8, 55.3], [166.9, 57.8],
|
|
83
|
+
[163.5, 53.4], [165.4, 56.7],
|
|
84
|
+
[164.5, 55.1], [166.2, 57.5], [163.4, 53.6], [165.9, 56.2],
|
|
85
|
+
[162.6, 52.5], [167.5, 58.4], [164.4, 55.6], [166.6, 57.6],
|
|
86
|
+
[163.8, 53.7], [165.2, 56.9]
|
|
87
|
+
],
|
|
88
|
+
"marker": 'true'
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"percentageHeightDesktop": 35,
|
|
92
|
+
"percentageHeightMobile": 90
|
|
93
|
+
})
|
|
94
|
+
}}
|
|
@@ -1,39 +1,34 @@
|
|
|
1
|
+
import ChartConstants from './chart-constants';
|
|
1
2
|
class LineChart {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.chartConstants = ChartConstants.constants();
|
|
5
|
+
this.markerStyles = this.chartConstants.lineMarkerStyles;
|
|
6
|
+
}
|
|
7
|
+
|
|
2
8
|
getLineChartOptions = () => {
|
|
3
9
|
return {
|
|
4
10
|
plotOptions: {
|
|
5
11
|
line: {
|
|
6
12
|
lineWidth: 3,
|
|
7
13
|
linecap: 'round',
|
|
8
|
-
// In a later PR we will update the marker styles
|
|
9
|
-
marker: {
|
|
10
|
-
enabled: false,
|
|
11
|
-
radius: 4,
|
|
12
|
-
symbol: 'circle',
|
|
13
|
-
lineWidth: 0,
|
|
14
|
-
},
|
|
15
14
|
},
|
|
16
15
|
},
|
|
17
16
|
};
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
updateLastPointMarker = (series) => {
|
|
21
|
-
series.forEach((series) => {
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
false,
|
|
35
|
-
);
|
|
36
|
-
}
|
|
20
|
+
series.forEach((series, i) => {
|
|
21
|
+
const points = series.points;
|
|
22
|
+
if (points && points.length > 0) {
|
|
23
|
+
// Show only the last point marker
|
|
24
|
+
const lastPoint = points[points.length - 1];
|
|
25
|
+
lastPoint.update({
|
|
26
|
+
marker: {
|
|
27
|
+
enabled: true,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
// Update the marker styles to use for each series
|
|
31
|
+
series.update({ marker: this.markerStyles[i] != undefined ? this.markerStyles[i] : this.markerStyles[0] }, false);
|
|
37
32
|
}
|
|
38
33
|
});
|
|
39
34
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import ChartConstants from './chart-constants';
|
|
2
|
+
|
|
3
|
+
class ScatterChart {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.chartConstants = ChartConstants.constants();
|
|
6
|
+
this.markerStyles = this.chartConstants.scatterMarkerStyles;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getScatterChartOptions = () => {
|
|
10
|
+
return {
|
|
11
|
+
plotOptions: {
|
|
12
|
+
scatter: {
|
|
13
|
+
// enable tooltips for scatter charts
|
|
14
|
+
enableMouseTracking: true,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
xAxis: {
|
|
18
|
+
gridLineWidth: 1,
|
|
19
|
+
},
|
|
20
|
+
yAxis: {
|
|
21
|
+
gridLineWidth: 1,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Use a different set of marker styles for scatter charts
|
|
27
|
+
updateMarkers = (currentChart) => {
|
|
28
|
+
currentChart.series.forEach((series, i) => {
|
|
29
|
+
series.update({ marker: this.markerStyles[i] != undefined ? this.markerStyles[i] : this.markerStyles[0] }, false);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default ScatterChart;
|
|
@@ -61,17 +61,7 @@
|
|
|
61
61
|
|
|
62
62
|
{% if params.button %}
|
|
63
63
|
<div class="ons-table-of-contents__button ons-u-pt-l">
|
|
64
|
-
{% set allVariants = ['small', 'secondary'] %}
|
|
65
|
-
|
|
66
|
-
{% if params.button.variants %}
|
|
67
|
-
{% if params.button.variants is string %}
|
|
68
|
-
{% set allVariants = (allVariants.push(params.button.variants), allVariants) %}
|
|
69
|
-
{% else %}
|
|
70
|
-
{% for variant in params.button.variants %}
|
|
71
|
-
{% set allVariants = (allVariants.push(variant), allVariants) %}
|
|
72
|
-
{% endfor %}
|
|
73
|
-
{% endif %}
|
|
74
|
-
{% endif %}
|
|
64
|
+
{% set allVariants = ['small', 'secondary', 'print'] %}
|
|
75
65
|
|
|
76
66
|
{{
|
|
77
67
|
onsButton({
|