@pareto-engineering/design-system 5.0.0 → 5.0.2
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/dist/cjs/a/{AreaChart → Charts/AreaChart}/AreaChart.js +89 -73
- package/dist/cjs/a/Charts/AreaChart/styles.scss +48 -0
- package/dist/cjs/a/Charts/BarChart/BarChart.js +137 -0
- package/dist/cjs/a/Charts/BarChart/index.js +13 -0
- package/dist/cjs/a/Charts/BarChart/styles.scss +48 -0
- package/dist/cjs/a/Charts/Common/CustomLegend/CustomLegend.js +88 -0
- package/dist/cjs/a/Charts/Common/CustomLegend/index.js +13 -0
- package/dist/cjs/a/Charts/Common/CustomLegend/styles.scss +67 -0
- package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +97 -0
- package/dist/cjs/a/Charts/Common/CustomTooltipContent/index.js +13 -0
- package/dist/cjs/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +97 -0
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/index.js +13 -0
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
- package/dist/cjs/a/Charts/Common/index.js +26 -0
- package/dist/cjs/a/Charts/PieChart/PieChart.js +99 -0
- package/dist/cjs/a/Charts/PieChart/index.js +13 -0
- package/dist/cjs/a/Charts/PieChart/styles.scss +48 -0
- package/dist/cjs/a/Charts/index.js +26 -0
- package/dist/cjs/a/Tooltip/styles.scss +1 -1
- package/dist/cjs/a/index.js +14 -2
- package/dist/cjs/f/FormInput/FormInput.js +6 -0
- package/dist/cjs/f/fields/FileUpload/FileUpload.js +18 -4
- package/dist/cjs/f/fields/LatexPreviewInput/LatexPreviewInput.js +78 -0
- package/dist/cjs/f/fields/LatexPreviewInput/convertLatexToHtml.js +46 -0
- package/dist/cjs/f/fields/LatexPreviewInput/index.js +20 -0
- package/dist/cjs/f/fields/LatexPreviewInput/styles.scss +24 -0
- package/dist/cjs/f/fields/index.js +13 -0
- package/dist/cjs/g/FormBuilder/FormBuilder.js +3 -6
- package/dist/cjs/g/FormBuilder/common/Builder/Builder.js +1 -3
- package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +5 -7
- package/dist/cjs/g/FormBuilder/common/Builder/common/Section/Section.js +2 -4
- package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +2 -4
- package/dist/cjs/g/FormBuilder/common/Renderer/common/Section/Section.js +2 -10
- package/dist/cjs/utils/formatting.js +119 -0
- package/dist/cjs/utils/index.js +26 -1
- package/dist/es/a/{AreaChart → Charts/AreaChart}/AreaChart.js +88 -69
- package/dist/es/a/Charts/AreaChart/styles.scss +48 -0
- package/dist/es/a/Charts/BarChart/BarChart.js +128 -0
- package/dist/es/a/Charts/BarChart/index.js +1 -0
- package/dist/es/a/Charts/BarChart/styles.scss +48 -0
- package/dist/es/a/Charts/Common/CustomLegend/CustomLegend.js +76 -0
- package/dist/es/a/Charts/Common/CustomLegend/index.js +1 -0
- package/dist/es/a/Charts/Common/CustomLegend/styles.scss +67 -0
- package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +87 -0
- package/dist/es/a/Charts/Common/CustomTooltipContent/index.js +1 -0
- package/dist/es/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
- package/dist/es/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +86 -0
- package/dist/es/a/Charts/Common/YLabelsDropDown/index.js +1 -0
- package/dist/es/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
- package/dist/es/a/Charts/Common/index.js +3 -0
- package/dist/es/a/Charts/PieChart/PieChart.js +89 -0
- package/dist/es/a/Charts/PieChart/index.js +1 -0
- package/dist/es/a/Charts/PieChart/styles.scss +48 -0
- package/dist/es/a/Charts/index.js +3 -0
- package/dist/es/a/Tooltip/styles.scss +1 -1
- package/dist/es/a/index.js +1 -1
- package/dist/es/f/FormInput/FormInput.js +7 -1
- package/dist/es/f/fields/FileUpload/FileUpload.js +18 -4
- package/dist/es/f/fields/LatexPreviewInput/LatexPreviewInput.js +70 -0
- package/dist/es/f/fields/LatexPreviewInput/convertLatexToHtml.js +31 -0
- package/dist/es/f/fields/LatexPreviewInput/index.js +3 -0
- package/dist/es/f/fields/LatexPreviewInput/styles.scss +24 -0
- package/dist/es/f/fields/index.js +1 -0
- package/dist/es/g/FormBuilder/FormBuilder.js +3 -6
- package/dist/es/g/FormBuilder/common/Builder/Builder.js +1 -3
- package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +5 -7
- package/dist/es/g/FormBuilder/common/Builder/common/Section/Section.js +2 -4
- package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +2 -4
- package/dist/es/g/FormBuilder/common/Renderer/common/Section/Section.js +32 -42
- package/dist/es/utils/formatting.js +109 -0
- package/dist/es/utils/index.js +2 -1
- package/jest.config.js +3 -0
- package/package.json +7 -3
- package/src/stories/a/AreaChart.stories.jsx +1 -1
- package/src/stories/a/BarChart.stories.jsx +89 -0
- package/src/stories/a/PieChart.stories.jsx +53 -0
- package/src/ui/a/{AreaChart → Charts/AreaChart}/AreaChart.jsx +114 -65
- package/src/ui/a/Charts/AreaChart/styles.scss +48 -0
- package/src/ui/a/Charts/BarChart/BarChart.jsx +167 -0
- package/src/ui/a/Charts/BarChart/index.js +1 -0
- package/src/ui/a/Charts/BarChart/styles.scss +48 -0
- package/src/ui/a/Charts/Common/CustomLegend/CustomLegend.jsx +109 -0
- package/src/ui/a/Charts/Common/CustomLegend/index.js +1 -0
- package/src/ui/a/Charts/Common/CustomLegend/styles.scss +67 -0
- package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +117 -0
- package/src/ui/a/Charts/Common/CustomTooltipContent/index.js +1 -0
- package/src/ui/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
- package/src/ui/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.jsx +121 -0
- package/src/ui/a/Charts/Common/YLabelsDropDown/index.js +1 -0
- package/src/ui/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
- package/src/ui/a/Charts/Common/index.js +3 -0
- package/src/ui/a/Charts/PieChart/PieChart.jsx +125 -0
- package/src/ui/a/Charts/PieChart/index.js +1 -0
- package/src/ui/a/Charts/PieChart/styles.scss +48 -0
- package/src/ui/a/Charts/index.js +3 -0
- package/src/ui/a/Tooltip/styles.scss +1 -1
- package/src/ui/a/index.js +1 -1
- package/src/ui/f/FormInput/FormInput.jsx +11 -0
- package/src/ui/f/fields/FileUpload/FileUpload.jsx +24 -4
- package/src/ui/f/fields/LatexPreviewInput/LatexPreviewInput.jsx +91 -0
- package/src/ui/f/fields/LatexPreviewInput/convertLatexToHtml.jsx +38 -0
- package/src/ui/f/fields/LatexPreviewInput/index.js +3 -0
- package/src/ui/f/fields/LatexPreviewInput/styles.scss +24 -0
- package/src/ui/f/fields/index.js +4 -0
- package/src/ui/g/FormBuilder/FormBuilder.jsx +0 -3
- package/src/ui/g/FormBuilder/common/Builder/Builder.jsx +0 -2
- package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +4 -7
- package/src/ui/g/FormBuilder/common/Builder/common/Section/Section.jsx +0 -2
- package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +0 -2
- package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +49 -64
- package/src/ui/utils/formatting.js +133 -0
- package/src/ui/utils/index.js +3 -0
- package/tests/__snapshots__/Storyshots.test.js.snap +2227 -296
- package/tests/emptyMock.js +3 -0
- package/tests/mockTextEncoder.js +7 -0
- package/tests/test-setup.js +7 -0
- package/dist/cjs/a/AreaChart/styles.scss +0 -89
- package/dist/es/a/AreaChart/styles.scss +0 -89
- package/src/ui/a/AreaChart/styles.scss +0 -89
- /package/dist/cjs/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
- /package/dist/es/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
- /package/src/ui/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
|
@@ -4,18 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var React = _react;
|
|
8
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
10
|
var _recharts = require("recharts");
|
|
10
11
|
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
12
|
+
var _utils = require("../../../utils");
|
|
13
|
+
var _Common = require("../Common");
|
|
11
14
|
require("./styles.scss");
|
|
12
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
-
// front/packages/design-system/src/ui/a/AreaChart/AreaChart.jsx
|
|
16
|
-
|
|
17
|
-
// Local Definitions
|
|
18
|
-
|
|
19
18
|
const baseClassName = _exports.default.base;
|
|
20
19
|
const componentClassName = 'area-chart';
|
|
21
20
|
const AreaChart = _ref => {
|
|
@@ -31,19 +30,16 @@ const AreaChart = _ref => {
|
|
|
31
30
|
colors,
|
|
32
31
|
filled,
|
|
33
32
|
height,
|
|
34
|
-
width
|
|
35
|
-
|
|
33
|
+
width,
|
|
34
|
+
isTimeFormat,
|
|
35
|
+
dateFormat,
|
|
36
|
+
capitalizedLegend
|
|
36
37
|
} = _ref;
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
...item,
|
|
44
|
-
bounds: [lowerBound - margin, upperBound + margin]
|
|
45
|
-
};
|
|
46
|
-
});
|
|
38
|
+
const allYLabels = yKeys.map(key => ({
|
|
39
|
+
label: key,
|
|
40
|
+
color: colors[yKeys.indexOf(key)]
|
|
41
|
+
}));
|
|
42
|
+
const [selectedYLabels, setSelectedYLabels] = (0, _react.useState)(allYLabels);
|
|
47
43
|
const yAxisBounds = () => {
|
|
48
44
|
const yValues = data.map(item => yKeys.map(key => item[key]));
|
|
49
45
|
const min = Math.min(...yValues.flat());
|
|
@@ -51,58 +47,24 @@ const AreaChart = _ref => {
|
|
|
51
47
|
const margin = (max - min) * 0.1;
|
|
52
48
|
return [min - margin, max + margin];
|
|
53
49
|
};
|
|
54
|
-
const CustomTooltipContent = _ref2 => {
|
|
55
|
-
let {
|
|
56
|
-
active,
|
|
57
|
-
payload,
|
|
58
|
-
label
|
|
59
|
-
} = _ref2;
|
|
60
|
-
if (active && payload && payload.length) {
|
|
61
|
-
const newPayload = payload.filter(item => item.name !== 'bounds');
|
|
62
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
63
|
-
className: "custom-tooltip"
|
|
64
|
-
}, /*#__PURE__*/React.createElement("p", {
|
|
65
|
-
className: "label"
|
|
66
|
-
}, `${xLabel}: ${label}`), newPayload.map(entry => /*#__PURE__*/React.createElement("p", {
|
|
67
|
-
className: "label",
|
|
68
|
-
key: `${entry.name}`,
|
|
69
|
-
style: {
|
|
70
|
-
color: entry.color
|
|
71
|
-
}
|
|
72
|
-
}, `${entry.name}: ${entry.value}`)));
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
};
|
|
76
|
-
const CustomLegend = _ref3 => {
|
|
77
|
-
let {
|
|
78
|
-
colorsArray,
|
|
79
|
-
yKeysArray
|
|
80
|
-
} = _ref3;
|
|
81
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
82
|
-
className: "custom-legend"
|
|
83
|
-
}, yKeysArray.map((key, index) => /*#__PURE__*/React.createElement("div", {
|
|
84
|
-
key: key,
|
|
85
|
-
className: "item"
|
|
86
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
87
|
-
className: "line",
|
|
88
|
-
style: {
|
|
89
|
-
backgroundColor: colorsArray[index]
|
|
90
|
-
}
|
|
91
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
92
|
-
className: "text"
|
|
93
|
-
}, key))));
|
|
94
|
-
};
|
|
95
50
|
return /*#__PURE__*/React.createElement("div", {
|
|
96
51
|
id: id,
|
|
97
52
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
98
|
-
}, /*#__PURE__*/React.createElement("
|
|
53
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: "chart-header"
|
|
55
|
+
}, /*#__PURE__*/React.createElement("h3", null, title), /*#__PURE__*/React.createElement(_Common.YLabelsDropDown, {
|
|
56
|
+
allYLabels: allYLabels,
|
|
57
|
+
selectedYLabels: selectedYLabels,
|
|
58
|
+
setSelectedYLabels: setSelectedYLabels
|
|
59
|
+
})), /*#__PURE__*/React.createElement(_Common.CustomLegend, {
|
|
99
60
|
colorsArray: colors,
|
|
100
|
-
yKeysArray: yKeys
|
|
61
|
+
yKeysArray: yKeys,
|
|
62
|
+
capitalizedLegend: capitalizedLegend
|
|
101
63
|
}), /*#__PURE__*/React.createElement(_recharts.ResponsiveContainer, {
|
|
102
64
|
width: width,
|
|
103
65
|
height: height
|
|
104
66
|
}, /*#__PURE__*/React.createElement(_recharts.AreaChart, {
|
|
105
|
-
data:
|
|
67
|
+
data: data
|
|
106
68
|
}, /*#__PURE__*/React.createElement(_recharts.CartesianGrid, {
|
|
107
69
|
strokeDasharray: "3 3"
|
|
108
70
|
}), /*#__PURE__*/React.createElement(_recharts.XAxis, {
|
|
@@ -114,7 +76,8 @@ const AreaChart = _ref => {
|
|
|
114
76
|
},
|
|
115
77
|
axisLine: false,
|
|
116
78
|
tickLine: false,
|
|
117
|
-
tickCount: 3
|
|
79
|
+
tickCount: 3,
|
|
80
|
+
tickFormatter: value => (0, _utils.formatDate)(value, dateFormat)
|
|
118
81
|
}), /*#__PURE__*/React.createElement(_recharts.YAxis, {
|
|
119
82
|
domain: yAxisBounds,
|
|
120
83
|
scale: "linear",
|
|
@@ -123,7 +86,7 @@ const AreaChart = _ref => {
|
|
|
123
86
|
value: yLabel,
|
|
124
87
|
angle: -90,
|
|
125
88
|
position: 'left',
|
|
126
|
-
offset:
|
|
89
|
+
offset: -3,
|
|
127
90
|
style: {
|
|
128
91
|
textAnchor: 'middle'
|
|
129
92
|
}
|
|
@@ -133,10 +96,18 @@ const AreaChart = _ref => {
|
|
|
133
96
|
bottom: 10
|
|
134
97
|
},
|
|
135
98
|
axisLine: false,
|
|
136
|
-
tickLine:
|
|
137
|
-
tickFormatter: value =>
|
|
99
|
+
tickLine: false,
|
|
100
|
+
tickFormatter: value => {
|
|
101
|
+
if (isTimeFormat) {
|
|
102
|
+
return (0, _utils.formatTime)(value);
|
|
103
|
+
}
|
|
104
|
+
return value.toFixed(2);
|
|
105
|
+
}
|
|
138
106
|
}), /*#__PURE__*/React.createElement(_recharts.Tooltip, {
|
|
139
|
-
content: /*#__PURE__*/React.createElement(CustomTooltipContent,
|
|
107
|
+
content: /*#__PURE__*/React.createElement(_Common.CustomTooltipContent, {
|
|
108
|
+
dateFormat: dateFormat,
|
|
109
|
+
isTimeFormat: isTimeFormat
|
|
110
|
+
})
|
|
140
111
|
}), filled && /*#__PURE__*/React.createElement(_recharts.Area, {
|
|
141
112
|
id: "bounds",
|
|
142
113
|
type: "linear",
|
|
@@ -148,12 +119,12 @@ const AreaChart = _ref => {
|
|
|
148
119
|
dot: false,
|
|
149
120
|
label: false,
|
|
150
121
|
isAnimationActive: false
|
|
151
|
-
}),
|
|
152
|
-
id: key,
|
|
153
|
-
key: key,
|
|
122
|
+
}), selectedYLabels.map(key => /*#__PURE__*/React.createElement(_recharts.Area, {
|
|
123
|
+
id: key.label,
|
|
124
|
+
key: key.label,
|
|
154
125
|
type: "linear",
|
|
155
|
-
dataKey: key,
|
|
156
|
-
stroke:
|
|
126
|
+
dataKey: key.label,
|
|
127
|
+
stroke: key.color,
|
|
157
128
|
fill: "none",
|
|
158
129
|
connectNulls: true,
|
|
159
130
|
dot: false,
|
|
@@ -164,21 +135,66 @@ const AreaChart = _ref => {
|
|
|
164
135
|
})))));
|
|
165
136
|
};
|
|
166
137
|
AreaChart.propTypes = {
|
|
138
|
+
/**
|
|
139
|
+
* Array of data objects to be displayed in the chart.
|
|
140
|
+
*/
|
|
167
141
|
// eslint-disable-next-line react/forbid-prop-types
|
|
168
142
|
data: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
143
|
+
/**
|
|
144
|
+
* Title of the chart.
|
|
145
|
+
*/
|
|
169
146
|
title: _propTypes.default.string.isRequired,
|
|
147
|
+
/**
|
|
148
|
+
* Key for the x-axis data.
|
|
149
|
+
*/
|
|
170
150
|
xKey: _propTypes.default.string.isRequired,
|
|
151
|
+
/**
|
|
152
|
+
* Array of keys for the y-axis data.
|
|
153
|
+
*/
|
|
171
154
|
yKeys: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
155
|
+
/**
|
|
156
|
+
* Label for the x-axis.
|
|
157
|
+
*/
|
|
172
158
|
xLabel: _propTypes.default.string,
|
|
159
|
+
/**
|
|
160
|
+
* Label for the y-axis.
|
|
161
|
+
*/
|
|
173
162
|
yLabel: _propTypes.default.string,
|
|
163
|
+
/**
|
|
164
|
+
* Array of colors corresponding to the y-axis data keys.
|
|
165
|
+
*/
|
|
174
166
|
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
167
|
+
/**
|
|
168
|
+
* Boolean to determine if the area under the curve should be filled.
|
|
169
|
+
*/
|
|
175
170
|
filled: _propTypes.default.bool,
|
|
171
|
+
/**
|
|
172
|
+
* Height of the chart.
|
|
173
|
+
*/
|
|
176
174
|
height: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
177
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Width of the chart.
|
|
177
|
+
*/
|
|
178
|
+
width: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
179
|
+
/**
|
|
180
|
+
* Flag on whether to capitalize legend keys
|
|
181
|
+
*/
|
|
182
|
+
capitalizedLegend: _propTypes.default.bool,
|
|
183
|
+
/**
|
|
184
|
+
* Flag on whether it is a timeformat or not
|
|
185
|
+
*/
|
|
186
|
+
isTimeFormat: _propTypes.default.bool,
|
|
187
|
+
/**
|
|
188
|
+
* The type of format for the datetime value
|
|
189
|
+
*/
|
|
190
|
+
dateFormat: _propTypes.default.oneOf(Object.values(_utils.DATE_FORMATS))
|
|
178
191
|
};
|
|
179
192
|
AreaChart.defaultProps = {
|
|
180
193
|
filled: false,
|
|
181
194
|
width: '100%',
|
|
182
|
-
height: 300
|
|
195
|
+
height: 300,
|
|
196
|
+
capitalizedLegend: false,
|
|
197
|
+
isTimeFormat: false,
|
|
198
|
+
dateFormat: _utils.DATE_FORMATS.HUMAN_READABLE
|
|
183
199
|
};
|
|
184
200
|
var _default = exports.default = AreaChart;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@use "@pareto-engineering/bem";
|
|
2
|
+
|
|
3
|
+
$default-margin: 1rem;
|
|
4
|
+
$default-padding: 1rem;
|
|
5
|
+
$default-box-shadow: 0 .25rem .75rem var(--ui-lines);
|
|
6
|
+
$default-text-font-size: calc(var(--s-1) * 1rem);
|
|
7
|
+
|
|
8
|
+
.#{bem.$base} {
|
|
9
|
+
&.area-chart {
|
|
10
|
+
background-color: var(--background-far);
|
|
11
|
+
border-radius: var(--theme-default-border-radius);
|
|
12
|
+
box-shadow: $default-box-shadow;
|
|
13
|
+
margin: $default-margin 0;
|
|
14
|
+
padding: $default-padding;
|
|
15
|
+
|
|
16
|
+
.chart-header {
|
|
17
|
+
align-items: center;
|
|
18
|
+
display: flex;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
margin-bottom: $default-margin;
|
|
21
|
+
|
|
22
|
+
h3 {
|
|
23
|
+
color: var(--subtitle);
|
|
24
|
+
margin: calc($default-margin / 5);
|
|
25
|
+
text-align: left;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* stylelint-disable selector-max-compound-selectors -- nested elements */
|
|
30
|
+
.recharts-wrapper {
|
|
31
|
+
.recharts-surface {
|
|
32
|
+
.recharts-cartesian-grid line {
|
|
33
|
+
stroke: var(--ui-lines);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.recharts-text {
|
|
37
|
+
fill: var(--soft-paragraph);
|
|
38
|
+
font-size: calc($default-text-font-size * .75);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.recharts-text.recharts-label {
|
|
42
|
+
fill: var(--paragraph);
|
|
43
|
+
font-size: $default-text-font-size;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var React = _react;
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _recharts = require("recharts");
|
|
11
|
+
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
12
|
+
var _Common = require("../Common");
|
|
13
|
+
require("./styles.scss");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
// Local Definitions
|
|
18
|
+
|
|
19
|
+
const baseClassName = _exports.default.base;
|
|
20
|
+
const componentClassName = 'bar-chart';
|
|
21
|
+
const BarChart = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
id,
|
|
24
|
+
className: userClassName,
|
|
25
|
+
data,
|
|
26
|
+
title,
|
|
27
|
+
xKey,
|
|
28
|
+
yKeys,
|
|
29
|
+
xLabel,
|
|
30
|
+
yLabel,
|
|
31
|
+
colors,
|
|
32
|
+
height,
|
|
33
|
+
width,
|
|
34
|
+
isTimeFormat,
|
|
35
|
+
capitalizedLegend
|
|
36
|
+
} = _ref;
|
|
37
|
+
const allYLabels = yKeys.map(key => ({
|
|
38
|
+
label: key,
|
|
39
|
+
color: colors[yKeys.indexOf(key)]
|
|
40
|
+
}));
|
|
41
|
+
const [selectedYLabels, setSelectedYLabels] = (0, _react.useState)(allYLabels);
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
id: id,
|
|
44
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
45
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: "chart-header"
|
|
47
|
+
}, /*#__PURE__*/React.createElement("h3", null, title), /*#__PURE__*/React.createElement(_Common.YLabelsDropDown, {
|
|
48
|
+
allYLabels: allYLabels,
|
|
49
|
+
selectedYLabels: selectedYLabels,
|
|
50
|
+
setSelectedYLabels: setSelectedYLabels
|
|
51
|
+
})), /*#__PURE__*/React.createElement(_Common.CustomLegend, {
|
|
52
|
+
colorsArray: selectedYLabels.map(item => item.color),
|
|
53
|
+
yKeysArray: selectedYLabels.map(item => item.label),
|
|
54
|
+
capitalizedLegend: capitalizedLegend
|
|
55
|
+
}), /*#__PURE__*/React.createElement(_recharts.ResponsiveContainer, {
|
|
56
|
+
width: width,
|
|
57
|
+
height: height
|
|
58
|
+
}, /*#__PURE__*/React.createElement(_recharts.BarChart, {
|
|
59
|
+
data: data
|
|
60
|
+
}, /*#__PURE__*/React.createElement(_recharts.CartesianGrid, {
|
|
61
|
+
vertical: false
|
|
62
|
+
}), /*#__PURE__*/React.createElement(_recharts.XAxis, {
|
|
63
|
+
dataKey: xKey,
|
|
64
|
+
label: {
|
|
65
|
+
value: xLabel,
|
|
66
|
+
position: 'insideBottom',
|
|
67
|
+
offset: -5
|
|
68
|
+
} // Adjusted offset for padding
|
|
69
|
+
,
|
|
70
|
+
axisLine: false,
|
|
71
|
+
tickLine: false,
|
|
72
|
+
tickCount: 3
|
|
73
|
+
}), /*#__PURE__*/React.createElement(_recharts.YAxis, {
|
|
74
|
+
label: {
|
|
75
|
+
value: yLabel,
|
|
76
|
+
angle: -90,
|
|
77
|
+
position: 'insideLeft',
|
|
78
|
+
offset: 15
|
|
79
|
+
},
|
|
80
|
+
axisLine: false,
|
|
81
|
+
tickLine: false
|
|
82
|
+
}), /*#__PURE__*/React.createElement(_recharts.Tooltip, {
|
|
83
|
+
content: /*#__PURE__*/React.createElement(_Common.CustomTooltipContent, {
|
|
84
|
+
isTimeFormat: isTimeFormat
|
|
85
|
+
})
|
|
86
|
+
}), selectedYLabels.map(key => /*#__PURE__*/React.createElement(_recharts.Bar, {
|
|
87
|
+
stackId: "a",
|
|
88
|
+
id: key.label,
|
|
89
|
+
key: key.label,
|
|
90
|
+
dataKey: key.label,
|
|
91
|
+
fill: key.color
|
|
92
|
+
})))));
|
|
93
|
+
};
|
|
94
|
+
BarChart.propTypes = {
|
|
95
|
+
/**
|
|
96
|
+
* Array of data objects to be displayed in the chart.
|
|
97
|
+
*/
|
|
98
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
99
|
+
data: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
100
|
+
/**
|
|
101
|
+
* Title of the chart.
|
|
102
|
+
*/
|
|
103
|
+
title: _propTypes.default.string.isRequired,
|
|
104
|
+
/**
|
|
105
|
+
* Key for the x-axis data.
|
|
106
|
+
*/
|
|
107
|
+
xKey: _propTypes.default.string.isRequired,
|
|
108
|
+
/**
|
|
109
|
+
* Array of keys for the y-axis data.
|
|
110
|
+
*/
|
|
111
|
+
yKeys: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
112
|
+
/**
|
|
113
|
+
* Label for the x-axis.
|
|
114
|
+
*/
|
|
115
|
+
xLabel: _propTypes.default.string,
|
|
116
|
+
/**
|
|
117
|
+
* Label for the y-axis.
|
|
118
|
+
*/
|
|
119
|
+
yLabel: _propTypes.default.string,
|
|
120
|
+
/**
|
|
121
|
+
* Array of colors corresponding to the y-axis data keys.
|
|
122
|
+
*/
|
|
123
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
124
|
+
/**
|
|
125
|
+
* Height of the chart.
|
|
126
|
+
*/
|
|
127
|
+
height: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
128
|
+
/**
|
|
129
|
+
* Width of the chart.
|
|
130
|
+
*/
|
|
131
|
+
width: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
|
|
132
|
+
};
|
|
133
|
+
BarChart.defaultProps = {
|
|
134
|
+
width: '100%',
|
|
135
|
+
height: 300
|
|
136
|
+
};
|
|
137
|
+
var _default = exports.default = BarChart;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BarChart", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _BarChart.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _BarChart = _interopRequireDefault(require("./BarChart"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@use "@pareto-engineering/bem";
|
|
2
|
+
|
|
3
|
+
$default-margin: 1rem;
|
|
4
|
+
$default-padding: 1rem;
|
|
5
|
+
$default-box-shadow: 0 .25rem .75rem var(--ui-lines);
|
|
6
|
+
$default-text-font-size: calc(var(--s-1) * 1rem);
|
|
7
|
+
|
|
8
|
+
.#{bem.$base} {
|
|
9
|
+
&.bar-chart {
|
|
10
|
+
background-color: var(--background-far);
|
|
11
|
+
border-radius: var(--theme-default-border-radius);
|
|
12
|
+
box-shadow: $default-box-shadow;
|
|
13
|
+
margin: $default-margin 0;
|
|
14
|
+
padding: $default-padding;
|
|
15
|
+
|
|
16
|
+
.chart-header {
|
|
17
|
+
align-items: center;
|
|
18
|
+
display: flex;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
margin-bottom: $default-margin;
|
|
21
|
+
|
|
22
|
+
h3 {
|
|
23
|
+
color: var(--subtitle);
|
|
24
|
+
margin: calc($default-margin / 5);
|
|
25
|
+
text-align: left;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* stylelint-disable selector-max-compound-selectors -- nested elements */
|
|
30
|
+
.recharts-wrapper {
|
|
31
|
+
.recharts-surface {
|
|
32
|
+
.recharts-cartesian-grid line {
|
|
33
|
+
stroke: var(--ui-lines);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.recharts-text {
|
|
37
|
+
fill: var(--soft-paragraph);
|
|
38
|
+
font-size: calc($default-text-font-size * .75);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.recharts-text.recharts-label {
|
|
42
|
+
fill: var(--paragraph);
|
|
43
|
+
font-size: $default-text-font-size;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
10
|
+
var _utils = require("../../../../utils");
|
|
11
|
+
require("./styles.scss");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
const baseClassName = _exports.default.base;
|
|
16
|
+
const componentClassName = 'custom-legend';
|
|
17
|
+
const CustomLegend = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
id,
|
|
20
|
+
className: userClassName,
|
|
21
|
+
colorsArray,
|
|
22
|
+
yKeysArray,
|
|
23
|
+
orientation,
|
|
24
|
+
getLegendItemTitle,
|
|
25
|
+
getLegendItemSubtitle,
|
|
26
|
+
capitalizedLegend
|
|
27
|
+
} = _ref;
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
id: id,
|
|
30
|
+
className: [baseClassName, componentClassName, userClassName, orientation].filter(e => e).join(' ')
|
|
31
|
+
}, yKeysArray.map((key, index) => /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
key: key,
|
|
33
|
+
className: "item"
|
|
34
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "title"
|
|
36
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
37
|
+
className: "dot",
|
|
38
|
+
style: {
|
|
39
|
+
backgroundColor: colorsArray[index]
|
|
40
|
+
}
|
|
41
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
42
|
+
className: "text"
|
|
43
|
+
}, capitalizedLegend ? (0, _utils.snakeCaseToTitleCase)(getLegendItemTitle(key)) : getLegendItemTitle(key))), /*#__PURE__*/React.createElement("span", {
|
|
44
|
+
className: "sub-title"
|
|
45
|
+
}, getLegendItemSubtitle(key)))));
|
|
46
|
+
};
|
|
47
|
+
CustomLegend.propTypes = {
|
|
48
|
+
/**
|
|
49
|
+
* The id of the dropdown component.
|
|
50
|
+
*/
|
|
51
|
+
id: _propTypes.default.string,
|
|
52
|
+
/**
|
|
53
|
+
* Additional class names for the dropdown component.
|
|
54
|
+
*/
|
|
55
|
+
className: _propTypes.default.string,
|
|
56
|
+
/**
|
|
57
|
+
* Array of colors corresponding to the y-axis data keys.
|
|
58
|
+
*/
|
|
59
|
+
colorsArray: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
60
|
+
/**
|
|
61
|
+
* Array of keys for the y-axis data.
|
|
62
|
+
*/
|
|
63
|
+
yKeysArray: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
64
|
+
/**
|
|
65
|
+
* The orientation of the Legend
|
|
66
|
+
*/
|
|
67
|
+
orientation: _propTypes.default.oneOf(['vertical', 'horizontal']),
|
|
68
|
+
/**
|
|
69
|
+
* The function to get the legendItemKey
|
|
70
|
+
*/
|
|
71
|
+
getLegendItemTitle: _propTypes.default.func,
|
|
72
|
+
/**
|
|
73
|
+
* The function to get legend children
|
|
74
|
+
*/
|
|
75
|
+
getLegendItemSubtitle: _propTypes.default.func,
|
|
76
|
+
/**
|
|
77
|
+
* Flag on whether to capitalize legend keys
|
|
78
|
+
*/
|
|
79
|
+
capitalizedLegend: _propTypes.default.bool
|
|
80
|
+
};
|
|
81
|
+
CustomLegend.defaultProps = {
|
|
82
|
+
orientation: 'horizontal',
|
|
83
|
+
getLegendItemTitle: key => key,
|
|
84
|
+
/* eslint-disable no-unused-vars */
|
|
85
|
+
getLegendItemSubtitle: () => {},
|
|
86
|
+
capitalizedLegend: false
|
|
87
|
+
};
|
|
88
|
+
var _default = exports.default = CustomLegend;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "CustomLegend", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _CustomLegend.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _CustomLegend = _interopRequireDefault(require("./CustomLegend"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@use "@pareto-engineering/bem";
|
|
2
|
+
|
|
3
|
+
$default-padding: 1rem;
|
|
4
|
+
$default-margin: 1rem;
|
|
5
|
+
$default-text-font-size: calc(var(--s-1) * 1rem);
|
|
6
|
+
$default-border-radius: .25rem;
|
|
7
|
+
$default-legend-gap: .625rem;
|
|
8
|
+
$default-legend-padding: calc($default-padding * .125) calc($default-padding * .625);
|
|
9
|
+
$default-legend-dot-width: .5rem;
|
|
10
|
+
$default-legend-dot-height: .5rem;
|
|
11
|
+
$default-legend-dot-margin-right: .3125rem;
|
|
12
|
+
$default-box-shadow: 0 4px 16px 0 var(--soft-shadow);
|
|
13
|
+
|
|
14
|
+
.#{bem.$base} {
|
|
15
|
+
&.custom-legend {
|
|
16
|
+
gap: $default-legend-gap;
|
|
17
|
+
justify-content: flex-end;
|
|
18
|
+
padding-bottom: $default-padding;
|
|
19
|
+
padding-right: calc($default-padding * .25);
|
|
20
|
+
|
|
21
|
+
&.vertical {
|
|
22
|
+
display: block;
|
|
23
|
+
margin-right: calc($default-margin * 2);
|
|
24
|
+
min-width: fit-content;
|
|
25
|
+
|
|
26
|
+
.item {
|
|
27
|
+
box-shadow: $default-box-shadow;
|
|
28
|
+
padding-top: $default-padding;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&.horizontal {
|
|
33
|
+
display: flex;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.item {
|
|
37
|
+
border-radius: $default-border-radius;
|
|
38
|
+
padding: $default-legend-padding;
|
|
39
|
+
|
|
40
|
+
.title {
|
|
41
|
+
align-items: center;
|
|
42
|
+
display: flex;
|
|
43
|
+
|
|
44
|
+
.dot {
|
|
45
|
+
border-radius: 50%;
|
|
46
|
+
display: inline-block;
|
|
47
|
+
height: $default-legend-dot-height;
|
|
48
|
+
margin-right: $default-legend-dot-margin-right;
|
|
49
|
+
width: $default-legend-dot-width;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.text {
|
|
53
|
+
color: var(--paragraph);
|
|
54
|
+
font-size: calc($default-text-font-size * .75);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.sub-title {
|
|
59
|
+
color: var(--heading);
|
|
60
|
+
display: flex;
|
|
61
|
+
font-size: calc($default-text-font-size * 1.2);
|
|
62
|
+
font-weight: 500;
|
|
63
|
+
justify-content: flex-end;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|