@spaced-out/ui-design-system 0.1.86 → 0.1.87

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.
Files changed (73) hide show
  1. package/.cspell/custom-words.txt +5 -1
  2. package/.storybook/preview-head.html +4 -0
  3. package/CHANGELOG.md +20 -0
  4. package/design-tokens/color/app-color.json +26 -0
  5. package/design-tokens/font/base-font.json +1 -1
  6. package/design-tokens/size/base-size.json +12 -0
  7. package/lib/components/ChartWrapper/ChartWrapper.js +124 -0
  8. package/lib/components/ChartWrapper/ChartWrapper.js.flow +156 -0
  9. package/lib/components/ChartWrapper/ChartWrapper.module.css +19 -0
  10. package/lib/components/ChartWrapper/index.js +16 -0
  11. package/lib/components/ChartWrapper/index.js.flow +3 -0
  12. package/lib/components/Charts/ChartTooltip.js +18 -0
  13. package/lib/components/Charts/ChartTooltip.js.flow +15 -0
  14. package/lib/components/Charts/ChartTooltip.module.css +36 -0
  15. package/lib/components/Charts/index.js +71 -0
  16. package/lib/components/Charts/index.js.flow +8 -0
  17. package/lib/components/ColumnChart/ColumnChart.js +82 -0
  18. package/lib/components/ColumnChart/ColumnChart.js.flow +109 -0
  19. package/lib/components/ColumnChart/ColumnChart.module.css +12 -0
  20. package/lib/components/ColumnChart/index.js +16 -0
  21. package/lib/components/ColumnChart/index.js.flow +3 -0
  22. package/lib/components/DonutChart/DonutChart.js +97 -0
  23. package/lib/components/DonutChart/DonutChart.js.flow +147 -0
  24. package/lib/components/DonutChart/DonutChart.module.css +65 -0
  25. package/lib/components/DonutChart/index.js +16 -0
  26. package/lib/components/DonutChart/index.js.flow +3 -0
  27. package/lib/components/Grid/Grid.js +3 -2
  28. package/lib/components/Grid/Grid.js.flow +3 -2
  29. package/lib/components/Icon/index.js +31 -25
  30. package/lib/components/Icon/index.js.flow +3 -6
  31. package/lib/components/LineChart/LineChart.js +72 -0
  32. package/lib/components/LineChart/LineChart.js.flow +96 -0
  33. package/lib/components/LineChart/LineChart.module.css +17 -0
  34. package/lib/components/LineChart/index.js +16 -0
  35. package/lib/components/LineChart/index.js.flow +3 -0
  36. package/lib/components/SpiderChart/SpiderChart.js +88 -0
  37. package/lib/components/SpiderChart/SpiderChart.js.flow +123 -0
  38. package/lib/components/SpiderChart/SpiderChart.module.css +17 -0
  39. package/lib/components/SpiderChart/index.js +16 -0
  40. package/lib/components/SpiderChart/index.js.flow +3 -0
  41. package/lib/components/index.js +11 -0
  42. package/lib/components/index.js.flow +1 -0
  43. package/lib/styles/index.css +25 -1
  44. package/lib/styles/index.js +28 -4
  45. package/lib/styles/index.js.flow +25 -1
  46. package/lib/styles/variables/_color.css +16 -0
  47. package/lib/styles/variables/_color.js +17 -1
  48. package/lib/styles/variables/_color.js.flow +16 -0
  49. package/lib/styles/variables/_font.css +1 -1
  50. package/lib/styles/variables/_font.js +1 -1
  51. package/lib/styles/variables/_font.js.flow +1 -1
  52. package/lib/styles/variables/_size.css +8 -0
  53. package/lib/styles/variables/_size.js +9 -1
  54. package/lib/styles/variables/_size.js.flow +8 -0
  55. package/lib/types/charts.js +0 -0
  56. package/lib/types/charts.js.flow +151 -0
  57. package/lib/utils/charts/charts.js +71 -0
  58. package/lib/utils/charts/charts.js.flow +89 -0
  59. package/lib/utils/charts/columnChart.js +55 -0
  60. package/lib/utils/charts/columnChart.js.flow +59 -0
  61. package/lib/utils/charts/donutChart.js +114 -0
  62. package/lib/utils/charts/donutChart.js.flow +138 -0
  63. package/lib/utils/charts/helpers.js +65 -0
  64. package/lib/utils/charts/helpers.js.flow +68 -0
  65. package/lib/utils/charts/index.js +82 -0
  66. package/lib/utils/charts/index.js.flow +9 -0
  67. package/lib/utils/charts/lineChart.js +47 -0
  68. package/lib/utils/charts/lineChart.js.flow +49 -0
  69. package/lib/utils/charts/spiderChart.js +59 -0
  70. package/lib/utils/charts/spiderChart.js.flow +72 -0
  71. package/lib/utils/charts/typography.js +59 -0
  72. package/lib/utils/charts/typography.js.flow +67 -0
  73. package/package.json +4 -1
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.rightLegendColumn = exports.getDonutChartOptions = void 0;
7
+ var _charts = require("./charts");
8
+ var _helpers = require("./helpers");
9
+
10
+ /**
11
+ * Defining these constants here so that internal calculations are self explanatory.
12
+ */
13
+ const INNER_SIZE = 0.5; // set .5 here for 50% inner size w.r.t the pie chart outer circle.
14
+ const LEGEND_WIDTH = 0.4; // set .4 here for 40% legend width w.r.t the plot width.
15
+ const CHART_WIDTH = 1 - LEGEND_WIDTH;
16
+ const CHART_CENTER = (1 - LEGEND_WIDTH) / 2;
17
+ const CHART_SIZE = 0.8; // chart size w.r.t area allocated to chart drawing;
18
+
19
+ const rightLegendColumn = {
20
+ layout: 'vertical',
21
+ align: 'right',
22
+ verticalAlign: 'middle',
23
+ itemMarginBottom: 12,
24
+ symbolPadding: 8,
25
+ symbolWidth: 8,
26
+ // take it as 10% of width as left margin
27
+ width: `${LEGEND_WIDTH * 90}%`
28
+ };
29
+ exports.rightLegendColumn = rightLegendColumn;
30
+ const commonLegendOption = _charts.commonChartOptions.legend;
31
+
32
+ /**
33
+ * This function modifies the the common chart behavior to donut chart default behavior.
34
+ * It will not take userPassed option into account.
35
+ */
36
+
37
+ const getDonutChartOptions = _ref => {
38
+ let {
39
+ legend,
40
+ defaultCenterHTML,
41
+ subtitleSize,
42
+ centerTextX,
43
+ tooltip
44
+ } = _ref;
45
+ const legendOption = (0, _helpers.deepMerge)(_charts.commonChartOptions.legend, legend);
46
+ const isLegendEnabled = legendOption.enabled;
47
+ return {
48
+ ..._charts.commonChartOptions,
49
+ chart: {
50
+ ..._charts.commonChartOptions.chart,
51
+ type: 'pie',
52
+ spacing: [0, 0, 0, 0],
53
+ margin: [0, 0, 0, 0],
54
+ events: {
55
+ render() {
56
+ //$FlowFixMe[object-this-reference]
57
+ const chart = this;
58
+ const containerWidth = chart.renderTo.offsetWidth;
59
+ const desiredHeight = CHART_WIDTH * containerWidth;
60
+ // 5px adjustment required due to borderWidth mostly.
61
+ const centerTextX = isLegendEnabled ? parseInt(chart.plotWidth) * CHART_CENTER + 5 : 0;
62
+ chart.update({
63
+ chart: {
64
+ height: desiredHeight // Set the height dynamically based on the container's width
65
+ },
66
+
67
+ subtitle: {
68
+ x: centerTextX
69
+ }
70
+ }, false);
71
+ }
72
+ }
73
+ },
74
+ legend: {
75
+ ...legendOption,
76
+ ...rightLegendColumn
77
+ },
78
+ plotOptions: {
79
+ pie: {
80
+ innerSize: `${INNER_SIZE * 100}%`,
81
+ allowPointSelect: true,
82
+ cursor: 'pointer',
83
+ dataLabels: {
84
+ // auto disabling the data label when legend is enabled.
85
+ enabled: !isLegendEnabled,
86
+ distance: 20
87
+ },
88
+ showInLegend: true,
89
+ center: isLegendEnabled ? [`${CHART_CENTER * 100}%`, '50%'] : ['50%', '50%'],
90
+ size: `${CHART_SIZE * 100}%`,
91
+ borderWidth: 5,
92
+ borderRadius: 10,
93
+ minSize: 240,
94
+ clip: false
95
+ }
96
+ },
97
+ subtitle: {
98
+ useHTML: true,
99
+ text: defaultCenterHTML,
100
+ verticalAlign: 'middle',
101
+ align: isLegendEnabled ? 'left' : 'center',
102
+ style: {
103
+ alignContent: 'center',
104
+ // Note: Width was not working, have given miWidth and maxWidth
105
+ minWidth: isLegendEnabled ? `${CHART_WIDTH * CHART_SIZE * INNER_SIZE * 80}%` : `${CHART_SIZE * INNER_SIZE * 80}%`,
106
+ maxWidth: isLegendEnabled ? `${CHART_WIDTH * CHART_SIZE * INNER_SIZE * 80}%` : `${CHART_SIZE * INNER_SIZE * 80}%`,
107
+ ...(isLegendEnabled ? {
108
+ transform: 'translate(-50%)'
109
+ } : {})
110
+ }
111
+ }
112
+ };
113
+ };
114
+ exports.getDonutChartOptions = getDonutChartOptions;
@@ -0,0 +1,138 @@
1
+ // @flow strict
2
+
3
+ import type {
4
+ ChartOptions,
5
+ LegendOptionsType,
6
+ Tooltip,
7
+ } from '../../types/charts';
8
+
9
+ import {commonChartOptions} from './charts';
10
+ import {deepMerge} from './helpers';
11
+
12
+
13
+ type DonutChartDataType = {
14
+ name?: string,
15
+ color?: string,
16
+ y?: number,
17
+ };
18
+
19
+ type DonutChartPropsType = {
20
+ legend?: LegendOptionsType,
21
+ defaultCenterHTML?: string,
22
+ subtitleSize?: string,
23
+ centerTextX?: number,
24
+ tooltip?: Tooltip,
25
+ };
26
+
27
+ /**
28
+ * Defining these constants here so that internal calculations are self explanatory.
29
+ */
30
+ const INNER_SIZE = 0.5; // set .5 here for 50% inner size w.r.t the pie chart outer circle.
31
+ const LEGEND_WIDTH = 0.4; // set .4 here for 40% legend width w.r.t the plot width.
32
+ const CHART_WIDTH = 1 - LEGEND_WIDTH;
33
+ const CHART_CENTER = (1 - LEGEND_WIDTH) / 2;
34
+ const CHART_SIZE = 0.8; // chart size w.r.t area allocated to chart drawing;
35
+
36
+ export const rightLegendColumn = {
37
+ layout: 'vertical',
38
+ align: 'right',
39
+ verticalAlign: 'middle',
40
+ itemMarginBottom: 12,
41
+ symbolPadding: 8,
42
+ symbolWidth: 8,
43
+ // take it as 10% of width as left margin
44
+ width: `${LEGEND_WIDTH * 90}%`,
45
+ };
46
+
47
+ const commonLegendOption = commonChartOptions.legend;
48
+
49
+ /**
50
+ * This function modifies the the common chart behavior to donut chart default behavior.
51
+ * It will not take userPassed option into account.
52
+ */
53
+
54
+ export const getDonutChartOptions = ({
55
+ legend,
56
+ defaultCenterHTML,
57
+ subtitleSize,
58
+ centerTextX,
59
+ tooltip,
60
+ }: //$FlowFixMe[prop-missing]
61
+ DonutChartPropsType): ChartOptions => {
62
+ const legendOption = deepMerge(commonChartOptions.legend, legend);
63
+ const isLegendEnabled = legendOption.enabled;
64
+ return {
65
+ ...commonChartOptions,
66
+ chart: {
67
+ ...commonChartOptions.chart,
68
+ type: 'pie',
69
+ spacing: [0, 0, 0, 0],
70
+ margin: [0, 0, 0, 0],
71
+ events: {
72
+ render() {
73
+ //$FlowFixMe[object-this-reference]
74
+ const chart = this;
75
+ const containerWidth = chart.renderTo.offsetWidth;
76
+ const desiredHeight = CHART_WIDTH * containerWidth;
77
+ // 5px adjustment required due to borderWidth mostly.
78
+ const centerTextX = isLegendEnabled
79
+ ? parseInt(chart.plotWidth) * CHART_CENTER + 5
80
+ : 0;
81
+ chart.update(
82
+ {
83
+ chart: {
84
+ height: desiredHeight, // Set the height dynamically based on the container's width
85
+ },
86
+ subtitle: {
87
+ x: centerTextX,
88
+ },
89
+ },
90
+ false,
91
+ );
92
+ },
93
+ },
94
+ },
95
+ legend: {
96
+ ...legendOption,
97
+ ...rightLegendColumn,
98
+ },
99
+ plotOptions: {
100
+ pie: {
101
+ innerSize: `${INNER_SIZE * 100}%`,
102
+ allowPointSelect: true,
103
+ cursor: 'pointer',
104
+ dataLabels: {
105
+ // auto disabling the data label when legend is enabled.
106
+ enabled: !isLegendEnabled,
107
+ distance: 20,
108
+ },
109
+ showInLegend: true,
110
+ center: isLegendEnabled
111
+ ? [`${CHART_CENTER * 100}%`, '50%']
112
+ : ['50%', '50%'],
113
+ size: `${CHART_SIZE * 100}%`,
114
+ borderWidth: 5,
115
+ borderRadius: 10,
116
+ minSize: 240,
117
+ clip: false,
118
+ },
119
+ },
120
+ subtitle: {
121
+ useHTML: true,
122
+ text: defaultCenterHTML,
123
+ verticalAlign: 'middle',
124
+ align: isLegendEnabled ? 'left' : 'center',
125
+ style: {
126
+ alignContent: 'center',
127
+ // Note: Width was not working, have given miWidth and maxWidth
128
+ minWidth: isLegendEnabled
129
+ ? `${CHART_WIDTH * CHART_SIZE * INNER_SIZE * 80}%`
130
+ : `${CHART_SIZE * INNER_SIZE * 80}%`,
131
+ maxWidth: isLegendEnabled
132
+ ? `${CHART_WIDTH * CHART_SIZE * INNER_SIZE * 80}%`
133
+ : `${CHART_SIZE * INNER_SIZE * 80}%`,
134
+ ...(isLegendEnabled ? {transform: 'translate(-50%)'} : {}),
135
+ },
136
+ },
137
+ };
138
+ };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.yAxisTitleStyle = exports.yAxisLabelStyle = exports.xAxisTitleStyle = exports.xAxisLabelStyle = exports.rightLineLegendColumn = exports.deepMerge = exports.bottomLegendRow = exports.activeLabelStyle = void 0;
7
+ var _merge = _interopRequireDefault(require("lodash/merge"));
8
+ var _color = require("../../styles/variables/_color");
9
+ var _typography = require("./typography");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const deepMerge = function (obj1, obj2) {
13
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
14
+ args[_key - 2] = arguments[_key];
15
+ }
16
+ return (
17
+ // {} is used here to ensure obj1 is not modified
18
+ (0, _merge.default)({}, obj1, obj2, ...args)
19
+ );
20
+ };
21
+ exports.deepMerge = deepMerge;
22
+ const rightLineLegendColumn = {
23
+ layout: 'vertical',
24
+ align: 'right',
25
+ verticalAlign: 'middle',
26
+ itemMarginBottom: 12,
27
+ symbolPadding: 4,
28
+ symbolWidth: 16,
29
+ width: '40%'
30
+ };
31
+ exports.rightLineLegendColumn = rightLineLegendColumn;
32
+ const bottomLegendRow = {
33
+ layout: 'horizontal',
34
+ align: 'center',
35
+ verticalAlign: 'bottom',
36
+ itemDistance: 20,
37
+ symbolPadding: 4,
38
+ symbolWidth: 16
39
+ };
40
+ exports.bottomLegendRow = bottomLegendRow;
41
+ const yAxisTitleStyle = {
42
+ ..._typography.bodySmall,
43
+ color: _color.colorTextSecondary
44
+ };
45
+ exports.yAxisTitleStyle = yAxisTitleStyle;
46
+ const xAxisTitleStyle = {
47
+ ..._typography.bodySmall,
48
+ color: _color.colorTextSecondary
49
+ };
50
+ exports.xAxisTitleStyle = xAxisTitleStyle;
51
+ const yAxisLabelStyle = {
52
+ ..._typography.formLabelSmall
53
+ };
54
+ exports.yAxisLabelStyle = yAxisLabelStyle;
55
+ const xAxisLabelStyle = {
56
+ ..._typography.buttonTextExtraSmall
57
+ };
58
+ exports.xAxisLabelStyle = xAxisLabelStyle;
59
+ const activeLabelStyle = {
60
+ ..._typography.buttonTextExtraSmall,
61
+ ..._typography.underline,
62
+ color: _color.colorTextPrimary,
63
+ fill: _color.colorTextPrimary
64
+ };
65
+ exports.activeLabelStyle = activeLabelStyle;
@@ -0,0 +1,68 @@
1
+ // @flow strict
2
+
3
+ import merge from 'lodash/merge';
4
+
5
+ import {
6
+ colorTextPrimary,
7
+ colorTextSecondary,
8
+ } from '../../styles/variables/_color';
9
+
10
+ import {
11
+ bodySmall,
12
+ buttonTextExtraSmall,
13
+ formLabelSmall,
14
+ underline,
15
+ } from './typography';
16
+
17
+
18
+ export const deepMerge = <T: {}>(
19
+ obj1?: $Shape<T>,
20
+ obj2?: $Shape<T>,
21
+ ...args: Array<?$Shape<T>>
22
+ ): T =>
23
+ // {} is used here to ensure obj1 is not modified
24
+ merge({}, obj1, obj2, ...args);
25
+
26
+ export const rightLineLegendColumn = {
27
+ layout: 'vertical',
28
+ align: 'right',
29
+ verticalAlign: 'middle',
30
+ itemMarginBottom: 12,
31
+ symbolPadding: 4,
32
+ symbolWidth: 16,
33
+ width: '40%',
34
+ };
35
+
36
+ export const bottomLegendRow = {
37
+ layout: 'horizontal',
38
+ align: 'center',
39
+ verticalAlign: 'bottom',
40
+ itemDistance: 20,
41
+ symbolPadding: 4,
42
+ symbolWidth: 16,
43
+ };
44
+
45
+ export const yAxisTitleStyle = {
46
+ ...bodySmall,
47
+ color: colorTextSecondary,
48
+ };
49
+
50
+ export const xAxisTitleStyle = {
51
+ ...bodySmall,
52
+ color: colorTextSecondary,
53
+ };
54
+
55
+ export const yAxisLabelStyle = {
56
+ ...formLabelSmall,
57
+ };
58
+
59
+ export const xAxisLabelStyle = {
60
+ ...buttonTextExtraSmall,
61
+ };
62
+
63
+ export const activeLabelStyle = {
64
+ ...buttonTextExtraSmall,
65
+ ...underline,
66
+ color: colorTextPrimary,
67
+ fill: colorTextPrimary,
68
+ };
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _charts = require("./charts");
7
+ Object.keys(_charts).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _charts[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _charts[key];
14
+ }
15
+ });
16
+ });
17
+ var _columnChart = require("./columnChart");
18
+ Object.keys(_columnChart).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _columnChart[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _columnChart[key];
25
+ }
26
+ });
27
+ });
28
+ var _donutChart = require("./donutChart");
29
+ Object.keys(_donutChart).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _donutChart[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _donutChart[key];
36
+ }
37
+ });
38
+ });
39
+ var _helpers = require("./helpers");
40
+ Object.keys(_helpers).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _helpers[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _helpers[key];
47
+ }
48
+ });
49
+ });
50
+ var _lineChart = require("./lineChart");
51
+ Object.keys(_lineChart).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _lineChart[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _lineChart[key];
58
+ }
59
+ });
60
+ });
61
+ var _spiderChart = require("./spiderChart");
62
+ Object.keys(_spiderChart).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _spiderChart[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _spiderChart[key];
69
+ }
70
+ });
71
+ });
72
+ var _typography = require("./typography");
73
+ Object.keys(_typography).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _typography[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _typography[key];
80
+ }
81
+ });
82
+ });
@@ -0,0 +1,9 @@
1
+ // @flow strict
2
+
3
+ export * from './charts';
4
+ export * from './columnChart';
5
+ export * from './donutChart';
6
+ export * from './helpers';
7
+ export * from './lineChart';
8
+ export * from './spiderChart';
9
+ export * from './typography';
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLineChartOptions = void 0;
7
+ var _charts = require("./charts");
8
+ var _helpers = require("./helpers");
9
+ var _typography = require("./typography");
10
+
11
+ /**
12
+ * This function modifies the the common chart behavior to line chart default behavior.
13
+ * It will not take userPassed option into account.
14
+ */
15
+
16
+ const getLineChartOptions = () => ({
17
+ ..._charts.commonChartOptions,
18
+ chart: {
19
+ type: 'line'
20
+ },
21
+ legend: {
22
+ ..._charts.commonChartOptions.legend,
23
+ ..._helpers.bottomLegendRow,
24
+ symbolWidth: 18
25
+ },
26
+ xAxis: {
27
+ labels: {
28
+ style: _typography.formLabelSmall
29
+ },
30
+ title: {
31
+ margin: 12,
32
+ style: _helpers.xAxisTitleStyle
33
+ }
34
+ },
35
+ yAxis: {
36
+ labels: {
37
+ align: 'right',
38
+ distance: 12,
39
+ style: _helpers.yAxisLabelStyle
40
+ },
41
+ title: {
42
+ margin: 12,
43
+ style: _helpers.yAxisTitleStyle
44
+ }
45
+ }
46
+ });
47
+ exports.getLineChartOptions = getLineChartOptions;
@@ -0,0 +1,49 @@
1
+ // @flow strict
2
+
3
+ import type {ChartOptions} from '../../types/charts';
4
+
5
+ import {commonChartOptions} from './charts';
6
+ import {
7
+ bottomLegendRow,
8
+ xAxisTitleStyle,
9
+ yAxisLabelStyle,
10
+ yAxisTitleStyle,
11
+ } from './helpers';
12
+ import {formLabelSmall} from './typography';
13
+
14
+ /**
15
+ * This function modifies the the common chart behavior to line chart default behavior.
16
+ * It will not take userPassed option into account.
17
+ */
18
+
19
+ export const getLineChartOptions = (): ChartOptions => ({
20
+ ...commonChartOptions,
21
+ chart: {
22
+ type: 'line',
23
+ },
24
+ legend: {
25
+ ...commonChartOptions.legend,
26
+ ...bottomLegendRow,
27
+ symbolWidth: 18,
28
+ },
29
+ xAxis: {
30
+ labels: {
31
+ style: formLabelSmall,
32
+ },
33
+ title: {
34
+ margin: 12,
35
+ style: xAxisTitleStyle,
36
+ },
37
+ },
38
+ yAxis: {
39
+ labels: {
40
+ align: 'right',
41
+ distance: 12,
42
+ style: yAxisLabelStyle,
43
+ },
44
+ title: {
45
+ margin: 12,
46
+ style: yAxisTitleStyle,
47
+ },
48
+ },
49
+ });
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSpiderChartOptions = exports.bodySmallSecondary = void 0;
7
+ var _color = require("../../styles/variables/_color");
8
+ var _charts = require("./charts");
9
+ var _helpers = require("./helpers");
10
+ var _typography = require("./typography");
11
+
12
+ const bodySmallSecondary = {
13
+ ..._typography.bodySmall,
14
+ color: _color.colorTextSecondary
15
+ };
16
+
17
+ /**
18
+ * This function modifies the the common chart behavior to spider chart default behavior.
19
+ * It will not take userPassed option into account.
20
+ */
21
+ exports.bodySmallSecondary = bodySmallSecondary;
22
+ const getSpiderChartOptions = () => ({
23
+ ..._charts.commonChartOptions,
24
+ chart: {
25
+ ..._charts.commonChartOptions.chart,
26
+ polar: true,
27
+ type: 'line',
28
+ spacing: [0, 0, 0, 0],
29
+ margin: [0, 0, 0, 0]
30
+ },
31
+ xAxis: {
32
+ labels: {
33
+ style: bodySmallSecondary
34
+ },
35
+ lineWidth: 0
36
+ },
37
+ yAxis: {
38
+ labels: {
39
+ style: bodySmallSecondary
40
+ },
41
+ gridLineInterpolation: 'polygon',
42
+ lineWidth: 0
43
+ },
44
+ legend: {
45
+ ..._charts.commonChartOptions.legend,
46
+ ..._helpers.rightLineLegendColumn,
47
+ symbolWidth: 18
48
+ },
49
+ pane: {
50
+ center: ['30%', '50%'],
51
+ size: '70%'
52
+ },
53
+ tooltip: {
54
+ ..._charts.commonChartOptions.tooltip,
55
+ followPointer: false,
56
+ shared: true
57
+ }
58
+ });
59
+ exports.getSpiderChartOptions = getSpiderChartOptions;
@@ -0,0 +1,72 @@
1
+ // @flow strict
2
+
3
+ import {colorTextSecondary} from '../../styles/variables/_color';
4
+ import type {
5
+ AxisOptions,
6
+ ChartOptions,
7
+ LegendOptionsType,
8
+ SeriesOptionsType,
9
+ } from '../../types/charts';
10
+
11
+ import {commonChartOptions} from './charts';
12
+ import { rightLineLegendColumn} from './helpers';
13
+ import {bodySmall} from './typography';
14
+
15
+
16
+ type SpiderChartPropsType = {
17
+ ...ChartOptions,
18
+ chart: ChartOptions,
19
+ xAxis: AxisOptions,
20
+ yAxis: AxisOptions,
21
+ series?: Array<SeriesOptionsType>,
22
+ legend?: LegendOptionsType,
23
+ ...
24
+ };
25
+
26
+ export const bodySmallSecondary = {
27
+ ...bodySmall,
28
+ color: colorTextSecondary,
29
+ };
30
+
31
+ /**
32
+ * This function modifies the the common chart behavior to spider chart default behavior.
33
+ * It will not take userPassed option into account.
34
+ */
35
+
36
+ export const getSpiderChartOptions = (): ChartOptions => ({
37
+ ...commonChartOptions,
38
+ chart: {
39
+ ...commonChartOptions.chart,
40
+ polar: true,
41
+ type: 'line',
42
+ spacing: [0, 0, 0, 0],
43
+ margin: [0, 0, 0, 0],
44
+ },
45
+ xAxis: {
46
+ labels: {
47
+ style: bodySmallSecondary,
48
+ },
49
+ lineWidth: 0,
50
+ },
51
+ yAxis: {
52
+ labels: {
53
+ style: bodySmallSecondary,
54
+ },
55
+ gridLineInterpolation: 'polygon',
56
+ lineWidth: 0,
57
+ },
58
+ legend: {
59
+ ...commonChartOptions.legend,
60
+ ...rightLineLegendColumn,
61
+ symbolWidth: 18,
62
+ },
63
+ pane: {
64
+ center: ['30%', '50%'],
65
+ size: '70%',
66
+ },
67
+ tooltip: {
68
+ ...commonChartOptions.tooltip,
69
+ followPointer: false,
70
+ shared: true,
71
+ },
72
+ });