@apia/charts 1.0.2 → 2.0.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/dist/charts/ChartContext.js +6 -0
- package/dist/charts/ChartContext.js.map +1 -0
- package/dist/charts/ChartRenderer.d.ts +17 -0
- package/dist/charts/ChartRenderer.d.ts.map +1 -0
- package/dist/charts/ChartRenderer.js +175 -0
- package/dist/charts/ChartRenderer.js.map +1 -0
- package/dist/charts/horizontalBars/Bar.js +226 -0
- package/dist/charts/horizontalBars/Bar.js.map +1 -0
- package/dist/charts/horizontalBars/HorizontalBars.js +374 -0
- package/dist/charts/horizontalBars/HorizontalBars.js.map +1 -0
- package/dist/charts/linear/LineChart.js +528 -0
- package/dist/charts/linear/LineChart.js.map +1 -0
- package/dist/charts/linear/Node.js +56 -0
- package/dist/charts/linear/Node.js.map +1 -0
- package/dist/charts/pie/Pie.js +184 -0
- package/dist/charts/pie/Pie.js.map +1 -0
- package/dist/charts/pie/Slice.js +96 -0
- package/dist/charts/pie/Slice.js.map +1 -0
- package/dist/charts/pie/usePieAnimation.js +123 -0
- package/dist/charts/pie/usePieAnimation.js.map +1 -0
- package/dist/charts/types.d.ts +188 -0
- package/dist/charts/types.d.ts.map +1 -0
- package/dist/charts/util/ChartSelector.js +36 -0
- package/dist/charts/util/ChartSelector.js.map +1 -0
- package/dist/charts/util/ColoredLegendItem.js +46 -0
- package/dist/charts/util/ColoredLegendItem.js.map +1 -0
- package/dist/charts/util/EmptyGrid.d.ts +8 -0
- package/dist/charts/util/EmptyGrid.d.ts.map +1 -0
- package/dist/charts/util/EmptyGrid.js +51 -0
- package/dist/charts/util/EmptyGrid.js.map +1 -0
- package/dist/charts/util/LegendContainer.js +53 -0
- package/dist/charts/util/LegendContainer.js.map +1 -0
- package/dist/charts/util/NumberedLegendItem.js +45 -0
- package/dist/charts/util/NumberedLegendItem.js.map +1 -0
- package/dist/charts/util/getBarColor.js +29 -0
- package/dist/charts/util/getBarColor.js.map +1 -0
- package/dist/charts/util/parseMargin.js +11 -0
- package/dist/charts/util/parseMargin.js.map +1 -0
- package/dist/charts/util/useChartStyles.js +35 -0
- package/dist/charts/util/useChartStyles.js.map +1 -0
- package/dist/charts/verticalBars/Bar.js +239 -0
- package/dist/charts/verticalBars/Bar.js.map +1 -0
- package/dist/charts/verticalBars/VerticalBars.js +394 -0
- package/dist/charts/verticalBars/VerticalBars.js.map +1 -0
- package/dist/charts/waterfallBars/WaterfallBar.js +84 -0
- package/dist/charts/waterfallBars/WaterfallBar.js.map +1 -0
- package/dist/charts/waterfallBars/WaterfallBars.js +289 -0
- package/dist/charts/waterfallBars/WaterfallBars.js.map +1 -0
- package/dist/index.d.ts +6 -250
- package/dist/index.js +4 -4263
- package/dist/index.js.map +1 -1
- package/dist/widgets/WidgetContainer.d.ts +10 -0
- package/dist/widgets/WidgetContainer.d.ts.map +1 -0
- package/dist/widgets/WidgetContainer.js +68 -0
- package/dist/widgets/WidgetContainer.js.map +1 -0
- package/dist/widgets/counter/Counter.js +108 -0
- package/dist/widgets/counter/Counter.js.map +1 -0
- package/dist/widgets/custom/useCustomWidget.js +64 -0
- package/dist/widgets/custom/useCustomWidget.js.map +1 -0
- package/dist/widgets/custom/util.js +9 -0
- package/dist/widgets/custom/util.js.map +1 -0
- package/dist/widgets/oxford/Oxford.js +241 -0
- package/dist/widgets/oxford/Oxford.js.map +1 -0
- package/dist/widgets/ring/Ring.js +123 -0
- package/dist/widgets/ring/Ring.js.map +1 -0
- package/dist/widgets/scale/Scale.js +145 -0
- package/dist/widgets/scale/Scale.js.map +1 -0
- package/dist/widgets/speedMeter/SpeedMeter.js +187 -0
- package/dist/widgets/speedMeter/SpeedMeter.js.map +1 -0
- package/dist/widgets/tLight/TLight.js +134 -0
- package/dist/widgets/tLight/TLight.js.map +1 -0
- package/dist/widgets/thermometer/Thermometer.js +144 -0
- package/dist/widgets/thermometer/Thermometer.js.map +1 -0
- package/dist/widgets/thermometer/util.js +31 -0
- package/dist/widgets/thermometer/util.js.map +1 -0
- package/dist/widgets/types.d.ts +41 -0
- package/dist/widgets/types.d.ts.map +1 -0
- package/package.json +30 -43
- package/LICENSE.md +0 -21
- package/README.md +0 -1
- package/cleanDist.json +0 -3
package/dist/index.js
CHANGED
|
@@ -1,4263 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { useImperativeComponentContext, makeImperativeComponent, arrayOrArray, useImperativeComponentEvents, getValueByPath, usePanAndZoom, getLabel, animate, addBoundary, usePrevious, getIndex, noNaN } from '@apia/util';
|
|
6
|
-
import { scaleBand, scaleLog, scaleLinear, scaleOrdinal } from '@visx/scale';
|
|
7
|
-
import { Grid } from '@visx/visx';
|
|
8
|
-
import { Group } from '@visx/group';
|
|
9
|
-
import { BarGroupHorizontal, BarGroup, LinePath, Line } from '@visx/shape';
|
|
10
|
-
import { AxisLeft, AxisBottom } from '@visx/axis';
|
|
11
|
-
import tinycolor from 'tinycolor2';
|
|
12
|
-
import { localPoint } from '@visx/event';
|
|
13
|
-
import { ApiaUtil, SimpleButton } from '@apia/components';
|
|
14
|
-
import { icons } from '@apia/icons';
|
|
15
|
-
import Pie from '@visx/shape/lib/shapes/Pie';
|
|
16
|
-
import { min, max, extent } from 'd3-array';
|
|
17
|
-
import * as allCurves from '@visx/curve';
|
|
18
|
-
import { Fragment as Fragment$1 } from 'theme-ui/jsx-runtime';
|
|
19
|
-
import { GridRows } from '@visx/grid';
|
|
20
|
-
import { useGauge } from 'use-gauge';
|
|
21
|
-
|
|
22
|
-
function parseMargin(margin = {
|
|
23
|
-
left: 100,
|
|
24
|
-
right: 50,
|
|
25
|
-
top: 50,
|
|
26
|
-
bottom: 70
|
|
27
|
-
}) {
|
|
28
|
-
return typeof margin === "number" ? { left: margin, right: margin, top: margin, bottom: margin } : margin;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const ColoredLegendItem = ({
|
|
32
|
-
groupId,
|
|
33
|
-
title,
|
|
34
|
-
color,
|
|
35
|
-
className,
|
|
36
|
-
isHighlighted,
|
|
37
|
-
isAnyHighlighted,
|
|
38
|
-
avoidEvent
|
|
39
|
-
}) => {
|
|
40
|
-
const { id: chartId } = useImperativeComponentContext();
|
|
41
|
-
const handleMouseEnter = useCallback(() => {
|
|
42
|
-
if (avoidEvent) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
chartMethods(chartId, "highlight", groupId);
|
|
46
|
-
}, [avoidEvent, chartId, groupId]);
|
|
47
|
-
const handleMouseLeave = useCallback(() => {
|
|
48
|
-
if (avoidEvent) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
new ApiaUtil().tooltips.closeAll();
|
|
52
|
-
chartMethods(chartId, "highlight", "");
|
|
53
|
-
}, [avoidEvent, chartId]);
|
|
54
|
-
return /* @__PURE__ */ jsx(
|
|
55
|
-
SimpleButton,
|
|
56
|
-
{
|
|
57
|
-
variant: "link",
|
|
58
|
-
className: `${className != null ? className : ""} ${isHighlighted ? "highlight" : ""} ${isAnyHighlighted && !isHighlighted ? "isBlurred" : ""} legendItem`,
|
|
59
|
-
iconColor: color || "black",
|
|
60
|
-
icon: color === "transparent" ? void 0 : icons.SquareFilled,
|
|
61
|
-
onMouseEnter: handleMouseEnter,
|
|
62
|
-
onMouseLeave: handleMouseLeave,
|
|
63
|
-
children: title
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const NumberedLegendItem = ({
|
|
69
|
-
groupId,
|
|
70
|
-
title,
|
|
71
|
-
className,
|
|
72
|
-
isHighlighted,
|
|
73
|
-
isAnyHighlighted,
|
|
74
|
-
avoidEvent
|
|
75
|
-
}) => {
|
|
76
|
-
const { id: chartId } = useImperativeComponentContext();
|
|
77
|
-
const handleMouseEnter = useCallback(() => {
|
|
78
|
-
if (avoidEvent) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
chartMethods(chartId, "highlight", groupId);
|
|
82
|
-
}, [avoidEvent, chartId, groupId]);
|
|
83
|
-
const handleMouseLeave = useCallback(() => {
|
|
84
|
-
if (avoidEvent) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
new ApiaUtil().tooltips.closeAll();
|
|
88
|
-
chartMethods(chartId, "highlight", "");
|
|
89
|
-
}, [avoidEvent, chartId]);
|
|
90
|
-
return /* @__PURE__ */ jsx(
|
|
91
|
-
SimpleButton,
|
|
92
|
-
{
|
|
93
|
-
variant: "link",
|
|
94
|
-
className: `${className != null ? className : ""} ${isHighlighted ? "highlight" : ""} ${isAnyHighlighted && !isHighlighted ? "isBlurred" : ""} legendItem`,
|
|
95
|
-
sx: {
|
|
96
|
-
opacity: isAnyHighlighted && !isHighlighted ? "0.15" : "1"
|
|
97
|
-
},
|
|
98
|
-
onMouseEnter: handleMouseEnter,
|
|
99
|
-
onMouseLeave: handleMouseLeave,
|
|
100
|
-
children: title
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const [legendContainerMethods, , LegendContainer] = makeImperativeComponent()({
|
|
106
|
-
initialState: {
|
|
107
|
-
highlightedBarGroup: ""
|
|
108
|
-
},
|
|
109
|
-
methods: {
|
|
110
|
-
highlight(setState, highlightedBarGroup) {
|
|
111
|
-
console.log(highlightedBarGroup);
|
|
112
|
-
setState({ highlightedBarGroup });
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
Component: ({
|
|
116
|
-
references,
|
|
117
|
-
highlightedBarGroup,
|
|
118
|
-
avoidEvent,
|
|
119
|
-
useNumbered
|
|
120
|
-
}) => {
|
|
121
|
-
return /* @__PURE__ */ jsx(Box, { className: `legendContainer`, children: !useNumbered ? references.map((data) => {
|
|
122
|
-
return /* @__PURE__ */ jsx(
|
|
123
|
-
ColoredLegendItem,
|
|
124
|
-
{
|
|
125
|
-
isHighlighted: data.title === highlightedBarGroup,
|
|
126
|
-
isAnyHighlighted: highlightedBarGroup !== "",
|
|
127
|
-
groupId: data.title,
|
|
128
|
-
color: data.color,
|
|
129
|
-
title: data.title,
|
|
130
|
-
avoidEvent: avoidEvent != null ? avoidEvent : false
|
|
131
|
-
},
|
|
132
|
-
data.title
|
|
133
|
-
);
|
|
134
|
-
}) : references.map((data, i) => {
|
|
135
|
-
return /* @__PURE__ */ jsx(
|
|
136
|
-
NumberedLegendItem,
|
|
137
|
-
{
|
|
138
|
-
isHighlighted: data.title === highlightedBarGroup,
|
|
139
|
-
isAnyHighlighted: highlightedBarGroup !== "",
|
|
140
|
-
groupId: data.title,
|
|
141
|
-
position: `${i + 1}`,
|
|
142
|
-
title: data.title,
|
|
143
|
-
avoidEvent: avoidEvent != null ? avoidEvent : false
|
|
144
|
-
},
|
|
145
|
-
data.title
|
|
146
|
-
);
|
|
147
|
-
}) });
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const ChartContext = createContext({});
|
|
152
|
-
|
|
153
|
-
const Bar$1 = ({
|
|
154
|
-
bar,
|
|
155
|
-
barGroup,
|
|
156
|
-
chart,
|
|
157
|
-
parsedData,
|
|
158
|
-
isSingle,
|
|
159
|
-
effectiveMargin,
|
|
160
|
-
setsWithColor
|
|
161
|
-
}) => {
|
|
162
|
-
var _a;
|
|
163
|
-
const column = arrayOrArray(chart.dataSets.data)[bar.index];
|
|
164
|
-
const set = arrayOrArray(column == null ? void 0 : column.sets)[barGroup.index];
|
|
165
|
-
const currentBarColor = (_a = setsWithColor.find(
|
|
166
|
-
(innerSet) => innerSet.columnName === column.name && innerSet.key === set.key
|
|
167
|
-
)) == null ? void 0 : _a.color;
|
|
168
|
-
const [isHighlighted, setIsHighlighted] = useState(false);
|
|
169
|
-
const [isAnyHighlighted, setIsAnyHighlighted] = useState(false);
|
|
170
|
-
const ref = useRef(null);
|
|
171
|
-
useImperativeComponentEvents({
|
|
172
|
-
highlight(barNameColumn) {
|
|
173
|
-
let barName = barNameColumn;
|
|
174
|
-
let columnName = "";
|
|
175
|
-
if (barNameColumn.includes("_$_")) {
|
|
176
|
-
barName = barNameColumn.split("_$_")[0];
|
|
177
|
-
columnName = barNameColumn.split("_$_")[1];
|
|
178
|
-
if (isSingle && barNameColumn !== "" && barNameColumn !== void 0) {
|
|
179
|
-
barName = barNameColumn.split("_$_")[1];
|
|
180
|
-
columnName = barNameColumn.split("_$_")[1];
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
if (barName.split(" - ").length === 1) {
|
|
184
|
-
if (arrayOrArray(chart.dataSets.data).length === 1) {
|
|
185
|
-
setIsHighlighted(barName === parsedData[barGroup.index].columnName);
|
|
186
|
-
setIsAnyHighlighted(
|
|
187
|
-
barName !== parsedData[barGroup.index].columnName && barName !== ""
|
|
188
|
-
);
|
|
189
|
-
if (barName === parsedData[barGroup.index].columnName && columnName === parsedData[barGroup.index].columnName) {
|
|
190
|
-
new ApiaUtil().tooltips.open({
|
|
191
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
192
|
-
/* @__PURE__ */ jsx(
|
|
193
|
-
"div",
|
|
194
|
-
{
|
|
195
|
-
style: {
|
|
196
|
-
color: currentBarColor
|
|
197
|
-
},
|
|
198
|
-
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
199
|
-
}
|
|
200
|
-
),
|
|
201
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
202
|
-
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
203
|
-
] }),
|
|
204
|
-
attachToElement: () => ref.current,
|
|
205
|
-
attachToElementAnchorPoint: "center"
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
} else {
|
|
209
|
-
setIsHighlighted(barName === bar.key);
|
|
210
|
-
setIsAnyHighlighted(barName !== bar.key && barName !== "");
|
|
211
|
-
const currentBar = document.querySelector(
|
|
212
|
-
`.${parsedData[barGroup.index].columnName}__${bar.key}`
|
|
213
|
-
);
|
|
214
|
-
if (barName === bar.key && columnName === parsedData[barGroup.index].columnName) {
|
|
215
|
-
new ApiaUtil().tooltips.open({
|
|
216
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
217
|
-
/* @__PURE__ */ jsx(
|
|
218
|
-
"div",
|
|
219
|
-
{
|
|
220
|
-
style: {
|
|
221
|
-
color: currentBarColor
|
|
222
|
-
},
|
|
223
|
-
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
224
|
-
}
|
|
225
|
-
),
|
|
226
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
227
|
-
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
228
|
-
] }),
|
|
229
|
-
attachToElement: () => ref.current,
|
|
230
|
-
attachToElementAnchorPoint: "center"
|
|
231
|
-
});
|
|
232
|
-
} else if (barName === bar.key && currentBar && columnName === "") {
|
|
233
|
-
new ApiaUtil().tooltips.open({
|
|
234
|
-
children: parsedData.map((dat, i) => {
|
|
235
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
236
|
-
/* @__PURE__ */ jsx(
|
|
237
|
-
"div",
|
|
238
|
-
{
|
|
239
|
-
style: {
|
|
240
|
-
color: currentBarColor
|
|
241
|
-
},
|
|
242
|
-
children: /* @__PURE__ */ jsx("strong", { children: dat.columnName })
|
|
243
|
-
}
|
|
244
|
-
),
|
|
245
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: dat[barName] }),
|
|
246
|
-
/* @__PURE__ */ jsx("div", { children: Object.keys(dat).find(
|
|
247
|
-
(key) => dat[key] === dat[barName]
|
|
248
|
-
) }),
|
|
249
|
-
parsedData[i + 1] && /* @__PURE__ */ jsx("hr", {})
|
|
250
|
-
] }, `${dat.columnName}_${dat[barName]}`);
|
|
251
|
-
}),
|
|
252
|
-
attachToMousePosition: true
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
} else if (barName.split(" - ").length === 2) {
|
|
257
|
-
setIsHighlighted(
|
|
258
|
-
barName.split(" - ")[0] === bar.key && barName.split(" - ")[1] === set.key
|
|
259
|
-
);
|
|
260
|
-
setIsAnyHighlighted(
|
|
261
|
-
barName.split(" - ")[0] !== bar.key && barName.split(" - ")[0] !== ""
|
|
262
|
-
);
|
|
263
|
-
if (barName.split(" - ")[0] === bar.key && barName.split(" - ")[1] === set.key && columnName === parsedData[barGroup.index].columnName) {
|
|
264
|
-
new ApiaUtil().tooltips.open({
|
|
265
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
266
|
-
/* @__PURE__ */ jsx(
|
|
267
|
-
"div",
|
|
268
|
-
{
|
|
269
|
-
style: {
|
|
270
|
-
color: currentBarColor
|
|
271
|
-
},
|
|
272
|
-
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
273
|
-
}
|
|
274
|
-
),
|
|
275
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
276
|
-
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
277
|
-
] }),
|
|
278
|
-
attachToElement: () => ref.current,
|
|
279
|
-
attachToElementAnchorPoint: "center"
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
const { chartId } = useContext(ChartContext);
|
|
286
|
-
return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
287
|
-
Box,
|
|
288
|
-
{
|
|
289
|
-
as: "rect",
|
|
290
|
-
className: `chart__barRect ${parsedData[barGroup.index].columnName}__${bar.key}`,
|
|
291
|
-
ref,
|
|
292
|
-
sx: useMemo(
|
|
293
|
-
() => ({
|
|
294
|
-
fill: isAnyHighlighted ? `#${tinycolor(currentBarColor).desaturate(70).toHex()}` : currentBarColor,
|
|
295
|
-
"&:hover": {
|
|
296
|
-
fill: `#${tinycolor(currentBarColor).saturate(25).toHex()}`
|
|
297
|
-
},
|
|
298
|
-
transition: "fill 500ms, opacity 500ms",
|
|
299
|
-
x: bar.x,
|
|
300
|
-
y: bar.y,
|
|
301
|
-
width: bar.width - effectiveMargin.left,
|
|
302
|
-
opacity: isAnyHighlighted && !isHighlighted ? 0.15 : 1,
|
|
303
|
-
height: bar.height > 0 ? bar.height : 0
|
|
304
|
-
}),
|
|
305
|
-
[
|
|
306
|
-
bar.height,
|
|
307
|
-
bar.width,
|
|
308
|
-
bar.x,
|
|
309
|
-
bar.y,
|
|
310
|
-
currentBarColor,
|
|
311
|
-
effectiveMargin.left,
|
|
312
|
-
isAnyHighlighted,
|
|
313
|
-
isHighlighted
|
|
314
|
-
]
|
|
315
|
-
),
|
|
316
|
-
onMouseEnter: (ev) => {
|
|
317
|
-
var _a2, _b, _c;
|
|
318
|
-
if (!isSingle) {
|
|
319
|
-
legendContainerMethods.highlight(chartId, bar.key);
|
|
320
|
-
} else {
|
|
321
|
-
legendContainerMethods.highlight(
|
|
322
|
-
chartId,
|
|
323
|
-
parsedData[barGroup.index].columnName
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
chartMethods(
|
|
327
|
-
chartId,
|
|
328
|
-
"highlight",
|
|
329
|
-
`${bar.key}_$_${parsedData[barGroup.index].columnName}`
|
|
330
|
-
);
|
|
331
|
-
(_a2 = ev.target.classList) == null ? void 0 : _a2.add("over");
|
|
332
|
-
const point = {
|
|
333
|
-
x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
|
|
334
|
-
y: (_c = localPoint(ev)) == null ? void 0 : _c.y
|
|
335
|
-
};
|
|
336
|
-
if (!point || !chart.showValues)
|
|
337
|
-
return;
|
|
338
|
-
},
|
|
339
|
-
onMouseLeave: (ev) => {
|
|
340
|
-
var _a2;
|
|
341
|
-
legendContainerMethods.highlight(chartId, "");
|
|
342
|
-
chartMethods(chartId, "highlight", "");
|
|
343
|
-
(_a2 = ev.target.classList) == null ? void 0 : _a2.remove("over");
|
|
344
|
-
},
|
|
345
|
-
children: /* @__PURE__ */ jsx(
|
|
346
|
-
"animate",
|
|
347
|
-
{
|
|
348
|
-
attributeName: "width",
|
|
349
|
-
from: 0,
|
|
350
|
-
to: bar.width,
|
|
351
|
-
dur: "0.5s",
|
|
352
|
-
calcMode: "paced",
|
|
353
|
-
keySplines: "0.5 0 0.5 1;",
|
|
354
|
-
keyTimes: "0; 1"
|
|
355
|
-
}
|
|
356
|
-
)
|
|
357
|
-
}
|
|
358
|
-
) });
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
function getBarColor(colors, index, alwaysDiffer = false) {
|
|
362
|
-
const module = colors.length;
|
|
363
|
-
let count = 0;
|
|
364
|
-
let barColor = "";
|
|
365
|
-
if (!alwaysDiffer) {
|
|
366
|
-
if (colors[index]) {
|
|
367
|
-
barColor = colors[index];
|
|
368
|
-
} else {
|
|
369
|
-
let innerIndex = index;
|
|
370
|
-
while (innerIndex >= module) {
|
|
371
|
-
innerIndex = index / module;
|
|
372
|
-
count++;
|
|
373
|
-
}
|
|
374
|
-
barColor = tinycolor(colors[index % module]).desaturate(count * 5).toHex().startsWith("#") ? tinycolor(colors[index % module]).desaturate(count * 5).toHex() : `#${tinycolor(colors[index % module]).desaturate(count * 5).toHex()}`;
|
|
375
|
-
}
|
|
376
|
-
} else {
|
|
377
|
-
if (colors[index]) {
|
|
378
|
-
barColor = colors[index];
|
|
379
|
-
} else {
|
|
380
|
-
barColor = tinycolor(colors[index % module]).toHex();
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
return barColor;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
var __defProp$f = Object.defineProperty;
|
|
387
|
-
var __defProps$d = Object.defineProperties;
|
|
388
|
-
var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
|
|
389
|
-
var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
|
|
390
|
-
var __hasOwnProp$f = Object.prototype.hasOwnProperty;
|
|
391
|
-
var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
|
|
392
|
-
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
393
|
-
var __spreadValues$f = (a, b) => {
|
|
394
|
-
for (var prop in b || (b = {}))
|
|
395
|
-
if (__hasOwnProp$f.call(b, prop))
|
|
396
|
-
__defNormalProp$f(a, prop, b[prop]);
|
|
397
|
-
if (__getOwnPropSymbols$f)
|
|
398
|
-
for (var prop of __getOwnPropSymbols$f(b)) {
|
|
399
|
-
if (__propIsEnum$f.call(b, prop))
|
|
400
|
-
__defNormalProp$f(a, prop, b[prop]);
|
|
401
|
-
}
|
|
402
|
-
return a;
|
|
403
|
-
};
|
|
404
|
-
var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
|
|
405
|
-
function useChartStyles(schemeName) {
|
|
406
|
-
var _a, _b, _c;
|
|
407
|
-
const { theme } = useThemeUI();
|
|
408
|
-
if (!theme.layout)
|
|
409
|
-
console.error("The layout property is missing in the current theme");
|
|
410
|
-
const charts = (_b = (_a = theme.layout) == null ? void 0 : _a.charts) != null ? _b : {};
|
|
411
|
-
const defaultStyles = charts.common;
|
|
412
|
-
const currentStylescheme = {
|
|
413
|
-
schema: getValueByPath(
|
|
414
|
-
theme.colors,
|
|
415
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
416
|
-
(_c = charts[schemeName && schemeName !== "0" ? schemeName : "blue"]) == null ? void 0 : _c.schema
|
|
417
|
-
)
|
|
418
|
-
};
|
|
419
|
-
if (typeof currentStylescheme.schema === "object" && currentStylescheme.schema) {
|
|
420
|
-
const returnStyles = Object.entries(
|
|
421
|
-
currentStylescheme.schema
|
|
422
|
-
).map((e) => {
|
|
423
|
-
const element = document.querySelector("*");
|
|
424
|
-
if (element) {
|
|
425
|
-
if (e[1].startsWith("var(")) {
|
|
426
|
-
return window.getComputedStyle(element).getPropertyValue(e[1].slice(4, -1));
|
|
427
|
-
}
|
|
428
|
-
return window.getComputedStyle(element).getPropertyValue(e[1]);
|
|
429
|
-
}
|
|
430
|
-
return window.getComputedStyle(document.querySelector("*")).getPropertyValue(e[1]);
|
|
431
|
-
});
|
|
432
|
-
return __spreadProps$d(__spreadValues$f({}, defaultStyles), { schema: returnStyles });
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
var __defProp$e = Object.defineProperty;
|
|
437
|
-
var __defProps$c = Object.defineProperties;
|
|
438
|
-
var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
|
|
439
|
-
var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
|
|
440
|
-
var __hasOwnProp$e = Object.prototype.hasOwnProperty;
|
|
441
|
-
var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
|
|
442
|
-
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
443
|
-
var __spreadValues$e = (a, b) => {
|
|
444
|
-
for (var prop in b || (b = {}))
|
|
445
|
-
if (__hasOwnProp$e.call(b, prop))
|
|
446
|
-
__defNormalProp$e(a, prop, b[prop]);
|
|
447
|
-
if (__getOwnPropSymbols$e)
|
|
448
|
-
for (var prop of __getOwnPropSymbols$e(b)) {
|
|
449
|
-
if (__propIsEnum$e.call(b, prop))
|
|
450
|
-
__defNormalProp$e(a, prop, b[prop]);
|
|
451
|
-
}
|
|
452
|
-
return a;
|
|
453
|
-
};
|
|
454
|
-
var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
|
|
455
|
-
function adjustDimensions$4({
|
|
456
|
-
width,
|
|
457
|
-
height,
|
|
458
|
-
maxWidth
|
|
459
|
-
}) {
|
|
460
|
-
if (width <= maxWidth) {
|
|
461
|
-
return { width, height };
|
|
462
|
-
}
|
|
463
|
-
const ratio = width / height;
|
|
464
|
-
const newWidth = maxWidth;
|
|
465
|
-
const newHeight = Math.floor(newWidth / ratio);
|
|
466
|
-
return { width: newWidth, height: newHeight };
|
|
467
|
-
}
|
|
468
|
-
const getYValue = (d) => d.columnName;
|
|
469
|
-
const HorizontalBars = ({
|
|
470
|
-
margin = { top: 20, left: 50, bottom: 150, right: 20 },
|
|
471
|
-
chart,
|
|
472
|
-
className,
|
|
473
|
-
chartId,
|
|
474
|
-
outerClassName,
|
|
475
|
-
allowZoom
|
|
476
|
-
}) => {
|
|
477
|
-
var _a;
|
|
478
|
-
const effectiveMargin = parseMargin(margin);
|
|
479
|
-
let innerWidth = chart.ratio.width + (-effectiveMargin.left - effectiveMargin.right) / 2;
|
|
480
|
-
let innerHeight = chart.ratio.height + (-effectiveMargin.top - effectiveMargin.bottom) / 2;
|
|
481
|
-
if (innerWidth > chart.ratio.maxWidth) {
|
|
482
|
-
const newValues = adjustDimensions$4({
|
|
483
|
-
height: innerHeight,
|
|
484
|
-
width: innerWidth,
|
|
485
|
-
maxWidth: chart.ratio.maxWidth
|
|
486
|
-
});
|
|
487
|
-
innerWidth = newValues.width;
|
|
488
|
-
innerHeight = newValues.height;
|
|
489
|
-
}
|
|
490
|
-
const columnas = arrayOrArray((_a = chart.dataSets) == null ? void 0 : _a.data).filter((column) => !!column.sets).map((column) => {
|
|
491
|
-
return __spreadProps$c(__spreadValues$e({}, column), {
|
|
492
|
-
sets: column.sets
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
const xValues = arrayOrArray(columnas[0].sets).map(
|
|
496
|
-
(innerCoord) => innerCoord.key
|
|
497
|
-
);
|
|
498
|
-
const columnNames = columnas.map((col) => {
|
|
499
|
-
return col.name;
|
|
500
|
-
});
|
|
501
|
-
const parsedData = xValues.map((x) => {
|
|
502
|
-
const obj = columnas.reduce(
|
|
503
|
-
(acc, column) => {
|
|
504
|
-
return __spreadProps$c(__spreadValues$e({}, acc), {
|
|
505
|
-
[column.name]: arrayOrArray(column.sets).filter((coord) => {
|
|
506
|
-
return coord.key === x;
|
|
507
|
-
})[0].value
|
|
508
|
-
});
|
|
509
|
-
},
|
|
510
|
-
{ columnName: x }
|
|
511
|
-
);
|
|
512
|
-
return obj;
|
|
513
|
-
});
|
|
514
|
-
const yScale = scaleBand({
|
|
515
|
-
range: [
|
|
516
|
-
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top,
|
|
517
|
-
innerHeight
|
|
518
|
-
],
|
|
519
|
-
domain: parsedData.map(getYValue),
|
|
520
|
-
padding: 0.2
|
|
521
|
-
});
|
|
522
|
-
const columnGroupScale = scaleBand({
|
|
523
|
-
domain: columnNames,
|
|
524
|
-
range: [0, yScale.bandwidth()]
|
|
525
|
-
});
|
|
526
|
-
const xScaleLog = scaleLog({
|
|
527
|
-
range: [
|
|
528
|
-
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.left,
|
|
529
|
-
innerWidth
|
|
530
|
-
],
|
|
531
|
-
domain: [
|
|
532
|
-
1,
|
|
533
|
-
Math.max(
|
|
534
|
-
...parsedData.map(
|
|
535
|
-
(d) => Math.max(...columnNames.map((key) => Number(d[key])))
|
|
536
|
-
)
|
|
537
|
-
)
|
|
538
|
-
],
|
|
539
|
-
base: 10
|
|
540
|
-
});
|
|
541
|
-
const xScaleLine = scaleLinear({
|
|
542
|
-
range: [
|
|
543
|
-
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.left,
|
|
544
|
-
innerWidth
|
|
545
|
-
],
|
|
546
|
-
domain: [
|
|
547
|
-
0,
|
|
548
|
-
Math.max(
|
|
549
|
-
...parsedData.map(
|
|
550
|
-
(d) => Math.max(...columnNames.map((key) => Number(d[key])))
|
|
551
|
-
)
|
|
552
|
-
)
|
|
553
|
-
]
|
|
554
|
-
});
|
|
555
|
-
const color = scaleOrdinal({
|
|
556
|
-
domain: columnNames,
|
|
557
|
-
range: columnas.map((col) => col.color)
|
|
558
|
-
});
|
|
559
|
-
const isLogScale = false;
|
|
560
|
-
const xScale = useMemo(() => {
|
|
561
|
-
{
|
|
562
|
-
return xScaleLine;
|
|
563
|
-
}
|
|
564
|
-
}, [isLogScale, xScaleLine, xScaleLog]);
|
|
565
|
-
const id = useMemo(() => `HorizontalBars${uniqueId()}`, []);
|
|
566
|
-
useLayoutEffect(() => {
|
|
567
|
-
document.querySelectorAll(
|
|
568
|
-
`#${id} .__${chartId != null ? chartId : outerClassName}`
|
|
569
|
-
).forEach((current) => {
|
|
570
|
-
const width = current.getBoundingClientRect().width;
|
|
571
|
-
current.style.transformOrigin = current.getAttribute("x") + "px 14px";
|
|
572
|
-
current.style.transform = `rotate(15deg) translateX(${width / 2}px)`;
|
|
573
|
-
});
|
|
574
|
-
});
|
|
575
|
-
const styles = useChartStyles(chart.colorSchema);
|
|
576
|
-
const { boxRef, elementRef } = usePanAndZoom(
|
|
577
|
-
void 0,
|
|
578
|
-
!allowZoom
|
|
579
|
-
);
|
|
580
|
-
const setsWithColor = arrayOrArray(chart.dataSets.data).map((data, index) => {
|
|
581
|
-
const isSingle = arrayOrArray(chart.dataSets.data).length === 1;
|
|
582
|
-
const dataColor = data.color !== "" && data.color !== void 0 ? data.color : arrayOrArray(
|
|
583
|
-
styles ? styles.schema : [
|
|
584
|
-
"#7ad6f4",
|
|
585
|
-
"#45bdee",
|
|
586
|
-
"#28a7ea",
|
|
587
|
-
"#006cbb",
|
|
588
|
-
"#034698",
|
|
589
|
-
"#032f64"
|
|
590
|
-
]
|
|
591
|
-
).length > 0 ? getBarColor(
|
|
592
|
-
arrayOrArray(
|
|
593
|
-
styles ? styles.schema : [
|
|
594
|
-
"#7ad6f4",
|
|
595
|
-
"#45bdee",
|
|
596
|
-
"#28a7ea",
|
|
597
|
-
"#006cbb",
|
|
598
|
-
"#034698",
|
|
599
|
-
"#032f64"
|
|
600
|
-
]
|
|
601
|
-
),
|
|
602
|
-
index,
|
|
603
|
-
isSingle
|
|
604
|
-
) : "";
|
|
605
|
-
const returnColumnsArray = [];
|
|
606
|
-
arrayOrArray(data.sets).forEach((set) => {
|
|
607
|
-
if (set.color !== "" && set.color !== void 0) {
|
|
608
|
-
returnColumnsArray.push(__spreadProps$c(__spreadValues$e({}, set), { columnName: data.name }));
|
|
609
|
-
} else {
|
|
610
|
-
returnColumnsArray.push(__spreadProps$c(__spreadValues$e({}, set), {
|
|
611
|
-
color: dataColor,
|
|
612
|
-
columnName: data.name
|
|
613
|
-
}));
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
|
-
return returnColumnsArray;
|
|
617
|
-
});
|
|
618
|
-
const colorReference = arrayOrArray(chart.dataSets.data).map(
|
|
619
|
-
(data, index) => {
|
|
620
|
-
const isSingle = arrayOrArray(chart.dataSets.data).length === 1;
|
|
621
|
-
const dataColor = data.color !== "" && data.color !== void 0 ? data.color : arrayOrArray(
|
|
622
|
-
styles ? styles.schema : [
|
|
623
|
-
"#7ad6f4",
|
|
624
|
-
"#45bdee",
|
|
625
|
-
"#28a7ea",
|
|
626
|
-
"#006cbb",
|
|
627
|
-
"#034698",
|
|
628
|
-
"#032f64"
|
|
629
|
-
]
|
|
630
|
-
).length > 0 ? getBarColor(
|
|
631
|
-
arrayOrArray(
|
|
632
|
-
styles ? styles.schema : [
|
|
633
|
-
"#7ad6f4",
|
|
634
|
-
"#45bdee",
|
|
635
|
-
"#28a7ea",
|
|
636
|
-
"#006cbb",
|
|
637
|
-
"#034698",
|
|
638
|
-
"#032f64"
|
|
639
|
-
]
|
|
640
|
-
),
|
|
641
|
-
index,
|
|
642
|
-
isSingle
|
|
643
|
-
) : "";
|
|
644
|
-
return {
|
|
645
|
-
color: dataColor,
|
|
646
|
-
title: data.name
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
);
|
|
650
|
-
let numberReference = [];
|
|
651
|
-
if (colorReference.length === 1) {
|
|
652
|
-
numberReference = arrayOrArray(
|
|
653
|
-
arrayOrArray(chart.dataSets.data)[0].sets
|
|
654
|
-
).map((data, index) => {
|
|
655
|
-
return {
|
|
656
|
-
color: `${index + 1}`,
|
|
657
|
-
title: data.key
|
|
658
|
-
};
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
arrayOrArray(chart.dataSets.data).map((data) => {
|
|
662
|
-
const returnArray = [];
|
|
663
|
-
arrayOrArray(data.sets).forEach((set) => {
|
|
664
|
-
if (set.color !== "" && set.color !== void 0) {
|
|
665
|
-
returnArray.push({
|
|
666
|
-
color: set.color,
|
|
667
|
-
title: data.name + " - " + set.key
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
});
|
|
671
|
-
return returnArray;
|
|
672
|
-
}).flat().forEach((addRef) => colorReference.push(addRef));
|
|
673
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
674
|
-
/* @__PURE__ */ jsx(
|
|
675
|
-
Box,
|
|
676
|
-
{
|
|
677
|
-
ref: boxRef,
|
|
678
|
-
id,
|
|
679
|
-
className: `${outerClassName != null ? outerClassName : ""} ${chartId} ${chart.title} chartBox chartContainer`,
|
|
680
|
-
sx: React.useMemo(() => {
|
|
681
|
-
return {
|
|
682
|
-
[`.__${chartId != null ? chartId : outerClassName}`]: {
|
|
683
|
-
transform: "rotate(45deg)",
|
|
684
|
-
transformOrigin: "attr(x) 18px"
|
|
685
|
-
},
|
|
686
|
-
overflow: "hidden",
|
|
687
|
-
position: "relative",
|
|
688
|
-
height: `${chart.ratio.height}px`
|
|
689
|
-
// width: `${chart.ratio.width}px`,
|
|
690
|
-
};
|
|
691
|
-
}, [chart.ratio.height, chartId, outerClassName]),
|
|
692
|
-
children: /* @__PURE__ */ jsxs(
|
|
693
|
-
"svg",
|
|
694
|
-
{
|
|
695
|
-
ref: elementRef,
|
|
696
|
-
className: `_${chartId} ${className ? className : ""} chart__svg`,
|
|
697
|
-
height: chart.ratio.height,
|
|
698
|
-
width: chart.ratio.width,
|
|
699
|
-
style: {
|
|
700
|
-
position: "absolute"
|
|
701
|
-
},
|
|
702
|
-
children: [
|
|
703
|
-
chart.showGrid && /* @__PURE__ */ jsx(
|
|
704
|
-
Grid.Grid,
|
|
705
|
-
{
|
|
706
|
-
xScale,
|
|
707
|
-
yScale,
|
|
708
|
-
left: 0,
|
|
709
|
-
width: innerWidth,
|
|
710
|
-
height: innerHeight,
|
|
711
|
-
numTicksRows: 10,
|
|
712
|
-
numTicksColumns: 10,
|
|
713
|
-
top: (typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top) - 20
|
|
714
|
-
}
|
|
715
|
-
),
|
|
716
|
-
/* @__PURE__ */ jsx(
|
|
717
|
-
Group,
|
|
718
|
-
{
|
|
719
|
-
top: (typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top) - 20,
|
|
720
|
-
left: effectiveMargin.left,
|
|
721
|
-
children: /* @__PURE__ */ jsx(
|
|
722
|
-
BarGroupHorizontal,
|
|
723
|
-
{
|
|
724
|
-
data: parsedData,
|
|
725
|
-
keys: columnNames,
|
|
726
|
-
width: innerWidth,
|
|
727
|
-
y0: getYValue,
|
|
728
|
-
y0Scale: yScale,
|
|
729
|
-
y1Scale: columnGroupScale,
|
|
730
|
-
xScale,
|
|
731
|
-
color,
|
|
732
|
-
children: (barGroups) => barGroups.map((barGroup) => {
|
|
733
|
-
return /* @__PURE__ */ jsx(
|
|
734
|
-
Group,
|
|
735
|
-
{
|
|
736
|
-
top: barGroup.y0,
|
|
737
|
-
children: barGroup.bars.map((bar) => {
|
|
738
|
-
const key = `${barGroup.index}-${bar.index}-${bar.key}`;
|
|
739
|
-
return /* @__PURE__ */ jsx(
|
|
740
|
-
Bar$1,
|
|
741
|
-
{
|
|
742
|
-
isSingle: barGroup.bars.length === 1,
|
|
743
|
-
bar,
|
|
744
|
-
barGroup,
|
|
745
|
-
chart,
|
|
746
|
-
parsedData,
|
|
747
|
-
effectiveMargin,
|
|
748
|
-
setsWithColor: setsWithColor.flat()
|
|
749
|
-
},
|
|
750
|
-
key
|
|
751
|
-
);
|
|
752
|
-
})
|
|
753
|
-
},
|
|
754
|
-
`bar-group-${barGroup.index}-${barGroup.y0}`
|
|
755
|
-
);
|
|
756
|
-
})
|
|
757
|
-
}
|
|
758
|
-
)
|
|
759
|
-
}
|
|
760
|
-
),
|
|
761
|
-
/* @__PURE__ */ jsx(
|
|
762
|
-
AxisLeft,
|
|
763
|
-
{
|
|
764
|
-
scale: yScale,
|
|
765
|
-
left: effectiveMargin.left,
|
|
766
|
-
label: chart.chartType !== "pie2D" && chart.showAxisYTitle ? chart.axisYTitle : "",
|
|
767
|
-
labelOffset: 10,
|
|
768
|
-
tickLabelProps: () => ({
|
|
769
|
-
display: "none"
|
|
770
|
-
})
|
|
771
|
-
}
|
|
772
|
-
),
|
|
773
|
-
/* @__PURE__ */ jsx(
|
|
774
|
-
AxisBottom,
|
|
775
|
-
{
|
|
776
|
-
top: innerHeight,
|
|
777
|
-
scale: xScale,
|
|
778
|
-
label: chart.chartType !== "pie2D" && chart.showAxisXTitle ? chart.axisXTitle : "",
|
|
779
|
-
tickLabelProps: { display: "none" },
|
|
780
|
-
tickLineProps: { display: "none" },
|
|
781
|
-
labelOffset: 30
|
|
782
|
-
}
|
|
783
|
-
)
|
|
784
|
-
]
|
|
785
|
-
}
|
|
786
|
-
)
|
|
787
|
-
}
|
|
788
|
-
),
|
|
789
|
-
/* @__PURE__ */ jsx(Box, { className: "chartLegend__Wrapper", children: chart.showLegend && colorReference.length !== 0 && /* @__PURE__ */ jsxs(Box, { className: "chart__legend__wrapper", children: [
|
|
790
|
-
/* @__PURE__ */ jsx(Heading, { as: "h6", children: getLabel("mnuLeyends").text }),
|
|
791
|
-
/* @__PURE__ */ jsx(
|
|
792
|
-
LegendContainer,
|
|
793
|
-
{
|
|
794
|
-
id: chartId,
|
|
795
|
-
references: (
|
|
796
|
-
// hideLegendsColors
|
|
797
|
-
// ? colorReference.map((ref) => {
|
|
798
|
-
// return { ...ref, color: 'transparent' };
|
|
799
|
-
// })
|
|
800
|
-
colorReference.length === 1 && numberReference.length > 0 ? numberReference : colorReference
|
|
801
|
-
),
|
|
802
|
-
useNumbered: colorReference.length === 1
|
|
803
|
-
}
|
|
804
|
-
)
|
|
805
|
-
] }) })
|
|
806
|
-
] });
|
|
807
|
-
};
|
|
808
|
-
|
|
809
|
-
const Slice = ({
|
|
810
|
-
arc,
|
|
811
|
-
arcPath,
|
|
812
|
-
chart,
|
|
813
|
-
actualColor,
|
|
814
|
-
chartId: outerChartId
|
|
815
|
-
}) => {
|
|
816
|
-
const [isHighlighted, setIsHighlighted] = useState(false);
|
|
817
|
-
const [isAnyHighlighted, setIsAnyHighlighted] = useState(false);
|
|
818
|
-
const ref = useRef(null);
|
|
819
|
-
const name = arc.data;
|
|
820
|
-
const { id: chartId } = useImperativeComponentContext();
|
|
821
|
-
useImperativeComponentEvents({
|
|
822
|
-
highlight(barNameId) {
|
|
823
|
-
const barName = barNameId.split("_$_")[0];
|
|
824
|
-
setIsHighlighted(barName === arc.data.key);
|
|
825
|
-
setIsAnyHighlighted(barName !== arc.data.key && barName !== "");
|
|
826
|
-
if (barName === arc.data.key) {
|
|
827
|
-
new ApiaUtil().tooltips.open({
|
|
828
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
829
|
-
/* @__PURE__ */ jsx(
|
|
830
|
-
"div",
|
|
831
|
-
{
|
|
832
|
-
style: {
|
|
833
|
-
color: `#${tinycolor(actualColor).toHex()}`
|
|
834
|
-
},
|
|
835
|
-
children: /* @__PURE__ */ jsx("strong", { children: arc.data.key })
|
|
836
|
-
}
|
|
837
|
-
),
|
|
838
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: `${arc.value} ${arc.data.percentage !== "" && arc.data.percentage !== void 0 ? "- " + arc.data.percentage : ""}${arc.data.percentage !== "" && arc.data.percentage !== void 0 ? "%" : ""}` })
|
|
839
|
-
] }),
|
|
840
|
-
attachToElement: () => {
|
|
841
|
-
return ref.current;
|
|
842
|
-
},
|
|
843
|
-
attachToElementAnchorPoint: "center",
|
|
844
|
-
closeOnClickOut: () => {
|
|
845
|
-
return window.innerWidth > 700;
|
|
846
|
-
},
|
|
847
|
-
closeOnMouseLeaveAttachedElement: (ev) => {
|
|
848
|
-
return !ev.relatedTarget.closest(".legendItem");
|
|
849
|
-
},
|
|
850
|
-
className: arc.data.key
|
|
851
|
-
});
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
});
|
|
855
|
-
return /* @__PURE__ */ jsx(
|
|
856
|
-
"path",
|
|
857
|
-
{
|
|
858
|
-
id: `arc-${name.key}-${name.value}-${outerChartId}`,
|
|
859
|
-
ref,
|
|
860
|
-
style: useMemo(
|
|
861
|
-
() => ({
|
|
862
|
-
"&:hover": {
|
|
863
|
-
fill: `#${tinycolor(actualColor).saturate(25).toHex()}`
|
|
864
|
-
},
|
|
865
|
-
transition: "fill 500ms, opacity 500ms"
|
|
866
|
-
}),
|
|
867
|
-
[actualColor]
|
|
868
|
-
),
|
|
869
|
-
color: isAnyHighlighted ? `#${tinycolor(actualColor).desaturate(70).toHex()}` : actualColor,
|
|
870
|
-
fill: isAnyHighlighted ? `#${tinycolor(actualColor).desaturate(70).toHex()}` : actualColor,
|
|
871
|
-
opacity: isAnyHighlighted && !isHighlighted ? 0.15 : 1,
|
|
872
|
-
d: arcPath != null ? arcPath : "",
|
|
873
|
-
onMouseEnter: (ev) => {
|
|
874
|
-
var _a, _b, _c;
|
|
875
|
-
legendContainerMethods.highlight(chartId, arc.data.key);
|
|
876
|
-
chartMethods(chartId, "highlight", `${name.key}_$_${outerChartId}`);
|
|
877
|
-
(_a = ev.target.classList) == null ? void 0 : _a.add("over");
|
|
878
|
-
const point = {
|
|
879
|
-
x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
|
|
880
|
-
y: (_c = localPoint(ev)) == null ? void 0 : _c.y
|
|
881
|
-
};
|
|
882
|
-
if (!point)
|
|
883
|
-
return;
|
|
884
|
-
},
|
|
885
|
-
onMouseLeave: (ev) => {
|
|
886
|
-
var _a;
|
|
887
|
-
legendContainerMethods.highlight(chartId, "");
|
|
888
|
-
chartMethods(chartId, "highlight", "");
|
|
889
|
-
(_a = ev.target.classList) == null ? void 0 : _a.remove("over");
|
|
890
|
-
}
|
|
891
|
-
},
|
|
892
|
-
`arc-${name.key}-${name.value}-${outerChartId}`
|
|
893
|
-
);
|
|
894
|
-
};
|
|
895
|
-
|
|
896
|
-
var __defProp$d = Object.defineProperty;
|
|
897
|
-
var __defProps$b = Object.defineProperties;
|
|
898
|
-
var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
|
|
899
|
-
var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
|
|
900
|
-
var __hasOwnProp$d = Object.prototype.hasOwnProperty;
|
|
901
|
-
var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
|
|
902
|
-
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
903
|
-
var __spreadValues$d = (a, b) => {
|
|
904
|
-
for (var prop in b || (b = {}))
|
|
905
|
-
if (__hasOwnProp$d.call(b, prop))
|
|
906
|
-
__defNormalProp$d(a, prop, b[prop]);
|
|
907
|
-
if (__getOwnPropSymbols$d)
|
|
908
|
-
for (var prop of __getOwnPropSymbols$d(b)) {
|
|
909
|
-
if (__propIsEnum$d.call(b, prop))
|
|
910
|
-
__defNormalProp$d(a, prop, b[prop]);
|
|
911
|
-
}
|
|
912
|
-
return a;
|
|
913
|
-
};
|
|
914
|
-
var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
|
|
915
|
-
const usePieAnimation = ({
|
|
916
|
-
incomingColumn,
|
|
917
|
-
piezas,
|
|
918
|
-
setDataset
|
|
919
|
-
}) => {
|
|
920
|
-
const previousObjectRef = useRef(void 0);
|
|
921
|
-
const actualObjectRef = useRef(void 0);
|
|
922
|
-
const isAnimating = useRef(false);
|
|
923
|
-
if (previousObjectRef.current && piezas) {
|
|
924
|
-
const previousCoordinates = isAnimating.current && actualObjectRef.current ? arrayOrArray(actualObjectRef.current.coordinate) : arrayOrArray(previousObjectRef.current.coordinate);
|
|
925
|
-
const currentCoordinates = arrayOrArray(incomingColumn.sets);
|
|
926
|
-
const hasValueChanged = previousCoordinates.some((prevCoord, index) => {
|
|
927
|
-
const currentCoord = currentCoordinates[index];
|
|
928
|
-
return prevCoord.value !== currentCoord.value;
|
|
929
|
-
});
|
|
930
|
-
if (hasValueChanged) {
|
|
931
|
-
isAnimating.current = true;
|
|
932
|
-
const difference = [];
|
|
933
|
-
for (let i = 0; i < Math.max(previousCoordinates.length, currentCoordinates.length); i++) {
|
|
934
|
-
const coord1 = previousCoordinates[i];
|
|
935
|
-
const coord2 = currentCoordinates[i];
|
|
936
|
-
if (coord1 && coord2) {
|
|
937
|
-
const newValue = Math.abs(
|
|
938
|
-
parseInt(coord1.value) - parseInt(coord2.value)
|
|
939
|
-
).toString();
|
|
940
|
-
const newCoordinate = {
|
|
941
|
-
key: coord2.key,
|
|
942
|
-
color: coord2.color,
|
|
943
|
-
// Assuming color is the same for both coordinates
|
|
944
|
-
value: newValue,
|
|
945
|
-
percentage: coord2.percentage !== "" && coord2.percentage !== void 0 ? coord2.percentage : void 0
|
|
946
|
-
};
|
|
947
|
-
difference.push(newCoordinate);
|
|
948
|
-
} else if (!coord1 && coord2 && previousCoordinates.length > 0) {
|
|
949
|
-
const newValue = Math.abs(0 - parseInt(coord2.value)).toString();
|
|
950
|
-
const newCoordinate = {
|
|
951
|
-
key: coord2.key,
|
|
952
|
-
color: coord2.color,
|
|
953
|
-
// Assuming color is the same for both coordinates
|
|
954
|
-
value: newValue,
|
|
955
|
-
percentage: coord2.percentage !== "" && coord2.percentage !== void 0 ? coord2.percentage : void 0
|
|
956
|
-
};
|
|
957
|
-
difference.push(newCoordinate);
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
return animate(
|
|
961
|
-
500,
|
|
962
|
-
(progress) => {
|
|
963
|
-
const step = {
|
|
964
|
-
color: piezas.color,
|
|
965
|
-
name: incomingColumn.name,
|
|
966
|
-
sets: difference.map((coord, i) => {
|
|
967
|
-
return {
|
|
968
|
-
key: coord.key,
|
|
969
|
-
color: coord.color,
|
|
970
|
-
percentage: coord.percentage,
|
|
971
|
-
value: addBoundary(
|
|
972
|
-
Number(currentCoordinates[i].value) > Number(
|
|
973
|
-
previousCoordinates[i] ? previousCoordinates[i].value : 0
|
|
974
|
-
) ? Number(coord.value) * progress + Number(
|
|
975
|
-
previousCoordinates[i] ? previousCoordinates[i].value : 0
|
|
976
|
-
) : Number(
|
|
977
|
-
previousCoordinates[i] ? previousCoordinates[i].value : 0
|
|
978
|
-
) - Number(coord.value) * progress,
|
|
979
|
-
Math.min(
|
|
980
|
-
Number(
|
|
981
|
-
previousCoordinates[i] ? previousCoordinates[i].value : 0
|
|
982
|
-
),
|
|
983
|
-
Number(currentCoordinates[i].value)
|
|
984
|
-
),
|
|
985
|
-
Math.max(
|
|
986
|
-
Number(
|
|
987
|
-
previousCoordinates[i] ? previousCoordinates[i].value : 0
|
|
988
|
-
),
|
|
989
|
-
Number(currentCoordinates[i].value)
|
|
990
|
-
)
|
|
991
|
-
).toString()
|
|
992
|
-
};
|
|
993
|
-
})
|
|
994
|
-
};
|
|
995
|
-
actualObjectRef.current = {
|
|
996
|
-
color: step.color,
|
|
997
|
-
coordinate: step.sets,
|
|
998
|
-
name: step.name
|
|
999
|
-
};
|
|
1000
|
-
setDataset((prev) => {
|
|
1001
|
-
const newIndex = prev.findIndex((col) => {
|
|
1002
|
-
return col.name === step.name;
|
|
1003
|
-
});
|
|
1004
|
-
const returnObj = [...prev];
|
|
1005
|
-
if (newIndex >= 0) {
|
|
1006
|
-
returnObj[newIndex] = step;
|
|
1007
|
-
return returnObj;
|
|
1008
|
-
} else {
|
|
1009
|
-
return [step];
|
|
1010
|
-
}
|
|
1011
|
-
});
|
|
1012
|
-
},
|
|
1013
|
-
() => {
|
|
1014
|
-
const newPrev = __spreadProps$b(__spreadValues$d({}, incomingColumn), {
|
|
1015
|
-
coordinate: incomingColumn.sets
|
|
1016
|
-
});
|
|
1017
|
-
previousObjectRef.current = newPrev;
|
|
1018
|
-
isAnimating.current = false;
|
|
1019
|
-
}
|
|
1020
|
-
);
|
|
1021
|
-
}
|
|
1022
|
-
} else if (!previousObjectRef.current) {
|
|
1023
|
-
const newPrev = __spreadProps$b(__spreadValues$d({}, incomingColumn), {
|
|
1024
|
-
coordinate: incomingColumn.sets
|
|
1025
|
-
});
|
|
1026
|
-
previousObjectRef.current = newPrev;
|
|
1027
|
-
isAnimating.current = false;
|
|
1028
|
-
}
|
|
1029
|
-
};
|
|
1030
|
-
|
|
1031
|
-
function ChartSelector({
|
|
1032
|
-
chartId,
|
|
1033
|
-
pieces,
|
|
1034
|
-
className,
|
|
1035
|
-
current,
|
|
1036
|
-
setCurrent
|
|
1037
|
-
}) {
|
|
1038
|
-
return /* @__PURE__ */ jsxs(
|
|
1039
|
-
Select,
|
|
1040
|
-
{
|
|
1041
|
-
sx: { width: "auto" },
|
|
1042
|
-
name: `chartSelector_${chartId}`,
|
|
1043
|
-
className: `chartSelector_${chartId} ${className != null ? className : ""}`,
|
|
1044
|
-
value: current != null ? current : "0",
|
|
1045
|
-
onChange: (ev) => {
|
|
1046
|
-
ev.preventDefault();
|
|
1047
|
-
setCurrent(ev.target.value);
|
|
1048
|
-
},
|
|
1049
|
-
children: [
|
|
1050
|
-
pieces.map((piece, i) => {
|
|
1051
|
-
return {
|
|
1052
|
-
label: piece,
|
|
1053
|
-
value: `${i}`
|
|
1054
|
-
};
|
|
1055
|
-
}).map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value)),
|
|
1056
|
-
" "
|
|
1057
|
-
]
|
|
1058
|
-
}
|
|
1059
|
-
);
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
var __defProp$c = Object.defineProperty;
|
|
1063
|
-
var __defProps$a = Object.defineProperties;
|
|
1064
|
-
var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
|
|
1065
|
-
var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
|
|
1066
|
-
var __hasOwnProp$c = Object.prototype.hasOwnProperty;
|
|
1067
|
-
var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
|
|
1068
|
-
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1069
|
-
var __spreadValues$c = (a, b) => {
|
|
1070
|
-
for (var prop in b || (b = {}))
|
|
1071
|
-
if (__hasOwnProp$c.call(b, prop))
|
|
1072
|
-
__defNormalProp$c(a, prop, b[prop]);
|
|
1073
|
-
if (__getOwnPropSymbols$c)
|
|
1074
|
-
for (var prop of __getOwnPropSymbols$c(b)) {
|
|
1075
|
-
if (__propIsEnum$c.call(b, prop))
|
|
1076
|
-
__defNormalProp$c(a, prop, b[prop]);
|
|
1077
|
-
}
|
|
1078
|
-
return a;
|
|
1079
|
-
};
|
|
1080
|
-
var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
|
|
1081
|
-
function adjustDimensions$3({
|
|
1082
|
-
width,
|
|
1083
|
-
height,
|
|
1084
|
-
maxWidth
|
|
1085
|
-
}) {
|
|
1086
|
-
if (width <= maxWidth) {
|
|
1087
|
-
return { width, height };
|
|
1088
|
-
}
|
|
1089
|
-
const ratio = width / height;
|
|
1090
|
-
const newWidth = maxWidth;
|
|
1091
|
-
const newHeight = Math.floor(newWidth / ratio);
|
|
1092
|
-
return { width: newWidth, height: newHeight };
|
|
1093
|
-
}
|
|
1094
|
-
const PieChart = ({
|
|
1095
|
-
chart,
|
|
1096
|
-
className,
|
|
1097
|
-
chartId,
|
|
1098
|
-
allowZoom
|
|
1099
|
-
}) => {
|
|
1100
|
-
var _a, _b, _c, _d;
|
|
1101
|
-
const [dataset, setDataset] = useState(
|
|
1102
|
-
arrayOrArray((_a = chart.dataSets) == null ? void 0 : _a.data)
|
|
1103
|
-
);
|
|
1104
|
-
const [currentPie, setCurrentPie] = useState("0");
|
|
1105
|
-
const piezas = useMemo(() => {
|
|
1106
|
-
return dataset.filter((piece) => !!piece.sets).map((piece) => {
|
|
1107
|
-
return __spreadProps$a(__spreadValues$c({}, piece), {
|
|
1108
|
-
coordinate: piece.sets
|
|
1109
|
-
});
|
|
1110
|
-
})[dataset[parseInt(currentPie)] ? parseInt(currentPie) : 0];
|
|
1111
|
-
}, [currentPie, dataset]);
|
|
1112
|
-
usePieAnimation({
|
|
1113
|
-
incomingColumn: arrayOrArray((_b = chart.dataSets) == null ? void 0 : _b.data)[dataset[parseInt(currentPie)] ? parseInt(currentPie) : 0],
|
|
1114
|
-
piezas,
|
|
1115
|
-
setDataset
|
|
1116
|
-
});
|
|
1117
|
-
let innerWidth = chart.ratio.width > chart.ratio.height ? chart.ratio.width : chart.ratio.height;
|
|
1118
|
-
let innerHeight = chart.ratio.width > chart.ratio.height ? chart.ratio.width : chart.ratio.height;
|
|
1119
|
-
if (innerWidth > chart.ratio.maxWidth) {
|
|
1120
|
-
const newValues = adjustDimensions$3({
|
|
1121
|
-
height: innerHeight,
|
|
1122
|
-
width: innerWidth,
|
|
1123
|
-
maxWidth: chart.ratio.maxWidth
|
|
1124
|
-
});
|
|
1125
|
-
innerWidth = newValues.width;
|
|
1126
|
-
innerHeight = newValues.height;
|
|
1127
|
-
}
|
|
1128
|
-
const centerY = useMemo(() => {
|
|
1129
|
-
return innerHeight / 2.5;
|
|
1130
|
-
}, [innerHeight]);
|
|
1131
|
-
const centerX = useMemo(() => {
|
|
1132
|
-
return innerWidth / 2.5;
|
|
1133
|
-
}, [innerWidth]);
|
|
1134
|
-
const top = centerY;
|
|
1135
|
-
const left = centerX;
|
|
1136
|
-
const getValue = (d) => Number(d.value) === 0 && arrayOrArray(piezas.coordinate).length === 1 ? 100 : Number(d.value);
|
|
1137
|
-
const radius = Math.min(innerHeight, innerWidth) / 2.5;
|
|
1138
|
-
const styles = useChartStyles(chart.colorSchema);
|
|
1139
|
-
const colorsArray = styles ? styles.schema : ["#7ad6f4", "#45bdee", "#28a7ea", "#006cbb", "#034698", "#032f64"];
|
|
1140
|
-
const names = arrayOrArray(
|
|
1141
|
-
((_c = dataset[parseInt(currentPie)]) != null ? _c : dataset[0]).sets
|
|
1142
|
-
).map((coord) => {
|
|
1143
|
-
return coord.key;
|
|
1144
|
-
});
|
|
1145
|
-
const colorReference = names.map((name, index) => {
|
|
1146
|
-
return {
|
|
1147
|
-
title: name,
|
|
1148
|
-
color: getBarColor(arrayOrArray(colorsArray), index)
|
|
1149
|
-
};
|
|
1150
|
-
});
|
|
1151
|
-
const { boxRef, elementRef } = usePanAndZoom(
|
|
1152
|
-
void 0,
|
|
1153
|
-
!allowZoom
|
|
1154
|
-
);
|
|
1155
|
-
const previousPaths = useRef([]);
|
|
1156
|
-
const id = useMemo(() => `Pie${uniqueId()}`, []);
|
|
1157
|
-
const charts = arrayOrArray((_d = chart.dataSets) == null ? void 0 : _d.data).filter((piece) => !!piece.sets).map((piece) => {
|
|
1158
|
-
return __spreadProps$a(__spreadValues$c({}, piece), {
|
|
1159
|
-
coordinate: piece.sets
|
|
1160
|
-
});
|
|
1161
|
-
});
|
|
1162
|
-
const chartNames = charts.map((piece) => {
|
|
1163
|
-
return piece.name;
|
|
1164
|
-
});
|
|
1165
|
-
if (!piezas) {
|
|
1166
|
-
return null;
|
|
1167
|
-
}
|
|
1168
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1169
|
-
/* @__PURE__ */ jsx(
|
|
1170
|
-
Box,
|
|
1171
|
-
{
|
|
1172
|
-
ref: boxRef,
|
|
1173
|
-
id,
|
|
1174
|
-
className: `${className ? className : ""} ${chartId} chartBox chartContainer`,
|
|
1175
|
-
sx: { textAlign: "center", pb: spacing(5) },
|
|
1176
|
-
children: /* @__PURE__ */ jsx(
|
|
1177
|
-
"svg",
|
|
1178
|
-
{
|
|
1179
|
-
ref: elementRef,
|
|
1180
|
-
height: radius * 2,
|
|
1181
|
-
width: radius * 2,
|
|
1182
|
-
className: `_${chartId} chart__svg`,
|
|
1183
|
-
children: /* @__PURE__ */ jsx(Group, { top: top != null ? top : 0, left: left != null ? left : 0, children: /* @__PURE__ */ jsx(
|
|
1184
|
-
Pie,
|
|
1185
|
-
{
|
|
1186
|
-
data: arrayOrArray(piezas.coordinate),
|
|
1187
|
-
pieValue: getValue,
|
|
1188
|
-
pieSort: null,
|
|
1189
|
-
outerRadius: radius,
|
|
1190
|
-
children: (pie) => {
|
|
1191
|
-
const paths = arrayOrArray(pie.arcs).map((arc) => {
|
|
1192
|
-
return pie.path(arc);
|
|
1193
|
-
});
|
|
1194
|
-
const result = pie.arcs.map((arc) => {
|
|
1195
|
-
var _a2, _b2, _c2, _d2, _e;
|
|
1196
|
-
const name = arc.data;
|
|
1197
|
-
const arcPath = pie.path(arc);
|
|
1198
|
-
return /* @__PURE__ */ jsx(
|
|
1199
|
-
Slice,
|
|
1200
|
-
{
|
|
1201
|
-
arc,
|
|
1202
|
-
chartId: id,
|
|
1203
|
-
arcPath,
|
|
1204
|
-
chart,
|
|
1205
|
-
actualColor: ((_a2 = colorReference.find((color) => {
|
|
1206
|
-
return color.title === name.key;
|
|
1207
|
-
})) == null ? void 0 : _a2.color.startsWith("#")) ? (_c2 = (_b2 = colorReference.find((color) => {
|
|
1208
|
-
return color.title === name.key;
|
|
1209
|
-
})) == null ? void 0 : _b2.color) != null ? _c2 : "" : `#${(_e = (_d2 = colorReference.find((color) => {
|
|
1210
|
-
return color.title === name.key;
|
|
1211
|
-
})) == null ? void 0 : _d2.color) != null ? _e : ""}`
|
|
1212
|
-
},
|
|
1213
|
-
`${name.key}_${name.value}`
|
|
1214
|
-
);
|
|
1215
|
-
});
|
|
1216
|
-
previousPaths.current = paths;
|
|
1217
|
-
return result;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
) })
|
|
1221
|
-
}
|
|
1222
|
-
)
|
|
1223
|
-
},
|
|
1224
|
-
piezas.name
|
|
1225
|
-
),
|
|
1226
|
-
/* @__PURE__ */ jsxs(Box, { className: "chartLegend__Wrapper", children: [
|
|
1227
|
-
!chart.hideSelector && charts.length > 1 && /* @__PURE__ */ jsxs(Box, { className: "chart__combo__wrapper", children: [
|
|
1228
|
-
/* @__PURE__ */ jsx(Heading, { as: "h6", children: getLabel("lblChartSel").text }),
|
|
1229
|
-
/* @__PURE__ */ jsx(
|
|
1230
|
-
ChartSelector,
|
|
1231
|
-
{
|
|
1232
|
-
chartId,
|
|
1233
|
-
pieces: chartNames,
|
|
1234
|
-
className: "chartSelectorCombo",
|
|
1235
|
-
current: currentPie,
|
|
1236
|
-
setCurrent: setCurrentPie
|
|
1237
|
-
}
|
|
1238
|
-
)
|
|
1239
|
-
] }),
|
|
1240
|
-
chart.showLegend && colorReference.length > 1 && /* @__PURE__ */ jsxs(Box, { className: "chart__legend__wrapper", children: [
|
|
1241
|
-
/* @__PURE__ */ jsx(Heading, { as: "h6", children: getLabel("mnuLeyends").text }),
|
|
1242
|
-
/* @__PURE__ */ jsx(LegendContainer, { id: chartId, references: colorReference })
|
|
1243
|
-
] })
|
|
1244
|
-
] })
|
|
1245
|
-
] });
|
|
1246
|
-
};
|
|
1247
|
-
|
|
1248
|
-
const Bar = ({
|
|
1249
|
-
bar,
|
|
1250
|
-
barGroup,
|
|
1251
|
-
chart,
|
|
1252
|
-
parsedData,
|
|
1253
|
-
isSingle,
|
|
1254
|
-
setsWithColor
|
|
1255
|
-
}) => {
|
|
1256
|
-
var _a;
|
|
1257
|
-
const column = arrayOrArray(chart.dataSets.data)[bar.index];
|
|
1258
|
-
const set = arrayOrArray(column == null ? void 0 : column.sets)[barGroup.index];
|
|
1259
|
-
const currentBarColor = (_a = setsWithColor.find(
|
|
1260
|
-
(innerSet) => innerSet.columnName === column.name && innerSet.key === set.key
|
|
1261
|
-
)) == null ? void 0 : _a.color;
|
|
1262
|
-
const [isHighlighted, setIsHighlighted] = useState(false);
|
|
1263
|
-
const [isAnyHighlighted, setIsAnyHighlighted] = useState(false);
|
|
1264
|
-
const ref = useRef(null);
|
|
1265
|
-
useImperativeComponentEvents({
|
|
1266
|
-
highlight(barNameColumn) {
|
|
1267
|
-
let barName = barNameColumn;
|
|
1268
|
-
let columnName = "";
|
|
1269
|
-
if (barNameColumn.includes("_$_")) {
|
|
1270
|
-
barName = barNameColumn.split("_$_")[0];
|
|
1271
|
-
columnName = barNameColumn.split("_$_")[1];
|
|
1272
|
-
if (isSingle && barNameColumn !== "" && barNameColumn !== void 0) {
|
|
1273
|
-
barName = barNameColumn.split("_$_")[1];
|
|
1274
|
-
columnName = barNameColumn.split("_$_")[1];
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
if (barName.split(" - ").length === 1) {
|
|
1278
|
-
if (arrayOrArray(chart.dataSets.data).length === 1) {
|
|
1279
|
-
setIsHighlighted(barName === parsedData[barGroup.index].columnName);
|
|
1280
|
-
setIsAnyHighlighted(
|
|
1281
|
-
barName !== parsedData[barGroup.index].columnName && barName !== ""
|
|
1282
|
-
);
|
|
1283
|
-
if (barName === parsedData[barGroup.index].columnName || columnName === parsedData[barGroup.index].columnName) {
|
|
1284
|
-
new ApiaUtil().tooltips.open({
|
|
1285
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1286
|
-
/* @__PURE__ */ jsx(
|
|
1287
|
-
"div",
|
|
1288
|
-
{
|
|
1289
|
-
style: {
|
|
1290
|
-
color: currentBarColor
|
|
1291
|
-
},
|
|
1292
|
-
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
1293
|
-
}
|
|
1294
|
-
),
|
|
1295
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
1296
|
-
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
1297
|
-
] }),
|
|
1298
|
-
attachToElement: () => ref.current,
|
|
1299
|
-
attachToElementAnchorPoint: "center"
|
|
1300
|
-
});
|
|
1301
|
-
}
|
|
1302
|
-
} else {
|
|
1303
|
-
setIsHighlighted(barName === bar.key);
|
|
1304
|
-
setIsAnyHighlighted(barName !== bar.key && barName !== "");
|
|
1305
|
-
const currentBar = document.querySelector(
|
|
1306
|
-
`.${parsedData[barGroup.index].columnName}__${bar.key}`
|
|
1307
|
-
);
|
|
1308
|
-
if (barName === bar.key && columnName === parsedData[barGroup.index].columnName) {
|
|
1309
|
-
new ApiaUtil().tooltips.open({
|
|
1310
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1311
|
-
/* @__PURE__ */ jsx(
|
|
1312
|
-
"div",
|
|
1313
|
-
{
|
|
1314
|
-
style: {
|
|
1315
|
-
color: currentBarColor
|
|
1316
|
-
},
|
|
1317
|
-
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
1318
|
-
}
|
|
1319
|
-
),
|
|
1320
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
1321
|
-
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
1322
|
-
] }),
|
|
1323
|
-
attachToElement: () => ref.current,
|
|
1324
|
-
attachToElementAnchorPoint: "center"
|
|
1325
|
-
});
|
|
1326
|
-
} else if (barName === bar.key && currentBar && columnName === "") {
|
|
1327
|
-
new ApiaUtil().tooltips.open({
|
|
1328
|
-
children: parsedData.map((dat, i) => {
|
|
1329
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1330
|
-
/* @__PURE__ */ jsx(
|
|
1331
|
-
"div",
|
|
1332
|
-
{
|
|
1333
|
-
style: {
|
|
1334
|
-
color: currentBarColor
|
|
1335
|
-
},
|
|
1336
|
-
children: /* @__PURE__ */ jsx("strong", { children: dat.columnName })
|
|
1337
|
-
}
|
|
1338
|
-
),
|
|
1339
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: dat[barName] }),
|
|
1340
|
-
/* @__PURE__ */ jsx("div", { children: Object.keys(dat).find(
|
|
1341
|
-
(key) => dat[key] === dat[barName]
|
|
1342
|
-
) }),
|
|
1343
|
-
parsedData[i + 1] && /* @__PURE__ */ jsx("hr", {})
|
|
1344
|
-
] }, `${dat.columnName}_${dat[barName]}`);
|
|
1345
|
-
}),
|
|
1346
|
-
attachToMousePosition: true
|
|
1347
|
-
});
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
} else if (barName.split(" - ").length === 2) {
|
|
1351
|
-
setIsHighlighted(
|
|
1352
|
-
barName.split(" - ")[0] === bar.key && barName.split(" - ")[1] === set.key
|
|
1353
|
-
);
|
|
1354
|
-
setIsAnyHighlighted(
|
|
1355
|
-
barName.split(" - ")[0] !== bar.key && barName.split(" - ")[0] !== ""
|
|
1356
|
-
);
|
|
1357
|
-
if (barName.split(" - ")[0] === bar.key && barName.split(" - ")[1] === set.key && columnName === parsedData[barGroup.index].columnName) {
|
|
1358
|
-
new ApiaUtil().tooltips.open({
|
|
1359
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1360
|
-
/* @__PURE__ */ jsx(
|
|
1361
|
-
"div",
|
|
1362
|
-
{
|
|
1363
|
-
style: {
|
|
1364
|
-
color: currentBarColor
|
|
1365
|
-
},
|
|
1366
|
-
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
1367
|
-
}
|
|
1368
|
-
),
|
|
1369
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
1370
|
-
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
1371
|
-
] }),
|
|
1372
|
-
attachToElement: () => ref.current,
|
|
1373
|
-
attachToElementAnchorPoint: "center"
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
});
|
|
1379
|
-
const { chartId } = useContext(ChartContext);
|
|
1380
|
-
return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsxs(
|
|
1381
|
-
Box,
|
|
1382
|
-
{
|
|
1383
|
-
as: "rect",
|
|
1384
|
-
className: `chart__barRect ${parsedData[barGroup.index].columnName}__${bar.key}`,
|
|
1385
|
-
ref,
|
|
1386
|
-
sx: useMemo(
|
|
1387
|
-
() => ({
|
|
1388
|
-
fill: isAnyHighlighted ? `#${tinycolor(currentBarColor).desaturate(70).toHex()}` : currentBarColor,
|
|
1389
|
-
"&:hover": {
|
|
1390
|
-
fill: `#${tinycolor(currentBarColor).saturate(25).toHex()}`
|
|
1391
|
-
},
|
|
1392
|
-
transition: "fill 500ms, opacity 500ms",
|
|
1393
|
-
x: bar.x,
|
|
1394
|
-
y: bar.y,
|
|
1395
|
-
width: bar.width,
|
|
1396
|
-
opacity: isAnyHighlighted && !isHighlighted ? 0.15 : 1,
|
|
1397
|
-
height: bar.height > 0 ? bar.height : 0
|
|
1398
|
-
}),
|
|
1399
|
-
[
|
|
1400
|
-
bar.height,
|
|
1401
|
-
bar.width,
|
|
1402
|
-
bar.x,
|
|
1403
|
-
bar.y,
|
|
1404
|
-
currentBarColor,
|
|
1405
|
-
isAnyHighlighted,
|
|
1406
|
-
isHighlighted
|
|
1407
|
-
]
|
|
1408
|
-
),
|
|
1409
|
-
onMouseEnter: (ev) => {
|
|
1410
|
-
var _a2, _b, _c;
|
|
1411
|
-
console.log(bar.key, parsedData[barGroup.index].columnName);
|
|
1412
|
-
if (!isSingle) {
|
|
1413
|
-
legendContainerMethods.highlight(chartId, bar.key);
|
|
1414
|
-
} else {
|
|
1415
|
-
legendContainerMethods.highlight(
|
|
1416
|
-
chartId,
|
|
1417
|
-
parsedData[barGroup.index].columnName
|
|
1418
|
-
);
|
|
1419
|
-
}
|
|
1420
|
-
chartMethods(
|
|
1421
|
-
chartId,
|
|
1422
|
-
"highlight",
|
|
1423
|
-
`${bar.key}_$_${parsedData[barGroup.index].columnName}`
|
|
1424
|
-
);
|
|
1425
|
-
(_a2 = ev.target.classList) == null ? void 0 : _a2.add("over");
|
|
1426
|
-
const point = {
|
|
1427
|
-
x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
|
|
1428
|
-
y: (_c = localPoint(ev)) == null ? void 0 : _c.y
|
|
1429
|
-
};
|
|
1430
|
-
if (!point || !chart.showValues)
|
|
1431
|
-
return;
|
|
1432
|
-
},
|
|
1433
|
-
onMouseLeave: (ev) => {
|
|
1434
|
-
var _a2;
|
|
1435
|
-
legendContainerMethods.highlight(chartId, "");
|
|
1436
|
-
chartMethods(chartId, "highlight", "");
|
|
1437
|
-
(_a2 = ev.target.classList) == null ? void 0 : _a2.remove("over");
|
|
1438
|
-
},
|
|
1439
|
-
children: [
|
|
1440
|
-
/* @__PURE__ */ jsx(
|
|
1441
|
-
"animate",
|
|
1442
|
-
{
|
|
1443
|
-
attributeName: "height",
|
|
1444
|
-
from: 0,
|
|
1445
|
-
to: bar.height,
|
|
1446
|
-
dur: "0.5s",
|
|
1447
|
-
calcMode: "paced",
|
|
1448
|
-
keySplines: "0.5 0 0.5 1;",
|
|
1449
|
-
keyTimes: "0; 1"
|
|
1450
|
-
}
|
|
1451
|
-
),
|
|
1452
|
-
/* @__PURE__ */ jsx(
|
|
1453
|
-
"animate",
|
|
1454
|
-
{
|
|
1455
|
-
attributeName: "y",
|
|
1456
|
-
from: bar.y + bar.height,
|
|
1457
|
-
to: bar.y,
|
|
1458
|
-
dur: "0.5s",
|
|
1459
|
-
calcMode: "paced",
|
|
1460
|
-
keySplines: "0.5 0 0.5 1;",
|
|
1461
|
-
keyTimes: "0; 1"
|
|
1462
|
-
}
|
|
1463
|
-
)
|
|
1464
|
-
]
|
|
1465
|
-
}
|
|
1466
|
-
) });
|
|
1467
|
-
};
|
|
1468
|
-
|
|
1469
|
-
var __defProp$b = Object.defineProperty;
|
|
1470
|
-
var __defProps$9 = Object.defineProperties;
|
|
1471
|
-
var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
|
|
1472
|
-
var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
|
|
1473
|
-
var __hasOwnProp$b = Object.prototype.hasOwnProperty;
|
|
1474
|
-
var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
|
|
1475
|
-
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1476
|
-
var __spreadValues$b = (a, b) => {
|
|
1477
|
-
for (var prop in b || (b = {}))
|
|
1478
|
-
if (__hasOwnProp$b.call(b, prop))
|
|
1479
|
-
__defNormalProp$b(a, prop, b[prop]);
|
|
1480
|
-
if (__getOwnPropSymbols$b)
|
|
1481
|
-
for (var prop of __getOwnPropSymbols$b(b)) {
|
|
1482
|
-
if (__propIsEnum$b.call(b, prop))
|
|
1483
|
-
__defNormalProp$b(a, prop, b[prop]);
|
|
1484
|
-
}
|
|
1485
|
-
return a;
|
|
1486
|
-
};
|
|
1487
|
-
var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
|
|
1488
|
-
function adjustDimensions$2({
|
|
1489
|
-
width,
|
|
1490
|
-
height,
|
|
1491
|
-
maxWidth
|
|
1492
|
-
}) {
|
|
1493
|
-
if (width <= maxWidth) {
|
|
1494
|
-
return { width, height };
|
|
1495
|
-
}
|
|
1496
|
-
const ratio = width / height;
|
|
1497
|
-
const newWidth = maxWidth;
|
|
1498
|
-
const newHeight = Math.floor(newWidth / ratio);
|
|
1499
|
-
return { width: newWidth, height: newHeight };
|
|
1500
|
-
}
|
|
1501
|
-
const getXValue = (d) => d.columnName;
|
|
1502
|
-
const VerticalBars = ({
|
|
1503
|
-
margin = { top: 20, left: 100, bottom: 24, right: 0 },
|
|
1504
|
-
chart,
|
|
1505
|
-
className,
|
|
1506
|
-
chartId,
|
|
1507
|
-
allowZoom
|
|
1508
|
-
}) => {
|
|
1509
|
-
var _a;
|
|
1510
|
-
const effectiveMargin = parseMargin(margin);
|
|
1511
|
-
if (!chart.showAxisYTitle && effectiveMargin.left > 50) {
|
|
1512
|
-
effectiveMargin.left = 50;
|
|
1513
|
-
}
|
|
1514
|
-
let innerWidth = chart.ratio.width + (-effectiveMargin.left - effectiveMargin.right) / 2;
|
|
1515
|
-
let innerHeight = chart.ratio.height + (chart.showAxisXTitle ? -effectiveMargin.top - effectiveMargin.bottom : (-effectiveMargin.top - effectiveMargin.bottom) / 2);
|
|
1516
|
-
if (innerWidth > chart.ratio.maxWidth) {
|
|
1517
|
-
const newValues = adjustDimensions$2({
|
|
1518
|
-
height: innerHeight,
|
|
1519
|
-
width: innerWidth,
|
|
1520
|
-
maxWidth: chart.ratio.maxWidth
|
|
1521
|
-
});
|
|
1522
|
-
innerWidth = newValues.width;
|
|
1523
|
-
innerHeight = newValues.height;
|
|
1524
|
-
}
|
|
1525
|
-
const styles = useChartStyles(chart.colorSchema);
|
|
1526
|
-
const columnas = arrayOrArray((_a = chart.dataSets) == null ? void 0 : _a.data).filter((column) => !!column.sets).map((column) => {
|
|
1527
|
-
return __spreadProps$9(__spreadValues$b({}, column), {
|
|
1528
|
-
sets: column.sets
|
|
1529
|
-
});
|
|
1530
|
-
});
|
|
1531
|
-
const xValues = arrayOrArray(columnas[0].sets).map(
|
|
1532
|
-
(innerCoord) => innerCoord.key
|
|
1533
|
-
);
|
|
1534
|
-
const columnNames = columnas.map((col) => {
|
|
1535
|
-
return col.name;
|
|
1536
|
-
});
|
|
1537
|
-
const parsedData = xValues.map((x) => {
|
|
1538
|
-
const obj = columnas.reduce(
|
|
1539
|
-
(acc, column) => {
|
|
1540
|
-
return __spreadProps$9(__spreadValues$b({}, acc), {
|
|
1541
|
-
[column.name]: arrayOrArray(column.sets).filter((coord) => {
|
|
1542
|
-
return coord.key === x;
|
|
1543
|
-
})[0].value
|
|
1544
|
-
});
|
|
1545
|
-
},
|
|
1546
|
-
{ columnName: x }
|
|
1547
|
-
);
|
|
1548
|
-
return obj;
|
|
1549
|
-
});
|
|
1550
|
-
const xScale = scaleBand({
|
|
1551
|
-
range: [
|
|
1552
|
-
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.left,
|
|
1553
|
-
chart.ratio.width
|
|
1554
|
-
],
|
|
1555
|
-
domain: parsedData.map(getXValue),
|
|
1556
|
-
padding: 0.2
|
|
1557
|
-
});
|
|
1558
|
-
const numericXScale = scaleBand({
|
|
1559
|
-
range: [
|
|
1560
|
-
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.left,
|
|
1561
|
-
chart.ratio.width
|
|
1562
|
-
],
|
|
1563
|
-
domain: parsedData.map((_, i) => `${i + 1}`),
|
|
1564
|
-
padding: 0.2
|
|
1565
|
-
});
|
|
1566
|
-
const columnGroupScale = scaleBand({
|
|
1567
|
-
domain: columnNames,
|
|
1568
|
-
range: [0, xScale.bandwidth()]
|
|
1569
|
-
});
|
|
1570
|
-
const yScaleLog = scaleLog({
|
|
1571
|
-
range: [
|
|
1572
|
-
innerHeight,
|
|
1573
|
-
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top
|
|
1574
|
-
],
|
|
1575
|
-
domain: [
|
|
1576
|
-
1,
|
|
1577
|
-
Math.max(
|
|
1578
|
-
...parsedData.map(
|
|
1579
|
-
(d) => Math.max(...columnNames.map((key) => Number(d[key])))
|
|
1580
|
-
)
|
|
1581
|
-
)
|
|
1582
|
-
],
|
|
1583
|
-
base: 10
|
|
1584
|
-
});
|
|
1585
|
-
const yScaleLine = scaleLinear({
|
|
1586
|
-
range: [
|
|
1587
|
-
innerHeight,
|
|
1588
|
-
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top
|
|
1589
|
-
],
|
|
1590
|
-
domain: [
|
|
1591
|
-
0,
|
|
1592
|
-
Math.max(
|
|
1593
|
-
...parsedData.map(
|
|
1594
|
-
(d) => Math.max(...columnNames.map((key) => Number(d[key])))
|
|
1595
|
-
)
|
|
1596
|
-
)
|
|
1597
|
-
]
|
|
1598
|
-
});
|
|
1599
|
-
const color = scaleOrdinal({
|
|
1600
|
-
domain: columnNames,
|
|
1601
|
-
range: columnas.map((col) => col.color)
|
|
1602
|
-
});
|
|
1603
|
-
const isLogScale = false;
|
|
1604
|
-
const yScale = useMemo(() => {
|
|
1605
|
-
{
|
|
1606
|
-
return yScaleLine;
|
|
1607
|
-
}
|
|
1608
|
-
}, [isLogScale, yScaleLine, yScaleLog]);
|
|
1609
|
-
const id = useMemo(() => `VerticalBars${uniqueId()}`, []);
|
|
1610
|
-
useLayoutEffect(() => {
|
|
1611
|
-
document.querySelectorAll(`#${id} .tickLabel`).forEach((current) => {
|
|
1612
|
-
const box = current.getBoundingClientRect();
|
|
1613
|
-
if (box.width > 125) {
|
|
1614
|
-
current.style.width = "125px";
|
|
1615
|
-
current.style.overflow = "hidden";
|
|
1616
|
-
current.style.textOverflow = "ellipsis";
|
|
1617
|
-
current.style.whiteSpace = "nowrap";
|
|
1618
|
-
}
|
|
1619
|
-
current.style.transformOrigin = current.getAttribute("x") + "px 14px";
|
|
1620
|
-
current.style.transform = `rotate(25deg)`;
|
|
1621
|
-
});
|
|
1622
|
-
});
|
|
1623
|
-
const { boxRef, elementRef } = usePanAndZoom(
|
|
1624
|
-
void 0,
|
|
1625
|
-
!allowZoom
|
|
1626
|
-
);
|
|
1627
|
-
const setsWithColor = arrayOrArray(chart.dataSets.data).map((data, index) => {
|
|
1628
|
-
const isSingle = arrayOrArray(chart.dataSets.data).length === 1;
|
|
1629
|
-
const dataColor = data.color !== "" && data.color !== void 0 ? data.color : arrayOrArray(
|
|
1630
|
-
styles ? styles.schema : [
|
|
1631
|
-
"#7ad6f4",
|
|
1632
|
-
"#45bdee",
|
|
1633
|
-
"#28a7ea",
|
|
1634
|
-
"#006cbb",
|
|
1635
|
-
"#034698",
|
|
1636
|
-
"#032f64"
|
|
1637
|
-
]
|
|
1638
|
-
).length > 0 ? getBarColor(
|
|
1639
|
-
arrayOrArray(
|
|
1640
|
-
styles ? styles.schema : [
|
|
1641
|
-
"#7ad6f4",
|
|
1642
|
-
"#45bdee",
|
|
1643
|
-
"#28a7ea",
|
|
1644
|
-
"#006cbb",
|
|
1645
|
-
"#034698",
|
|
1646
|
-
"#032f64"
|
|
1647
|
-
]
|
|
1648
|
-
),
|
|
1649
|
-
index,
|
|
1650
|
-
isSingle
|
|
1651
|
-
) : "";
|
|
1652
|
-
const returnColumnsArray = [];
|
|
1653
|
-
arrayOrArray(data.sets).forEach((set) => {
|
|
1654
|
-
if (set.color !== "" && set.color !== void 0) {
|
|
1655
|
-
returnColumnsArray.push(__spreadProps$9(__spreadValues$b({}, set), { columnName: data.name }));
|
|
1656
|
-
} else {
|
|
1657
|
-
returnColumnsArray.push(__spreadProps$9(__spreadValues$b({}, set), {
|
|
1658
|
-
color: dataColor,
|
|
1659
|
-
columnName: data.name
|
|
1660
|
-
}));
|
|
1661
|
-
}
|
|
1662
|
-
});
|
|
1663
|
-
return returnColumnsArray;
|
|
1664
|
-
});
|
|
1665
|
-
const colorReference = arrayOrArray(chart.dataSets.data).map(
|
|
1666
|
-
(data, index) => {
|
|
1667
|
-
const isSingle = arrayOrArray(chart.dataSets.data).length === 1;
|
|
1668
|
-
const dataColor = data.color !== "" && data.color !== void 0 ? data.color : arrayOrArray(
|
|
1669
|
-
styles ? styles.schema : [
|
|
1670
|
-
"#7ad6f4",
|
|
1671
|
-
"#45bdee",
|
|
1672
|
-
"#28a7ea",
|
|
1673
|
-
"#006cbb",
|
|
1674
|
-
"#034698",
|
|
1675
|
-
"#032f64"
|
|
1676
|
-
]
|
|
1677
|
-
).length > 0 ? getBarColor(
|
|
1678
|
-
arrayOrArray(
|
|
1679
|
-
styles ? styles.schema : [
|
|
1680
|
-
"#7ad6f4",
|
|
1681
|
-
"#45bdee",
|
|
1682
|
-
"#28a7ea",
|
|
1683
|
-
"#006cbb",
|
|
1684
|
-
"#034698",
|
|
1685
|
-
"#032f64"
|
|
1686
|
-
]
|
|
1687
|
-
),
|
|
1688
|
-
index,
|
|
1689
|
-
isSingle
|
|
1690
|
-
) : "";
|
|
1691
|
-
return {
|
|
1692
|
-
color: dataColor,
|
|
1693
|
-
title: data.name
|
|
1694
|
-
};
|
|
1695
|
-
}
|
|
1696
|
-
);
|
|
1697
|
-
let numberReference = [];
|
|
1698
|
-
if (colorReference.length === 1) {
|
|
1699
|
-
numberReference = arrayOrArray(
|
|
1700
|
-
arrayOrArray(chart.dataSets.data)[0].sets
|
|
1701
|
-
).map((data, index) => {
|
|
1702
|
-
return {
|
|
1703
|
-
color: `${index + 1}`,
|
|
1704
|
-
title: data.key
|
|
1705
|
-
};
|
|
1706
|
-
});
|
|
1707
|
-
}
|
|
1708
|
-
arrayOrArray(chart.dataSets.data).map((data) => {
|
|
1709
|
-
const returnArray = [];
|
|
1710
|
-
arrayOrArray(data.sets).forEach((set) => {
|
|
1711
|
-
if (set.color !== "" && set.color !== void 0) {
|
|
1712
|
-
returnArray.push({
|
|
1713
|
-
color: set.color,
|
|
1714
|
-
title: data.name + " - " + set.key
|
|
1715
|
-
});
|
|
1716
|
-
}
|
|
1717
|
-
});
|
|
1718
|
-
return returnArray;
|
|
1719
|
-
}).flat().forEach((addRef) => colorReference.push(addRef));
|
|
1720
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1721
|
-
/* @__PURE__ */ jsx(
|
|
1722
|
-
Box,
|
|
1723
|
-
{
|
|
1724
|
-
ref: boxRef,
|
|
1725
|
-
id,
|
|
1726
|
-
className: `${className != null ? className : ""} ${chart.title} chartBox chartContainer`,
|
|
1727
|
-
sx: {
|
|
1728
|
-
overflow: "hidden"
|
|
1729
|
-
},
|
|
1730
|
-
children: /* @__PURE__ */ jsxs(
|
|
1731
|
-
"svg",
|
|
1732
|
-
{
|
|
1733
|
-
ref: elementRef,
|
|
1734
|
-
className: `_${chartId} chart__svg`,
|
|
1735
|
-
height: chart.ratio.height,
|
|
1736
|
-
width: chart.ratio.width,
|
|
1737
|
-
children: [
|
|
1738
|
-
chart.showGrid && /* @__PURE__ */ jsx(
|
|
1739
|
-
Grid.Grid,
|
|
1740
|
-
{
|
|
1741
|
-
xScale,
|
|
1742
|
-
yScale,
|
|
1743
|
-
left: 0,
|
|
1744
|
-
width: chart.ratio.width,
|
|
1745
|
-
height: innerHeight,
|
|
1746
|
-
numTicksRows: 10,
|
|
1747
|
-
numTicksColumns: 10,
|
|
1748
|
-
top: (typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top) - 20
|
|
1749
|
-
}
|
|
1750
|
-
),
|
|
1751
|
-
/* @__PURE__ */ jsx(
|
|
1752
|
-
Group,
|
|
1753
|
-
{
|
|
1754
|
-
top: (typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top) - 20,
|
|
1755
|
-
children: /* @__PURE__ */ jsx(
|
|
1756
|
-
BarGroup,
|
|
1757
|
-
{
|
|
1758
|
-
data: parsedData,
|
|
1759
|
-
keys: columnNames,
|
|
1760
|
-
height: innerHeight,
|
|
1761
|
-
x0: getXValue,
|
|
1762
|
-
x0Scale: xScale,
|
|
1763
|
-
x1Scale: columnGroupScale,
|
|
1764
|
-
yScale,
|
|
1765
|
-
color,
|
|
1766
|
-
children: (barGroups) => barGroups.map((barGroup) => {
|
|
1767
|
-
return /* @__PURE__ */ jsx(
|
|
1768
|
-
Group,
|
|
1769
|
-
{
|
|
1770
|
-
left: barGroup.x0,
|
|
1771
|
-
children: barGroup.bars.map((bar) => {
|
|
1772
|
-
const key = `${barGroup.index}-${bar.index}-${bar.key}`;
|
|
1773
|
-
return /* @__PURE__ */ jsx(
|
|
1774
|
-
Bar,
|
|
1775
|
-
{
|
|
1776
|
-
isSingle: barGroup.bars.length === 1,
|
|
1777
|
-
bar,
|
|
1778
|
-
barGroup,
|
|
1779
|
-
chart,
|
|
1780
|
-
parsedData,
|
|
1781
|
-
setsWithColor: setsWithColor.flat()
|
|
1782
|
-
},
|
|
1783
|
-
key
|
|
1784
|
-
);
|
|
1785
|
-
})
|
|
1786
|
-
},
|
|
1787
|
-
`bar-group-${barGroup.index}-${barGroup.x0}`
|
|
1788
|
-
);
|
|
1789
|
-
})
|
|
1790
|
-
}
|
|
1791
|
-
)
|
|
1792
|
-
}
|
|
1793
|
-
),
|
|
1794
|
-
/* @__PURE__ */ jsx(
|
|
1795
|
-
AxisLeft,
|
|
1796
|
-
{
|
|
1797
|
-
scale: yScale,
|
|
1798
|
-
left: effectiveMargin.left,
|
|
1799
|
-
label: chart.chartType !== "pie2D" && chart.showAxisYTitle ? chart.axisYTitle : "",
|
|
1800
|
-
tickComponent: (props) => {
|
|
1801
|
-
var _a2;
|
|
1802
|
-
let value = Number((_a2 = props.formattedValue) == null ? void 0 : _a2.replace(",", ""));
|
|
1803
|
-
let counter = -1;
|
|
1804
|
-
const units = ["k", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"];
|
|
1805
|
-
while (value >= 1e3) {
|
|
1806
|
-
value = value / 1e3;
|
|
1807
|
-
counter++;
|
|
1808
|
-
}
|
|
1809
|
-
let stringValue = `${value}`;
|
|
1810
|
-
if (stringValue.length > 3) {
|
|
1811
|
-
stringValue = stringValue.slice(0, 3);
|
|
1812
|
-
}
|
|
1813
|
-
if (stringValue.endsWith(".")) {
|
|
1814
|
-
stringValue = stringValue.replace(".", "");
|
|
1815
|
-
}
|
|
1816
|
-
const newValue = `${stringValue}${counter >= 0 ? units[counter] : ""}`;
|
|
1817
|
-
return /* @__PURE__ */ jsx(Fragment, { children: chart.showAxisYTitle && /* @__PURE__ */ jsx(
|
|
1818
|
-
"text",
|
|
1819
|
-
{
|
|
1820
|
-
dx: props.dx,
|
|
1821
|
-
dy: props.dy,
|
|
1822
|
-
fill: props.fill,
|
|
1823
|
-
fontSize: props.fontSize,
|
|
1824
|
-
textAnchor: props.textAnchor,
|
|
1825
|
-
x: props.x,
|
|
1826
|
-
y: props.y,
|
|
1827
|
-
children: newValue
|
|
1828
|
-
}
|
|
1829
|
-
) });
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
),
|
|
1833
|
-
/* @__PURE__ */ jsx(
|
|
1834
|
-
AxisBottom,
|
|
1835
|
-
{
|
|
1836
|
-
top: innerHeight,
|
|
1837
|
-
scale: colorReference.length === 1 && numberReference.length > 0 ? numericXScale : xScale,
|
|
1838
|
-
label: chart.chartType !== "pie2D" && chart.showAxisXTitle ? chart.axisXTitle : "",
|
|
1839
|
-
tickLabelProps: { display: "none" },
|
|
1840
|
-
tickLineProps: { display: "none" },
|
|
1841
|
-
labelOffset: 0
|
|
1842
|
-
}
|
|
1843
|
-
)
|
|
1844
|
-
]
|
|
1845
|
-
}
|
|
1846
|
-
)
|
|
1847
|
-
}
|
|
1848
|
-
),
|
|
1849
|
-
/* @__PURE__ */ jsx(Box, { className: "chartLegend__Wrapper", children: chart.showLegend && colorReference.length !== 0 && /* @__PURE__ */ jsxs(Box, { className: "chart__legend__wrapper", children: [
|
|
1850
|
-
/* @__PURE__ */ jsx(Heading, { as: "h6", children: getLabel("mnuLeyends").text }),
|
|
1851
|
-
/* @__PURE__ */ jsx(
|
|
1852
|
-
LegendContainer,
|
|
1853
|
-
{
|
|
1854
|
-
id: chartId,
|
|
1855
|
-
references: colorReference.length === 1 && numberReference.length > 0 ? numberReference : colorReference,
|
|
1856
|
-
useNumbered: colorReference.length === 1
|
|
1857
|
-
}
|
|
1858
|
-
)
|
|
1859
|
-
] }) })
|
|
1860
|
-
] });
|
|
1861
|
-
};
|
|
1862
|
-
|
|
1863
|
-
const Node = ({
|
|
1864
|
-
currentCircle,
|
|
1865
|
-
innerKey,
|
|
1866
|
-
cx,
|
|
1867
|
-
cy,
|
|
1868
|
-
// coordinate,
|
|
1869
|
-
color,
|
|
1870
|
-
setCurrentCircle
|
|
1871
|
-
}) => {
|
|
1872
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1873
|
-
currentCircle.includes(innerKey) && /* @__PURE__ */ jsx(
|
|
1874
|
-
"circle",
|
|
1875
|
-
{
|
|
1876
|
-
r: 6,
|
|
1877
|
-
cx,
|
|
1878
|
-
cy,
|
|
1879
|
-
stroke: `#${tinycolor(color).saturate(25).toHex()}`,
|
|
1880
|
-
fill: `#${tinycolor(color).saturate(25).toHex()}`
|
|
1881
|
-
}
|
|
1882
|
-
),
|
|
1883
|
-
/* @__PURE__ */ jsx(
|
|
1884
|
-
"circle",
|
|
1885
|
-
{
|
|
1886
|
-
r: 3,
|
|
1887
|
-
cx,
|
|
1888
|
-
cy,
|
|
1889
|
-
stroke: `#${tinycolor(color).darken(15).toHex()}`,
|
|
1890
|
-
fill: `#${tinycolor(color).darken(15).toHex()}`
|
|
1891
|
-
}
|
|
1892
|
-
),
|
|
1893
|
-
/* @__PURE__ */ jsx(
|
|
1894
|
-
"circle",
|
|
1895
|
-
{
|
|
1896
|
-
r: 6,
|
|
1897
|
-
cx,
|
|
1898
|
-
cy,
|
|
1899
|
-
stroke: "transparent",
|
|
1900
|
-
fill: "transparent",
|
|
1901
|
-
onMouseEnter: () => {
|
|
1902
|
-
setCurrentCircle([innerKey]);
|
|
1903
|
-
},
|
|
1904
|
-
onMouseLeave: () => {
|
|
1905
|
-
setCurrentCircle([]);
|
|
1906
|
-
},
|
|
1907
|
-
style: { cursor: "pointer" }
|
|
1908
|
-
}
|
|
1909
|
-
)
|
|
1910
|
-
] }, innerKey);
|
|
1911
|
-
};
|
|
1912
|
-
|
|
1913
|
-
var __defProp$a = Object.defineProperty;
|
|
1914
|
-
var __defProps$8 = Object.defineProperties;
|
|
1915
|
-
var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
|
|
1916
|
-
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
1917
|
-
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
1918
|
-
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
1919
|
-
var __pow = Math.pow;
|
|
1920
|
-
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1921
|
-
var __spreadValues$a = (a, b) => {
|
|
1922
|
-
for (var prop in b || (b = {}))
|
|
1923
|
-
if (__hasOwnProp$a.call(b, prop))
|
|
1924
|
-
__defNormalProp$a(a, prop, b[prop]);
|
|
1925
|
-
if (__getOwnPropSymbols$a)
|
|
1926
|
-
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
1927
|
-
if (__propIsEnum$a.call(b, prop))
|
|
1928
|
-
__defNormalProp$a(a, prop, b[prop]);
|
|
1929
|
-
}
|
|
1930
|
-
return a;
|
|
1931
|
-
};
|
|
1932
|
-
var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
|
|
1933
|
-
function adjustDimensions$1({
|
|
1934
|
-
width,
|
|
1935
|
-
height,
|
|
1936
|
-
maxWidth
|
|
1937
|
-
}) {
|
|
1938
|
-
if (width <= maxWidth) {
|
|
1939
|
-
return { width, height };
|
|
1940
|
-
}
|
|
1941
|
-
const ratio = width / height;
|
|
1942
|
-
const newWidth = maxWidth;
|
|
1943
|
-
const newHeight = Math.floor(newWidth / ratio);
|
|
1944
|
-
return { width: newWidth, height: newHeight };
|
|
1945
|
-
}
|
|
1946
|
-
function getX(coordinate) {
|
|
1947
|
-
return coordinate.key;
|
|
1948
|
-
}
|
|
1949
|
-
function getY(coordinate) {
|
|
1950
|
-
return Number(coordinate.value);
|
|
1951
|
-
}
|
|
1952
|
-
function parseData(chart) {
|
|
1953
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1954
|
-
const setsArray = arrayOrArray((_a = chart.dataSets) == null ? void 0 : _a.data).map(
|
|
1955
|
-
(col) => arrayOrArray(col.sets)
|
|
1956
|
-
);
|
|
1957
|
-
let longestLine = [];
|
|
1958
|
-
let longestLineIndex = -1;
|
|
1959
|
-
for (let i = 0; i < setsArray.length; i++) {
|
|
1960
|
-
const array = setsArray[i];
|
|
1961
|
-
if (!longestLine || array.length > longestLine.length) {
|
|
1962
|
-
longestLine = array;
|
|
1963
|
-
longestLineIndex = i;
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
const lines = arrayOrArray((_b = chart.dataSets) == null ? void 0 : _b.data);
|
|
1967
|
-
const nodesDataArray = lines.map((line) => line.sets);
|
|
1968
|
-
const nodesData = nodesDataArray.reduce(
|
|
1969
|
-
(rec, d) => arrayOrArray(rec).concat(d),
|
|
1970
|
-
[]
|
|
1971
|
-
);
|
|
1972
|
-
return {
|
|
1973
|
-
lines,
|
|
1974
|
-
longestLine,
|
|
1975
|
-
longestLineIndex,
|
|
1976
|
-
tallestLine: [...new Set(nodesData.map((value) => value.value))],
|
|
1977
|
-
xScale: scaleOrdinal({
|
|
1978
|
-
domain: longestLine.map(getX)
|
|
1979
|
-
}),
|
|
1980
|
-
yScale: scaleLinear({
|
|
1981
|
-
domain: [
|
|
1982
|
-
((_c = min(nodesData, getY)) != null ? _c : 0) < 0 ? (_d = min(nodesData, getY)) != null ? _d : 0 : 0,
|
|
1983
|
-
(_e = max(nodesData, getY)) != null ? _e : 1
|
|
1984
|
-
]
|
|
1985
|
-
}),
|
|
1986
|
-
yScaleLog: scaleLog({
|
|
1987
|
-
domain: [
|
|
1988
|
-
((_f = min(nodesData, getY)) != null ? _f : 1) > 0 ? (_g = min(nodesData, getY)) != null ? _g : 1 : 1,
|
|
1989
|
-
(_h = max(nodesData, getY)) != null ? _h : 10
|
|
1990
|
-
]
|
|
1991
|
-
})
|
|
1992
|
-
};
|
|
1993
|
-
}
|
|
1994
|
-
const LineChart = ({
|
|
1995
|
-
chart,
|
|
1996
|
-
margin = { top: 20, left: 100, bottom: 24, right: 0 },
|
|
1997
|
-
chartId,
|
|
1998
|
-
allowZoom
|
|
1999
|
-
}) => {
|
|
2000
|
-
const effectiveMargin = parseMargin(margin);
|
|
2001
|
-
if (!chart.showAxisYTitle && effectiveMargin.left > 50) {
|
|
2002
|
-
effectiveMargin.left = 50;
|
|
2003
|
-
}
|
|
2004
|
-
let innerWidth = chart.ratio.width - (effectiveMargin.left + effectiveMargin.right) / 2;
|
|
2005
|
-
let innerHeight = chart.ratio.height - (effectiveMargin.top + effectiveMargin.bottom) / 2;
|
|
2006
|
-
if (innerWidth > chart.ratio.maxWidth) {
|
|
2007
|
-
const newValues = adjustDimensions$1({
|
|
2008
|
-
height: innerHeight,
|
|
2009
|
-
width: innerWidth,
|
|
2010
|
-
maxWidth: chart.ratio.maxWidth
|
|
2011
|
-
});
|
|
2012
|
-
innerWidth = newValues.width;
|
|
2013
|
-
innerHeight = newValues.height;
|
|
2014
|
-
}
|
|
2015
|
-
const { lines, xScale, yScale, yScaleLog, longestLine } = parseData(chart);
|
|
2016
|
-
const styles = useChartStyles(chart.colorSchema);
|
|
2017
|
-
const coordinates = arrayOrArray(lines[0].sets);
|
|
2018
|
-
const coordinatesArray = lines.map((col) => {
|
|
2019
|
-
return col.sets;
|
|
2020
|
-
});
|
|
2021
|
-
const divideRangeBetweenStrings = (min2, max2, strings) => {
|
|
2022
|
-
const numStrings = strings.length;
|
|
2023
|
-
const step = (max2 - min2) / (numStrings - 1);
|
|
2024
|
-
const resultArray = [];
|
|
2025
|
-
let currentValue = min2;
|
|
2026
|
-
for (let i = 0; i < numStrings; i++) {
|
|
2027
|
-
resultArray.push(currentValue);
|
|
2028
|
-
currentValue += step;
|
|
2029
|
-
}
|
|
2030
|
-
return resultArray;
|
|
2031
|
-
};
|
|
2032
|
-
const xScaleRange = useMemo(() => {
|
|
2033
|
-
const rangeArr = [
|
|
2034
|
-
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.left,
|
|
2035
|
-
innerWidth
|
|
2036
|
-
];
|
|
2037
|
-
return divideRangeBetweenStrings(rangeArr[0], rangeArr[1], longestLine);
|
|
2038
|
-
}, [effectiveMargin, innerWidth, longestLine]);
|
|
2039
|
-
xScale.range(xScaleRange);
|
|
2040
|
-
const yScaleRange = useMemo(() => {
|
|
2041
|
-
const rangeArr = [
|
|
2042
|
-
innerHeight - (effectiveMargin.top + effectiveMargin.bottom),
|
|
2043
|
-
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top
|
|
2044
|
-
];
|
|
2045
|
-
return rangeArr;
|
|
2046
|
-
}, [effectiveMargin, innerHeight]);
|
|
2047
|
-
yScale.range(yScaleRange);
|
|
2048
|
-
yScaleLog.range([
|
|
2049
|
-
innerHeight,
|
|
2050
|
-
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top
|
|
2051
|
-
]);
|
|
2052
|
-
const [currentCircle, setCurrentCircle] = useState([]);
|
|
2053
|
-
const actualYScale = useMemo(() => {
|
|
2054
|
-
return yScale;
|
|
2055
|
-
}, [yScale]);
|
|
2056
|
-
const id = useMemo(() => `Linear${uniqueId()}`, []);
|
|
2057
|
-
useLayoutEffect(() => {
|
|
2058
|
-
document.querySelectorAll(`#${id} .tickLabel`).forEach((current) => {
|
|
2059
|
-
const width = current.getBoundingClientRect().width;
|
|
2060
|
-
current.style.transformOrigin = current.getAttribute("x") + "px 14px";
|
|
2061
|
-
current.style.transform = `rotate(25deg) translateX(${width / 2}px)`;
|
|
2062
|
-
});
|
|
2063
|
-
});
|
|
2064
|
-
function addNameToProps(names, objects, fixedValue) {
|
|
2065
|
-
return objects.map((object, index) => {
|
|
2066
|
-
const nameIndex = Math.floor(index / fixedValue);
|
|
2067
|
-
const name = names[nameIndex];
|
|
2068
|
-
return __spreadProps$8(__spreadValues$a({}, object), { columnName: name });
|
|
2069
|
-
});
|
|
2070
|
-
}
|
|
2071
|
-
const setsWithColor = arrayOrArray(chart.dataSets.data).map((data, index) => {
|
|
2072
|
-
const isSingle = arrayOrArray(chart.dataSets.data).length === 1;
|
|
2073
|
-
const dataColor = data.color !== "" && data.color !== void 0 ? data.color : arrayOrArray(
|
|
2074
|
-
styles ? styles.schema : [
|
|
2075
|
-
"#7ad6f4",
|
|
2076
|
-
"#45bdee",
|
|
2077
|
-
"#28a7ea",
|
|
2078
|
-
"#006cbb",
|
|
2079
|
-
"#034698",
|
|
2080
|
-
"#032f64"
|
|
2081
|
-
]
|
|
2082
|
-
).length > 0 ? getBarColor(
|
|
2083
|
-
arrayOrArray(
|
|
2084
|
-
styles ? styles.schema : [
|
|
2085
|
-
"#7ad6f4",
|
|
2086
|
-
"#45bdee",
|
|
2087
|
-
"#28a7ea",
|
|
2088
|
-
"#006cbb",
|
|
2089
|
-
"#034698",
|
|
2090
|
-
"#032f64"
|
|
2091
|
-
]
|
|
2092
|
-
),
|
|
2093
|
-
index,
|
|
2094
|
-
isSingle
|
|
2095
|
-
) : "";
|
|
2096
|
-
const returnColumnsArray = [];
|
|
2097
|
-
arrayOrArray(data.sets).forEach((set) => {
|
|
2098
|
-
if (set.color !== "" && set.color !== void 0) {
|
|
2099
|
-
returnColumnsArray.push(__spreadProps$8(__spreadValues$a({}, set), { columnName: data.name }));
|
|
2100
|
-
} else {
|
|
2101
|
-
returnColumnsArray.push(__spreadProps$8(__spreadValues$a({}, set), {
|
|
2102
|
-
color: dataColor,
|
|
2103
|
-
columnName: data.name
|
|
2104
|
-
}));
|
|
2105
|
-
}
|
|
2106
|
-
});
|
|
2107
|
-
return { returnColumnsArray, columnColor: dataColor };
|
|
2108
|
-
});
|
|
2109
|
-
const colorReference = arrayOrArray(chart.dataSets.data).map(
|
|
2110
|
-
(data, index) => {
|
|
2111
|
-
const isSingle = arrayOrArray(chart.dataSets.data).length === 1;
|
|
2112
|
-
const dataColor = data.color !== "" && data.color !== void 0 ? data.color : arrayOrArray(
|
|
2113
|
-
styles ? styles.schema : [
|
|
2114
|
-
"#7ad6f4",
|
|
2115
|
-
"#45bdee",
|
|
2116
|
-
"#28a7ea",
|
|
2117
|
-
"#006cbb",
|
|
2118
|
-
"#034698",
|
|
2119
|
-
"#032f64"
|
|
2120
|
-
]
|
|
2121
|
-
).length > 0 ? getBarColor(
|
|
2122
|
-
arrayOrArray(
|
|
2123
|
-
styles ? styles.schema : [
|
|
2124
|
-
"#7ad6f4",
|
|
2125
|
-
"#45bdee",
|
|
2126
|
-
"#28a7ea",
|
|
2127
|
-
"#006cbb",
|
|
2128
|
-
"#034698",
|
|
2129
|
-
"#032f64"
|
|
2130
|
-
]
|
|
2131
|
-
),
|
|
2132
|
-
index,
|
|
2133
|
-
isSingle
|
|
2134
|
-
) : "";
|
|
2135
|
-
return {
|
|
2136
|
-
color: dataColor,
|
|
2137
|
-
title: data.name
|
|
2138
|
-
};
|
|
2139
|
-
}
|
|
2140
|
-
);
|
|
2141
|
-
arrayOrArray(chart.dataSets.data).map((data) => {
|
|
2142
|
-
const returnArray = [];
|
|
2143
|
-
arrayOrArray(data.sets).forEach((set) => {
|
|
2144
|
-
if (set.color !== "" && set.color !== void 0) {
|
|
2145
|
-
returnArray.push({
|
|
2146
|
-
color: set.color,
|
|
2147
|
-
title: data.name + " - " + set.key
|
|
2148
|
-
});
|
|
2149
|
-
}
|
|
2150
|
-
});
|
|
2151
|
-
return returnArray;
|
|
2152
|
-
}).flat().forEach((addRef) => colorReference.push(addRef));
|
|
2153
|
-
const [highlightedBar, setHighlightedBar] = useState("");
|
|
2154
|
-
useImperativeComponentEvents({
|
|
2155
|
-
highlight(barName) {
|
|
2156
|
-
if (barName.split(" - ").length === 1) {
|
|
2157
|
-
setHighlightedBar(barName);
|
|
2158
|
-
} else if (barName.split(" - ").length === 2) {
|
|
2159
|
-
setHighlightedBar(barName.split(" - ")[0]);
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
});
|
|
2163
|
-
const { boxRef, elementRef } = usePanAndZoom(
|
|
2164
|
-
void 0,
|
|
2165
|
-
!allowZoom
|
|
2166
|
-
);
|
|
2167
|
-
const coords = coordinatesArray.flat().map((coord) => {
|
|
2168
|
-
return {
|
|
2169
|
-
xValue: coord.key,
|
|
2170
|
-
yValue: coord.value,
|
|
2171
|
-
x: xScale(getX(coord)),
|
|
2172
|
-
y: actualYScale(getY(coord))
|
|
2173
|
-
};
|
|
2174
|
-
});
|
|
2175
|
-
const columnNames = lines.map((column) => {
|
|
2176
|
-
return column.name;
|
|
2177
|
-
});
|
|
2178
|
-
const nodes = addNameToProps(columnNames, coords, coordinates.length);
|
|
2179
|
-
const [nearNodesArray, setNearNodesArray] = useState([]);
|
|
2180
|
-
const previousNearNodesArray = usePrevious(nearNodesArray);
|
|
2181
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2182
|
-
/* @__PURE__ */ jsx(Box, { id, ref: boxRef, className: "chartBox chartContainer", children: /* @__PURE__ */ jsxs(
|
|
2183
|
-
"svg",
|
|
2184
|
-
{
|
|
2185
|
-
ref: elementRef,
|
|
2186
|
-
width: innerWidth,
|
|
2187
|
-
height: innerHeight,
|
|
2188
|
-
id: "LinesChart",
|
|
2189
|
-
className: `_${chartId} chart__svg`,
|
|
2190
|
-
onMouseMove: (ev) => {
|
|
2191
|
-
var _a;
|
|
2192
|
-
const rect = (_a = elementRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
2193
|
-
let clientX = ev.clientX - (effectiveMargin.left + effectiveMargin.right) / 2;
|
|
2194
|
-
let clientY = ev.clientY - (effectiveMargin.top + effectiveMargin.bottom) / 2;
|
|
2195
|
-
if (rect) {
|
|
2196
|
-
clientX = ev.clientX - rect.left;
|
|
2197
|
-
clientY = ev.clientY - rect.top;
|
|
2198
|
-
}
|
|
2199
|
-
const nearNodes = nodes.filter((node) => {
|
|
2200
|
-
return Math.sqrt(__pow(node.x - clientX, 2) + __pow(node.y - clientY, 2)) < 20;
|
|
2201
|
-
});
|
|
2202
|
-
if (previousNearNodesArray.current && nearNodes.length > 0) {
|
|
2203
|
-
const currentColumns = lines.map((col) => {
|
|
2204
|
-
let colNames = "";
|
|
2205
|
-
nearNodes.forEach((node) => {
|
|
2206
|
-
if (col.name === node.columnName) {
|
|
2207
|
-
colNames = node.columnName;
|
|
2208
|
-
}
|
|
2209
|
-
});
|
|
2210
|
-
return colNames;
|
|
2211
|
-
}).filter((name) => name !== "");
|
|
2212
|
-
const currentIndex = coordinates.findIndex((coord) => {
|
|
2213
|
-
return coord.key === nearNodes[0].xValue;
|
|
2214
|
-
});
|
|
2215
|
-
if (currentColumns && currentIndex !== void 0) {
|
|
2216
|
-
const newCircleValues = currentColumns.map((col) => {
|
|
2217
|
-
return `${col}${currentIndex}`;
|
|
2218
|
-
});
|
|
2219
|
-
setCurrentCircle([...newCircleValues]);
|
|
2220
|
-
}
|
|
2221
|
-
setNearNodesArray(nearNodes);
|
|
2222
|
-
const elementUnderCursor = document.elementFromPoint(
|
|
2223
|
-
ev.clientX,
|
|
2224
|
-
ev.clientY
|
|
2225
|
-
);
|
|
2226
|
-
if (elementUnderCursor && elementUnderCursor.tagName === "circle") {
|
|
2227
|
-
new ApiaUtil().tooltips.open({
|
|
2228
|
-
children: nearNodes.sort((a, b) => Number(b.yValue) - Number(a.yValue)).map((node, i) => {
|
|
2229
|
-
const useSpecific = colorReference.some(
|
|
2230
|
-
(ref) => ref.title === node.columnName + " - " + node.xValue
|
|
2231
|
-
);
|
|
2232
|
-
return /* @__PURE__ */ jsxs(
|
|
2233
|
-
Box,
|
|
2234
|
-
{
|
|
2235
|
-
children: [
|
|
2236
|
-
/* @__PURE__ */ jsx(
|
|
2237
|
-
"div",
|
|
2238
|
-
{
|
|
2239
|
-
style: {
|
|
2240
|
-
color: colorReference[colorReference.findIndex((ref) => {
|
|
2241
|
-
return ref.title === (useSpecific ? node.columnName + " - " + node.xValue : node.columnName);
|
|
2242
|
-
})].color
|
|
2243
|
-
},
|
|
2244
|
-
children: /* @__PURE__ */ jsx("strong", { children: node.columnName })
|
|
2245
|
-
}
|
|
2246
|
-
),
|
|
2247
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: node.yValue }),
|
|
2248
|
-
/* @__PURE__ */ jsx("div", { children: node.xValue }),
|
|
2249
|
-
nearNodesArray[i + 1] && /* @__PURE__ */ jsx("hr", {})
|
|
2250
|
-
]
|
|
2251
|
-
},
|
|
2252
|
-
`${node.columnName}_${node.xValue}_${node.yValue}`
|
|
2253
|
-
);
|
|
2254
|
-
}),
|
|
2255
|
-
attachToElement: () => elementUnderCursor,
|
|
2256
|
-
attachToElementAnchorPoint: "bottomRight"
|
|
2257
|
-
});
|
|
2258
|
-
} else {
|
|
2259
|
-
new ApiaUtil().tooltips.closeAll();
|
|
2260
|
-
}
|
|
2261
|
-
} else if (nearNodes.length === 0) {
|
|
2262
|
-
setCurrentCircle([]);
|
|
2263
|
-
}
|
|
2264
|
-
},
|
|
2265
|
-
children: [
|
|
2266
|
-
chart.showGrid && /* @__PURE__ */ jsx(
|
|
2267
|
-
Grid.Grid,
|
|
2268
|
-
{
|
|
2269
|
-
top: (typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top) - 20,
|
|
2270
|
-
left: 0,
|
|
2271
|
-
xScale,
|
|
2272
|
-
yScale: actualYScale,
|
|
2273
|
-
width: innerWidth,
|
|
2274
|
-
height: innerHeight,
|
|
2275
|
-
stroke: styles == null ? void 0 : styles.grid.stroke,
|
|
2276
|
-
strokeOpacity: styles == null ? void 0 : styles.grid.opacity
|
|
2277
|
-
}
|
|
2278
|
-
),
|
|
2279
|
-
lines.map((column, i) => {
|
|
2280
|
-
var _a;
|
|
2281
|
-
const currentCoordinates = arrayOrArray(column.sets);
|
|
2282
|
-
const newColor = (_a = setsWithColor.find(
|
|
2283
|
-
(data) => data.returnColumnsArray[0].columnName === column.name
|
|
2284
|
-
)) == null ? void 0 : _a.columnColor;
|
|
2285
|
-
return /* @__PURE__ */ jsxs(
|
|
2286
|
-
Group,
|
|
2287
|
-
{
|
|
2288
|
-
top: (typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top) - 20,
|
|
2289
|
-
style: {
|
|
2290
|
-
opacity: highlightedBar !== "" && highlightedBar !== column.name ? 0.15 : 1,
|
|
2291
|
-
transition: "opacity 500ms"
|
|
2292
|
-
},
|
|
2293
|
-
children: [
|
|
2294
|
-
/* @__PURE__ */ jsx(
|
|
2295
|
-
LinePath,
|
|
2296
|
-
{
|
|
2297
|
-
curve: allCurves.curveMonotoneX,
|
|
2298
|
-
data: currentCoordinates,
|
|
2299
|
-
x: (coordinate) => {
|
|
2300
|
-
var _a2;
|
|
2301
|
-
return (_a2 = xScale(getX(coordinate))) != null ? _a2 : 0;
|
|
2302
|
-
},
|
|
2303
|
-
y: (coordinate) => {
|
|
2304
|
-
var _a2;
|
|
2305
|
-
return (_a2 = actualYScale(getY(coordinate))) != null ? _a2 : 0;
|
|
2306
|
-
},
|
|
2307
|
-
stroke: newColor != null ? newColor : "black",
|
|
2308
|
-
strokeWidth: 2,
|
|
2309
|
-
strokeOpacity: 1,
|
|
2310
|
-
shapeRendering: "geometricPrecision",
|
|
2311
|
-
color: "transparent"
|
|
2312
|
-
}
|
|
2313
|
-
),
|
|
2314
|
-
currentCoordinates.map((coordinate, j) => {
|
|
2315
|
-
var _a2;
|
|
2316
|
-
const key = column.name + j.toString();
|
|
2317
|
-
const realColor = (_a2 = setsWithColor.map((sets) => sets.returnColumnsArray).flat().find(
|
|
2318
|
-
(set) => set.columnName === column.name && set.key === coordinate.key
|
|
2319
|
-
)) == null ? void 0 : _a2.color;
|
|
2320
|
-
return /* @__PURE__ */ jsxs("g", { children: [
|
|
2321
|
-
chart.showValues && /* @__PURE__ */ jsx(
|
|
2322
|
-
"text",
|
|
2323
|
-
{
|
|
2324
|
-
x: xScale(getX(coordinate)) + 10,
|
|
2325
|
-
y: actualYScale(getY(coordinate)) - 5,
|
|
2326
|
-
textAnchor: "middle",
|
|
2327
|
-
style: {
|
|
2328
|
-
display: highlightedBar === column.name ? "block" : "none",
|
|
2329
|
-
opacity: highlightedBar === column.name ? 1 : 0,
|
|
2330
|
-
transition: "opacity 500ms"
|
|
2331
|
-
},
|
|
2332
|
-
children: coordinate.value
|
|
2333
|
-
}
|
|
2334
|
-
),
|
|
2335
|
-
/* @__PURE__ */ jsx(
|
|
2336
|
-
Node,
|
|
2337
|
-
{
|
|
2338
|
-
color: realColor != null ? realColor : "black",
|
|
2339
|
-
coordinate,
|
|
2340
|
-
currentCircle,
|
|
2341
|
-
cx: xScale(getX(coordinate)),
|
|
2342
|
-
cy: actualYScale(getY(coordinate)),
|
|
2343
|
-
setCurrentCircle,
|
|
2344
|
-
innerKey: key,
|
|
2345
|
-
column
|
|
2346
|
-
}
|
|
2347
|
-
)
|
|
2348
|
-
] }, key);
|
|
2349
|
-
})
|
|
2350
|
-
]
|
|
2351
|
-
},
|
|
2352
|
-
`lines-${column.name + i.toString()}`
|
|
2353
|
-
);
|
|
2354
|
-
}),
|
|
2355
|
-
/* @__PURE__ */ jsx(
|
|
2356
|
-
AxisLeft,
|
|
2357
|
-
{
|
|
2358
|
-
scale: actualYScale,
|
|
2359
|
-
left: effectiveMargin.left,
|
|
2360
|
-
label: chart.chartType !== "pie2D" && chart.showAxisYTitle ? chart.axisYTitle : "",
|
|
2361
|
-
tickLabelProps: {
|
|
2362
|
-
display: chart.showAxisYTitle ? "auto" : "none"
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
),
|
|
2366
|
-
/* @__PURE__ */ jsx(
|
|
2367
|
-
AxisBottom,
|
|
2368
|
-
{
|
|
2369
|
-
top: innerHeight - (effectiveMargin.top + effectiveMargin.bottom),
|
|
2370
|
-
scale: xScale,
|
|
2371
|
-
label: chart.chartType !== "pie2D" && chart.showAxisXTitle ? chart.axisXTitle : "",
|
|
2372
|
-
tickLabelProps: { display: "none" },
|
|
2373
|
-
tickLineProps: { display: "none" },
|
|
2374
|
-
labelOffset: 10
|
|
2375
|
-
}
|
|
2376
|
-
)
|
|
2377
|
-
]
|
|
2378
|
-
}
|
|
2379
|
-
) }),
|
|
2380
|
-
/* @__PURE__ */ jsx(Box, { className: "chartLegend__Wrapper", children: chart.showLegend && colorReference.length !== 0 && /* @__PURE__ */ jsxs(Box, { className: "chart__legend__wrapper", children: [
|
|
2381
|
-
/* @__PURE__ */ jsx(Heading, { as: "h6", children: getLabel("mnuLeyends").text }),
|
|
2382
|
-
/* @__PURE__ */ jsx(LegendContainer, { id: chartId, references: colorReference })
|
|
2383
|
-
] }) })
|
|
2384
|
-
] });
|
|
2385
|
-
};
|
|
2386
|
-
|
|
2387
|
-
const WaterfallBar = ({
|
|
2388
|
-
width,
|
|
2389
|
-
height,
|
|
2390
|
-
x,
|
|
2391
|
-
y,
|
|
2392
|
-
fill,
|
|
2393
|
-
x1,
|
|
2394
|
-
lineY,
|
|
2395
|
-
x2,
|
|
2396
|
-
stroke,
|
|
2397
|
-
strokeDashArray,
|
|
2398
|
-
textX,
|
|
2399
|
-
textY,
|
|
2400
|
-
textContent,
|
|
2401
|
-
isLast,
|
|
2402
|
-
step,
|
|
2403
|
-
columnName,
|
|
2404
|
-
chart
|
|
2405
|
-
}) => {
|
|
2406
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2407
|
-
/* @__PURE__ */ jsx(
|
|
2408
|
-
Box,
|
|
2409
|
-
{
|
|
2410
|
-
as: "rect",
|
|
2411
|
-
sx: useMemo(() => {
|
|
2412
|
-
return {
|
|
2413
|
-
width: `${width}px`,
|
|
2414
|
-
height: `${height}px`,
|
|
2415
|
-
x: `${x}px`,
|
|
2416
|
-
y: `${y}px`,
|
|
2417
|
-
fill: `${fill}`,
|
|
2418
|
-
"&:hover": {
|
|
2419
|
-
fill: `#${tinycolor(fill).saturate(25).toHex()}`
|
|
2420
|
-
},
|
|
2421
|
-
transition: "fill 500ms"
|
|
2422
|
-
};
|
|
2423
|
-
}, [fill, height, width, x, y]),
|
|
2424
|
-
onMouseEnter: (ev) => {
|
|
2425
|
-
new ApiaUtil().tooltips.open({
|
|
2426
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2427
|
-
/* @__PURE__ */ jsx(
|
|
2428
|
-
"div",
|
|
2429
|
-
{
|
|
2430
|
-
style: {
|
|
2431
|
-
color: step.color
|
|
2432
|
-
},
|
|
2433
|
-
children: /* @__PURE__ */ jsx("strong", { children: columnName })
|
|
2434
|
-
}
|
|
2435
|
-
),
|
|
2436
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: step.y }),
|
|
2437
|
-
/* @__PURE__ */ jsx("div", { children: step.x })
|
|
2438
|
-
] }),
|
|
2439
|
-
attachToElement: () => ev.target,
|
|
2440
|
-
attachToElementAnchorPoint: "center"
|
|
2441
|
-
});
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
),
|
|
2445
|
-
!isLast && /* @__PURE__ */ jsx(
|
|
2446
|
-
Line,
|
|
2447
|
-
{
|
|
2448
|
-
x1,
|
|
2449
|
-
x2,
|
|
2450
|
-
y1: lineY,
|
|
2451
|
-
y2: lineY,
|
|
2452
|
-
stroke,
|
|
2453
|
-
strokeDasharray: strokeDashArray
|
|
2454
|
-
}
|
|
2455
|
-
),
|
|
2456
|
-
chart.showValues && /* @__PURE__ */ jsx("text", { textAnchor: "middle", x: textX, y: textY, children: textContent })
|
|
2457
|
-
] });
|
|
2458
|
-
};
|
|
2459
|
-
|
|
2460
|
-
var __defProp$9 = Object.defineProperty;
|
|
2461
|
-
var __defProps$7 = Object.defineProperties;
|
|
2462
|
-
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
2463
|
-
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
2464
|
-
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
2465
|
-
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
2466
|
-
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2467
|
-
var __spreadValues$9 = (a, b) => {
|
|
2468
|
-
for (var prop in b || (b = {}))
|
|
2469
|
-
if (__hasOwnProp$9.call(b, prop))
|
|
2470
|
-
__defNormalProp$9(a, prop, b[prop]);
|
|
2471
|
-
if (__getOwnPropSymbols$9)
|
|
2472
|
-
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
2473
|
-
if (__propIsEnum$9.call(b, prop))
|
|
2474
|
-
__defNormalProp$9(a, prop, b[prop]);
|
|
2475
|
-
}
|
|
2476
|
-
return a;
|
|
2477
|
-
};
|
|
2478
|
-
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
2479
|
-
var __objRest = (source, exclude) => {
|
|
2480
|
-
var target = {};
|
|
2481
|
-
for (var prop in source)
|
|
2482
|
-
if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2483
|
-
target[prop] = source[prop];
|
|
2484
|
-
if (source != null && __getOwnPropSymbols$9)
|
|
2485
|
-
for (var prop of __getOwnPropSymbols$9(source)) {
|
|
2486
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
|
|
2487
|
-
target[prop] = source[prop];
|
|
2488
|
-
}
|
|
2489
|
-
return target;
|
|
2490
|
-
};
|
|
2491
|
-
const calculateWaterfallSteps = ({
|
|
2492
|
-
data,
|
|
2493
|
-
xAccessor,
|
|
2494
|
-
yAccessor,
|
|
2495
|
-
showFinal,
|
|
2496
|
-
colors
|
|
2497
|
-
}) => {
|
|
2498
|
-
let cumulativeTotal = 0;
|
|
2499
|
-
const steps = data.map((datum) => {
|
|
2500
|
-
const xValue = xAccessor(datum);
|
|
2501
|
-
const yValue = yAccessor(datum);
|
|
2502
|
-
const prevTotal = cumulativeTotal;
|
|
2503
|
-
cumulativeTotal += Number(yValue);
|
|
2504
|
-
return {
|
|
2505
|
-
x: xValue,
|
|
2506
|
-
y: yValue,
|
|
2507
|
-
start: prevTotal,
|
|
2508
|
-
end: cumulativeTotal,
|
|
2509
|
-
color: Number(yValue) > 0 ? colors.positive : colors.negative
|
|
2510
|
-
};
|
|
2511
|
-
});
|
|
2512
|
-
if (showFinal) {
|
|
2513
|
-
steps.push({
|
|
2514
|
-
x: "Total",
|
|
2515
|
-
y: cumulativeTotal,
|
|
2516
|
-
start: 0,
|
|
2517
|
-
end: cumulativeTotal,
|
|
2518
|
-
color: colors.total
|
|
2519
|
-
});
|
|
2520
|
-
}
|
|
2521
|
-
return steps;
|
|
2522
|
-
};
|
|
2523
|
-
function adjustDimensions({
|
|
2524
|
-
width,
|
|
2525
|
-
height,
|
|
2526
|
-
maxWidth
|
|
2527
|
-
}) {
|
|
2528
|
-
if (width <= maxWidth) {
|
|
2529
|
-
return { width, height };
|
|
2530
|
-
}
|
|
2531
|
-
const ratio = width / height;
|
|
2532
|
-
const newWidth = maxWidth;
|
|
2533
|
-
const newHeight = Math.floor(newWidth / ratio);
|
|
2534
|
-
return { width: newWidth, height: newHeight };
|
|
2535
|
-
}
|
|
2536
|
-
const WaterfallBars = (_a) => {
|
|
2537
|
-
var _b = _a, {
|
|
2538
|
-
margin = { top: 20, left: 100, bottom: 150, right: 70 },
|
|
2539
|
-
chart: _c
|
|
2540
|
-
} = _b, _d = _c, {
|
|
2541
|
-
waterfallColors = {
|
|
2542
|
-
positive: "#49b86f",
|
|
2543
|
-
negative: "#c92e5b",
|
|
2544
|
-
total: "#434857",
|
|
2545
|
-
stepConnector: "#888d94"
|
|
2546
|
-
}
|
|
2547
|
-
} = _d, chart = __objRest(_d, [
|
|
2548
|
-
"waterfallColors"
|
|
2549
|
-
]), {
|
|
2550
|
-
className,
|
|
2551
|
-
chartId,
|
|
2552
|
-
allowZoom
|
|
2553
|
-
} = _b;
|
|
2554
|
-
var _a2;
|
|
2555
|
-
console.log({ margin });
|
|
2556
|
-
const effectiveMargin = parseMargin(margin);
|
|
2557
|
-
if (!chart.showAxisYTitle && effectiveMargin.left > 50) {
|
|
2558
|
-
effectiveMargin.left = 50;
|
|
2559
|
-
}
|
|
2560
|
-
let innerWidth = chart.ratio.width + (-effectiveMargin.left - effectiveMargin.right) / 2;
|
|
2561
|
-
let innerHeight = chart.ratio.height + (-effectiveMargin.top - effectiveMargin.bottom) / 2;
|
|
2562
|
-
if (innerWidth > chart.ratio.maxWidth) {
|
|
2563
|
-
const newValues = adjustDimensions({
|
|
2564
|
-
height: innerHeight,
|
|
2565
|
-
width: innerWidth,
|
|
2566
|
-
maxWidth: chart.ratio.maxWidth
|
|
2567
|
-
});
|
|
2568
|
-
innerWidth = newValues.width;
|
|
2569
|
-
innerHeight = newValues.height;
|
|
2570
|
-
}
|
|
2571
|
-
const getXValue = (d) => d.key;
|
|
2572
|
-
const getYValue = (d) => d.value;
|
|
2573
|
-
const charts = arrayOrArray((_a2 = chart.dataSets) == null ? void 0 : _a2.data).filter((piece) => !!piece.sets).map((piece) => {
|
|
2574
|
-
return __spreadProps$7(__spreadValues$9({}, piece), {
|
|
2575
|
-
coordinate: piece.sets
|
|
2576
|
-
});
|
|
2577
|
-
});
|
|
2578
|
-
const [currentPie, setCurrentPie] = useState("0");
|
|
2579
|
-
const chartNames = charts.map((piece) => {
|
|
2580
|
-
return piece.name;
|
|
2581
|
-
});
|
|
2582
|
-
const steps = useMemo(
|
|
2583
|
-
() => {
|
|
2584
|
-
var _a3;
|
|
2585
|
-
return calculateWaterfallSteps({
|
|
2586
|
-
data: arrayOrArray(chart.dataSets.data)[currentPie].sets,
|
|
2587
|
-
xAccessor: getXValue,
|
|
2588
|
-
yAccessor: getYValue,
|
|
2589
|
-
showFinal: (_a3 = chart.showTotal) != null ? _a3 : true,
|
|
2590
|
-
colors: waterfallColors
|
|
2591
|
-
});
|
|
2592
|
-
},
|
|
2593
|
-
[chart.dataSets.data, chart.showTotal, currentPie, waterfallColors]
|
|
2594
|
-
);
|
|
2595
|
-
const padding = 0.2;
|
|
2596
|
-
const xScale = scaleBand({
|
|
2597
|
-
domain: steps.map((step) => step.x),
|
|
2598
|
-
padding,
|
|
2599
|
-
range: [0, innerWidth]
|
|
2600
|
-
});
|
|
2601
|
-
const yDomain = useMemo(() => {
|
|
2602
|
-
const values = steps.flatMap((step) => [step.start, step.end]);
|
|
2603
|
-
const [min, max] = extent(values);
|
|
2604
|
-
return min != null && max != null ? [min - 5, max + 5] : void 0;
|
|
2605
|
-
}, [steps]);
|
|
2606
|
-
const yScale = scaleLinear({
|
|
2607
|
-
domain: yDomain,
|
|
2608
|
-
nice: true,
|
|
2609
|
-
range: [innerHeight, 0]
|
|
2610
|
-
});
|
|
2611
|
-
const id = useMemo(() => `WaterfallBars${uniqueId()}`, []);
|
|
2612
|
-
useLayoutEffect(() => {
|
|
2613
|
-
document.querySelectorAll(`#${id} .tickLabel`).forEach((current) => {
|
|
2614
|
-
const width = current.getBoundingClientRect().width;
|
|
2615
|
-
current.style.transformOrigin = current.getAttribute("x") + "px 14px";
|
|
2616
|
-
current.style.transform = `rotate(25deg) translateX(${width / 2}px)`;
|
|
2617
|
-
});
|
|
2618
|
-
});
|
|
2619
|
-
const { boxRef, elementRef } = usePanAndZoom(
|
|
2620
|
-
void 0,
|
|
2621
|
-
!allowZoom
|
|
2622
|
-
);
|
|
2623
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2624
|
-
/* @__PURE__ */ jsx(
|
|
2625
|
-
Box,
|
|
2626
|
-
{
|
|
2627
|
-
id,
|
|
2628
|
-
className: `${className ? className : ""} chartBox chartContainer`,
|
|
2629
|
-
ref: boxRef,
|
|
2630
|
-
children: /* @__PURE__ */ jsx(
|
|
2631
|
-
"svg",
|
|
2632
|
-
{
|
|
2633
|
-
height: chart.ratio.height,
|
|
2634
|
-
width: chart.ratio.width,
|
|
2635
|
-
ref: elementRef,
|
|
2636
|
-
children: /* @__PURE__ */ jsxs(Group, { left: effectiveMargin.left, top: effectiveMargin.top, children: [
|
|
2637
|
-
/* @__PURE__ */ jsx(GridRows, { scale: yScale, width: innerWidth, strokeDasharray: "5" }),
|
|
2638
|
-
steps.map((step, index) => {
|
|
2639
|
-
var _a3;
|
|
2640
|
-
const x = xScale(step.x);
|
|
2641
|
-
const y = yScale(Math.max(step.start, step.end));
|
|
2642
|
-
if (x == null || y == null) {
|
|
2643
|
-
return null;
|
|
2644
|
-
}
|
|
2645
|
-
const barHeight = Math.abs(yScale(step.start) - yScale(step.end));
|
|
2646
|
-
const isLast = index === steps.length - 1;
|
|
2647
|
-
const linePadding = 2;
|
|
2648
|
-
const x1 = x + xScale.bandwidth() + linePadding;
|
|
2649
|
-
const x2 = x + xScale.bandwidth() / (1 - padding) - linePadding;
|
|
2650
|
-
const lineY = step.end < step.start ? y + barHeight : y;
|
|
2651
|
-
const labelOffset = 10;
|
|
2652
|
-
const labelY = yScale(step.end) + (step.y < 0 ? labelOffset : -labelOffset);
|
|
2653
|
-
let currentYValue = 0;
|
|
2654
|
-
steps.filter((_, i) => {
|
|
2655
|
-
var _a4;
|
|
2656
|
-
if (((_a4 = chart.showTotal) != null ? _a4 : true) && !steps[i + 1]) {
|
|
2657
|
-
return false;
|
|
2658
|
-
}
|
|
2659
|
-
return i <= index;
|
|
2660
|
-
}).forEach((step2) => {
|
|
2661
|
-
currentYValue += Number(step2.y);
|
|
2662
|
-
});
|
|
2663
|
-
return /* @__PURE__ */ jsx(
|
|
2664
|
-
WaterfallBar,
|
|
2665
|
-
{
|
|
2666
|
-
chart,
|
|
2667
|
-
columnName: chartNames[currentPie],
|
|
2668
|
-
fill: step.color,
|
|
2669
|
-
height: barHeight,
|
|
2670
|
-
isLast,
|
|
2671
|
-
lineY,
|
|
2672
|
-
step,
|
|
2673
|
-
stroke: waterfallColors.stepConnector,
|
|
2674
|
-
strokeDashArray: 2,
|
|
2675
|
-
textContent: ((_a3 = chart.showTotal) != null ? _a3 : true) ? step.y : currentYValue,
|
|
2676
|
-
textX: x + xScale.bandwidth() / 2,
|
|
2677
|
-
textY: labelY + 5,
|
|
2678
|
-
width: xScale.bandwidth(),
|
|
2679
|
-
x,
|
|
2680
|
-
y,
|
|
2681
|
-
x1,
|
|
2682
|
-
x2
|
|
2683
|
-
},
|
|
2684
|
-
index
|
|
2685
|
-
);
|
|
2686
|
-
}),
|
|
2687
|
-
/* @__PURE__ */ jsx(
|
|
2688
|
-
AxisLeft,
|
|
2689
|
-
{
|
|
2690
|
-
label: "",
|
|
2691
|
-
scale: yScale,
|
|
2692
|
-
hideTicks: true,
|
|
2693
|
-
tickLabelProps: () => ({
|
|
2694
|
-
textAnchor: "end",
|
|
2695
|
-
verticalAnchor: "middle",
|
|
2696
|
-
display: chart.showAxisYTitle ? "auto" : "none"
|
|
2697
|
-
})
|
|
2698
|
-
}
|
|
2699
|
-
),
|
|
2700
|
-
/* @__PURE__ */ jsx(
|
|
2701
|
-
AxisBottom,
|
|
2702
|
-
{
|
|
2703
|
-
scale: xScale,
|
|
2704
|
-
top: innerHeight,
|
|
2705
|
-
tickLabelProps: { display: "none" },
|
|
2706
|
-
tickLineProps: { display: "none" }
|
|
2707
|
-
}
|
|
2708
|
-
)
|
|
2709
|
-
] })
|
|
2710
|
-
}
|
|
2711
|
-
)
|
|
2712
|
-
}
|
|
2713
|
-
),
|
|
2714
|
-
/* @__PURE__ */ jsx(Box, { className: "chartLegend__Wrapper", children: !chart.hideSelector && charts.length > 1 && /* @__PURE__ */ jsxs(Box, { className: "chart__combo__wrapper", children: [
|
|
2715
|
-
/* @__PURE__ */ jsx(Heading, { as: "h6", children: getLabel("lblChartSel").text }),
|
|
2716
|
-
/* @__PURE__ */ jsx(
|
|
2717
|
-
ChartSelector,
|
|
2718
|
-
{
|
|
2719
|
-
chartId,
|
|
2720
|
-
pieces: chartNames,
|
|
2721
|
-
className: "chartSelectorCombo",
|
|
2722
|
-
current: currentPie,
|
|
2723
|
-
setCurrent: setCurrentPie
|
|
2724
|
-
}
|
|
2725
|
-
)
|
|
2726
|
-
] }) })
|
|
2727
|
-
] });
|
|
2728
|
-
};
|
|
2729
|
-
|
|
2730
|
-
var __defProp$8 = Object.defineProperty;
|
|
2731
|
-
var __defProps$6 = Object.defineProperties;
|
|
2732
|
-
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
2733
|
-
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
2734
|
-
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
2735
|
-
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
2736
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2737
|
-
var __spreadValues$8 = (a, b) => {
|
|
2738
|
-
for (var prop in b || (b = {}))
|
|
2739
|
-
if (__hasOwnProp$8.call(b, prop))
|
|
2740
|
-
__defNormalProp$8(a, prop, b[prop]);
|
|
2741
|
-
if (__getOwnPropSymbols$8)
|
|
2742
|
-
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
2743
|
-
if (__propIsEnum$8.call(b, prop))
|
|
2744
|
-
__defNormalProp$8(a, prop, b[prop]);
|
|
2745
|
-
}
|
|
2746
|
-
return a;
|
|
2747
|
-
};
|
|
2748
|
-
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
2749
|
-
const frontColor = "hsl(196, 37%, 13%)";
|
|
2750
|
-
function useMultipleRefs(...refs) {
|
|
2751
|
-
return React.useCallback(
|
|
2752
|
-
function setRef(element) {
|
|
2753
|
-
refs.forEach((current) => {
|
|
2754
|
-
if (current)
|
|
2755
|
-
current.current = element;
|
|
2756
|
-
});
|
|
2757
|
-
},
|
|
2758
|
-
[refs]
|
|
2759
|
-
);
|
|
2760
|
-
}
|
|
2761
|
-
const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
|
|
2762
|
-
Component: makeStyledComponent(
|
|
2763
|
-
"ChartRenderer",
|
|
2764
|
-
"layout.charts",
|
|
2765
|
-
{
|
|
2766
|
-
red: {
|
|
2767
|
-
schema: "schemas.red"
|
|
2768
|
-
},
|
|
2769
|
-
orange: {
|
|
2770
|
-
schema: "schemas.orange"
|
|
2771
|
-
},
|
|
2772
|
-
green: {
|
|
2773
|
-
schema: "schemas.green"
|
|
2774
|
-
},
|
|
2775
|
-
blue: {
|
|
2776
|
-
schema: "schemas.blue"
|
|
2777
|
-
},
|
|
2778
|
-
violet: {
|
|
2779
|
-
schema: "schemas.violet"
|
|
2780
|
-
},
|
|
2781
|
-
turquoise: {
|
|
2782
|
-
schema: "schemas.turquoise"
|
|
2783
|
-
},
|
|
2784
|
-
yellow: {
|
|
2785
|
-
schema: "schemas.yellow"
|
|
2786
|
-
},
|
|
2787
|
-
grey: {
|
|
2788
|
-
schema: "schemas.grey"
|
|
2789
|
-
},
|
|
2790
|
-
ocean: {
|
|
2791
|
-
schema: "schemas.ocean"
|
|
2792
|
-
},
|
|
2793
|
-
sunset: {
|
|
2794
|
-
schema: "schemas.sunset"
|
|
2795
|
-
},
|
|
2796
|
-
common: {
|
|
2797
|
-
axis: {
|
|
2798
|
-
stroke: frontColor,
|
|
2799
|
-
title: frontColor
|
|
2800
|
-
},
|
|
2801
|
-
schema: frontColor,
|
|
2802
|
-
background: "hsl(200deg 20% 98%)",
|
|
2803
|
-
grid: {
|
|
2804
|
-
stroke: frontColor,
|
|
2805
|
-
opacity: "0.1"
|
|
2806
|
-
},
|
|
2807
|
-
toolTip: {
|
|
2808
|
-
backgroundColor: "rgb(232, 241, 255)",
|
|
2809
|
-
border: "1px solid #07c",
|
|
2810
|
-
color: frontColor,
|
|
2811
|
-
padding: ".3rem .5rem",
|
|
2812
|
-
borderRadius: "3px",
|
|
2813
|
-
fontSize: "18px",
|
|
2814
|
-
boxShadow: "0 1px 2px rgba(33,33,33,0.2)",
|
|
2815
|
-
lineHeight: "1em"
|
|
2816
|
-
}
|
|
2817
|
-
},
|
|
2818
|
-
".chartBox": () => {
|
|
2819
|
-
return {
|
|
2820
|
-
position: responsive({ 0: "static", 3: "sticky" }),
|
|
2821
|
-
top: "0",
|
|
2822
|
-
background: "white",
|
|
2823
|
-
zIndex: "1"
|
|
2824
|
-
};
|
|
2825
|
-
},
|
|
2826
|
-
".legendContainer": {
|
|
2827
|
-
display: "flex",
|
|
2828
|
-
flexDirection: "column",
|
|
2829
|
-
gap: spacing(2),
|
|
2830
|
-
overflow: "hidden",
|
|
2831
|
-
alignItems: "start",
|
|
2832
|
-
button: () => ({
|
|
2833
|
-
justifyContent: "start",
|
|
2834
|
-
textAlign: "start",
|
|
2835
|
-
width: "100%",
|
|
2836
|
-
textDecoration: "none",
|
|
2837
|
-
svg: {
|
|
2838
|
-
paddingLeft: spacing(1)
|
|
2839
|
-
}
|
|
2840
|
-
})
|
|
2841
|
-
},
|
|
2842
|
-
".legendItem": {
|
|
2843
|
-
transition: "opacity 200ms",
|
|
2844
|
-
"&.isBlurred": {
|
|
2845
|
-
opacity: "0.15"
|
|
2846
|
-
},
|
|
2847
|
-
".button__content": {
|
|
2848
|
-
overflow: "hidden",
|
|
2849
|
-
textOverflow: "ellipsis",
|
|
2850
|
-
wordWrap: "normal",
|
|
2851
|
-
display: "block",
|
|
2852
|
-
whiteSpace: "nowrap",
|
|
2853
|
-
p: spacing(1)
|
|
2854
|
-
}
|
|
2855
|
-
}
|
|
2856
|
-
},
|
|
2857
|
-
// eslint-disable-next-line react/display-name
|
|
2858
|
-
React.forwardRef(
|
|
2859
|
-
({
|
|
2860
|
-
currentChart,
|
|
2861
|
-
chartId,
|
|
2862
|
-
allowZoom,
|
|
2863
|
-
id
|
|
2864
|
-
}, ref) => {
|
|
2865
|
-
const innerRef = React.useRef(null);
|
|
2866
|
-
const setRefs = useMultipleRefs(
|
|
2867
|
-
ref,
|
|
2868
|
-
innerRef
|
|
2869
|
-
);
|
|
2870
|
-
const { id: imperativeId } = useImperativeComponentContext();
|
|
2871
|
-
const contextValue = useMemo(
|
|
2872
|
-
() => ({ chartId: String(imperativeId) }),
|
|
2873
|
-
[imperativeId]
|
|
2874
|
-
);
|
|
2875
|
-
const CurrentChart = getIndex(
|
|
2876
|
-
[PieChart, HorizontalBars, VerticalBars, LineChart, WaterfallBars],
|
|
2877
|
-
[
|
|
2878
|
-
currentChart.chartType === "pie2D",
|
|
2879
|
-
currentChart.chartType === "barH2D",
|
|
2880
|
-
currentChart.chartType === "barV2D",
|
|
2881
|
-
currentChart.chartType === "linear",
|
|
2882
|
-
currentChart.chartType === "waterfall"
|
|
2883
|
-
],
|
|
2884
|
-
0
|
|
2885
|
-
);
|
|
2886
|
-
return /* @__PURE__ */ jsx(ChartContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
2887
|
-
Box,
|
|
2888
|
-
__spreadProps$6(__spreadValues$8({
|
|
2889
|
-
ref: setRefs,
|
|
2890
|
-
className: "chart__chartRenderer"
|
|
2891
|
-
}, getVariant("layout.charts")), {
|
|
2892
|
-
id,
|
|
2893
|
-
children: /* @__PURE__ */ jsx(
|
|
2894
|
-
CurrentChart,
|
|
2895
|
-
{
|
|
2896
|
-
chart: currentChart,
|
|
2897
|
-
chartId,
|
|
2898
|
-
parentRef: innerRef,
|
|
2899
|
-
allowZoom,
|
|
2900
|
-
margin: currentChart.margin
|
|
2901
|
-
}
|
|
2902
|
-
)
|
|
2903
|
-
})
|
|
2904
|
-
) });
|
|
2905
|
-
}
|
|
2906
|
-
),
|
|
2907
|
-
true
|
|
2908
|
-
)
|
|
2909
|
-
});
|
|
2910
|
-
|
|
2911
|
-
const EmptyGrid = ({ width }) => {
|
|
2912
|
-
const xScale = scaleBand({
|
|
2913
|
-
range: [0, width != null ? width : 400],
|
|
2914
|
-
domain: ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"],
|
|
2915
|
-
padding: 0.2
|
|
2916
|
-
});
|
|
2917
|
-
const yScale = scaleBand({
|
|
2918
|
-
range: [0, 400],
|
|
2919
|
-
domain: ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"],
|
|
2920
|
-
padding: 0.2
|
|
2921
|
-
});
|
|
2922
|
-
return /* @__PURE__ */ jsxs("svg", { height: 400, width: width != null ? width : 400, children: [
|
|
2923
|
-
/* @__PURE__ */ jsx(
|
|
2924
|
-
Grid.Grid,
|
|
2925
|
-
{
|
|
2926
|
-
height: 400,
|
|
2927
|
-
width: width != null ? width : 400,
|
|
2928
|
-
numTicksRows: 10,
|
|
2929
|
-
numTicksColumns: 10,
|
|
2930
|
-
xScale,
|
|
2931
|
-
yScale
|
|
2932
|
-
}
|
|
2933
|
-
),
|
|
2934
|
-
/* @__PURE__ */ jsx(
|
|
2935
|
-
AxisLeft,
|
|
2936
|
-
{
|
|
2937
|
-
scale: yScale,
|
|
2938
|
-
left: 20,
|
|
2939
|
-
hideTicks: true,
|
|
2940
|
-
tickLabelProps: { display: "none" }
|
|
2941
|
-
}
|
|
2942
|
-
),
|
|
2943
|
-
/* @__PURE__ */ jsx(
|
|
2944
|
-
AxisBottom,
|
|
2945
|
-
{
|
|
2946
|
-
scale: xScale,
|
|
2947
|
-
top: 380,
|
|
2948
|
-
hideTicks: true,
|
|
2949
|
-
tickLabelProps: { display: "none" }
|
|
2950
|
-
}
|
|
2951
|
-
)
|
|
2952
|
-
] });
|
|
2953
|
-
};
|
|
2954
|
-
|
|
2955
|
-
var __defProp$7 = Object.defineProperty;
|
|
2956
|
-
var __defProps$5 = Object.defineProperties;
|
|
2957
|
-
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
2958
|
-
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
2959
|
-
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
2960
|
-
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
2961
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2962
|
-
var __spreadValues$7 = (a, b) => {
|
|
2963
|
-
for (var prop in b || (b = {}))
|
|
2964
|
-
if (__hasOwnProp$7.call(b, prop))
|
|
2965
|
-
__defNormalProp$7(a, prop, b[prop]);
|
|
2966
|
-
if (__getOwnPropSymbols$7)
|
|
2967
|
-
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
2968
|
-
if (__propIsEnum$7.call(b, prop))
|
|
2969
|
-
__defNormalProp$7(a, prop, b[prop]);
|
|
2970
|
-
}
|
|
2971
|
-
return a;
|
|
2972
|
-
};
|
|
2973
|
-
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
2974
|
-
const START_ANGLE$5 = 90;
|
|
2975
|
-
const END_ANGLE$5 = 270;
|
|
2976
|
-
const Scale = ({
|
|
2977
|
-
currentValue,
|
|
2978
|
-
currentValueFontSize,
|
|
2979
|
-
height,
|
|
2980
|
-
maxValue,
|
|
2981
|
-
minValue,
|
|
2982
|
-
pointerColor,
|
|
2983
|
-
scaleValuesSize,
|
|
2984
|
-
valueRanges,
|
|
2985
|
-
width
|
|
2986
|
-
}) => {
|
|
2987
|
-
var _a, _b;
|
|
2988
|
-
const allTicks = false;
|
|
2989
|
-
const value = currentValue;
|
|
2990
|
-
const diameter = Math.min(height, width);
|
|
2991
|
-
const domainMax = (_a = noNaN(maxValue)) != null ? _a : valueRanges[valueRanges.length - 1];
|
|
2992
|
-
const domainMin = (_b = noNaN(minValue)) != null ? _b : valueRanges[0];
|
|
2993
|
-
const offset = 20;
|
|
2994
|
-
const gauge = useGauge({
|
|
2995
|
-
domain: [domainMin, domainMax],
|
|
2996
|
-
startAngle: START_ANGLE$5,
|
|
2997
|
-
endAngle: END_ANGLE$5,
|
|
2998
|
-
numTicks: 10 + 1,
|
|
2999
|
-
diameter
|
|
3000
|
-
});
|
|
3001
|
-
useGauge({
|
|
3002
|
-
domain: [valueRanges[0], valueRanges[valueRanges.length - 1]],
|
|
3003
|
-
startAngle: START_ANGLE$5,
|
|
3004
|
-
endAngle: END_ANGLE$5,
|
|
3005
|
-
numTicks: valueRanges[valueRanges.length - 1] - valueRanges[0] + 1,
|
|
3006
|
-
diameter
|
|
3007
|
-
});
|
|
3008
|
-
const needle = gauge.getNeedleProps({
|
|
3009
|
-
value: 0,
|
|
3010
|
-
baseRadius: 12,
|
|
3011
|
-
tipRadius: 2
|
|
3012
|
-
});
|
|
3013
|
-
const angle = (END_ANGLE$5 - START_ANGLE$5) * value / (domainMax - domainMin);
|
|
3014
|
-
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
|
|
3015
|
-
"svg",
|
|
3016
|
-
__spreadProps$5(__spreadValues$7({}, gauge.getSVGProps()), {
|
|
3017
|
-
height: Math.max(width, height),
|
|
3018
|
-
width: Math.max(width, height),
|
|
3019
|
-
viewBox: `-${diameter / 2 + offset} -${diameter / 2 + offset} ${diameter + offset * 2} ${diameter / 2 + offset * 2}`,
|
|
3020
|
-
children: [
|
|
3021
|
-
/* @__PURE__ */ jsx("g", { id: "arcs", children: /* @__PURE__ */ jsx(
|
|
3022
|
-
"path",
|
|
3023
|
-
__spreadProps$5(__spreadValues$7({}, gauge.getArcProps({
|
|
3024
|
-
offset: offset - 5,
|
|
3025
|
-
startAngle: 90,
|
|
3026
|
-
endAngle: 270
|
|
3027
|
-
})), {
|
|
3028
|
-
stroke: "gray",
|
|
3029
|
-
opacity: "0.2",
|
|
3030
|
-
fill: "none",
|
|
3031
|
-
strokeLinecap: "round",
|
|
3032
|
-
strokeWidth: 5
|
|
3033
|
-
})
|
|
3034
|
-
) }),
|
|
3035
|
-
/* @__PURE__ */ jsxs("g", { id: "ticks", children: [
|
|
3036
|
-
gauge.ticks.map((angle2) => {
|
|
3037
|
-
const angleToValue = (angle3) => {
|
|
3038
|
-
const angleRange = END_ANGLE$5 - START_ANGLE$5;
|
|
3039
|
-
const valueRange = domainMax - domainMin;
|
|
3040
|
-
const value2 = domainMin + (angle3 - START_ANGLE$5) / angleRange * valueRange;
|
|
3041
|
-
return Math.round(value2);
|
|
3042
|
-
};
|
|
3043
|
-
const asValue = angleToValue(angle2);
|
|
3044
|
-
const showText = asValue % 10 === 0;
|
|
3045
|
-
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
3046
|
-
/* @__PURE__ */ jsx(
|
|
3047
|
-
"line",
|
|
3048
|
-
__spreadValues$7({
|
|
3049
|
-
stroke: "gray",
|
|
3050
|
-
strokeWidth: showText ? 4 : 2
|
|
3051
|
-
}, gauge.getTickProps({ angle: angle2, length: showText ? 12 : 3 }))
|
|
3052
|
-
),
|
|
3053
|
-
showText && /* @__PURE__ */ jsx(
|
|
3054
|
-
"text",
|
|
3055
|
-
__spreadProps$5(__spreadValues$7({
|
|
3056
|
-
fill: "black"
|
|
3057
|
-
}, gauge.getLabelProps({ angle: angle2, offset: 20 })), {
|
|
3058
|
-
style: { fontSize: `${scaleValuesSize != null ? scaleValuesSize : 30}px` },
|
|
3059
|
-
children: asValue
|
|
3060
|
-
})
|
|
3061
|
-
)
|
|
3062
|
-
] }, `tick-group-${angle2}`);
|
|
3063
|
-
}),
|
|
3064
|
-
allTicks
|
|
3065
|
-
] }),
|
|
3066
|
-
/* @__PURE__ */ jsxs("g", { id: "needle", children: [
|
|
3067
|
-
/* @__PURE__ */ jsx("circle", __spreadProps$5(__spreadValues$7({ fill: pointerColor }, needle.base), { r: 20 })),
|
|
3068
|
-
/* @__PURE__ */ jsx("circle", __spreadValues$7({ fill: pointerColor }, needle.base)),
|
|
3069
|
-
/* @__PURE__ */ jsx(
|
|
3070
|
-
"circle",
|
|
3071
|
-
__spreadProps$5(__spreadValues$7({
|
|
3072
|
-
fill: pointerColor,
|
|
3073
|
-
opacity: "0.5"
|
|
3074
|
-
}, needle.tip), {
|
|
3075
|
-
style: {
|
|
3076
|
-
transform: `rotate(${angle}deg)`,
|
|
3077
|
-
transition: "transform 500ms"
|
|
3078
|
-
}
|
|
3079
|
-
})
|
|
3080
|
-
),
|
|
3081
|
-
/* @__PURE__ */ jsx(
|
|
3082
|
-
"polyline",
|
|
3083
|
-
{
|
|
3084
|
-
style: {
|
|
3085
|
-
transform: `rotate(${angle}deg)`,
|
|
3086
|
-
transition: "transform 500ms"
|
|
3087
|
-
},
|
|
3088
|
-
fill: pointerColor,
|
|
3089
|
-
opacity: "0.5",
|
|
3090
|
-
points: needle.points
|
|
3091
|
-
}
|
|
3092
|
-
),
|
|
3093
|
-
/* @__PURE__ */ jsx("circle", __spreadProps$5(__spreadValues$7({ fill: "white" }, needle.base), { r: 4 }))
|
|
3094
|
-
] }),
|
|
3095
|
-
/* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
3096
|
-
"text",
|
|
3097
|
-
{
|
|
3098
|
-
textAnchor: "middle",
|
|
3099
|
-
style: { fontSize: `${currentValueFontSize != null ? currentValueFontSize : 30}px` },
|
|
3100
|
-
y: -diameter / 4 + 20,
|
|
3101
|
-
children: value
|
|
3102
|
-
}
|
|
3103
|
-
) })
|
|
3104
|
-
]
|
|
3105
|
-
})
|
|
3106
|
-
) });
|
|
3107
|
-
};
|
|
3108
|
-
|
|
3109
|
-
var __defProp$6 = Object.defineProperty;
|
|
3110
|
-
var __defProps$4 = Object.defineProperties;
|
|
3111
|
-
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
3112
|
-
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
3113
|
-
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
3114
|
-
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
3115
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3116
|
-
var __spreadValues$6 = (a, b) => {
|
|
3117
|
-
for (var prop in b || (b = {}))
|
|
3118
|
-
if (__hasOwnProp$6.call(b, prop))
|
|
3119
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
3120
|
-
if (__getOwnPropSymbols$6)
|
|
3121
|
-
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
3122
|
-
if (__propIsEnum$6.call(b, prop))
|
|
3123
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
3124
|
-
}
|
|
3125
|
-
return a;
|
|
3126
|
-
};
|
|
3127
|
-
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
3128
|
-
const START_ANGLE$4 = 30;
|
|
3129
|
-
const END_ANGLE$4 = 330;
|
|
3130
|
-
const SpeedMeter = ({
|
|
3131
|
-
backgroundColor,
|
|
3132
|
-
colorRanges,
|
|
3133
|
-
currentValue,
|
|
3134
|
-
currentValueColor,
|
|
3135
|
-
currentValueFontSize,
|
|
3136
|
-
height,
|
|
3137
|
-
maxValue,
|
|
3138
|
-
minValue,
|
|
3139
|
-
pointerColor,
|
|
3140
|
-
scaleValuesSize,
|
|
3141
|
-
valueRanges,
|
|
3142
|
-
width
|
|
3143
|
-
}) => {
|
|
3144
|
-
var _a, _b;
|
|
3145
|
-
const value = currentValue;
|
|
3146
|
-
const diameter = Math.min(height, width);
|
|
3147
|
-
const domainMax = (_a = noNaN(maxValue)) != null ? _a : valueRanges[valueRanges.length - 1];
|
|
3148
|
-
const domainMin = (_b = noNaN(minValue)) != null ? _b : valueRanges[0];
|
|
3149
|
-
const offset = 20;
|
|
3150
|
-
const gauge = useGauge({
|
|
3151
|
-
domain: [domainMin, domainMax],
|
|
3152
|
-
startAngle: START_ANGLE$4,
|
|
3153
|
-
endAngle: END_ANGLE$4,
|
|
3154
|
-
numTicks: valueRanges[valueRanges.length - 1] / 10 + 1,
|
|
3155
|
-
diameter
|
|
3156
|
-
});
|
|
3157
|
-
const needle = gauge.getNeedleProps({
|
|
3158
|
-
value: 0,
|
|
3159
|
-
baseRadius: 12,
|
|
3160
|
-
tipRadius: 2
|
|
3161
|
-
});
|
|
3162
|
-
function getColor(value2) {
|
|
3163
|
-
const index = valueRanges.findIndex((range) => value2 <= range);
|
|
3164
|
-
if (index === -1) {
|
|
3165
|
-
return colorRanges[0];
|
|
3166
|
-
}
|
|
3167
|
-
return colorRanges[index];
|
|
3168
|
-
}
|
|
3169
|
-
const angle = (END_ANGLE$4 - START_ANGLE$4) * value / (domainMax - domainMin);
|
|
3170
|
-
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
|
|
3171
|
-
"svg",
|
|
3172
|
-
__spreadProps$4(__spreadValues$6({}, gauge.getSVGProps()), {
|
|
3173
|
-
height: Math.max(width, height),
|
|
3174
|
-
width: Math.max(width, height),
|
|
3175
|
-
viewBox: `-${diameter / 2 + offset} -${diameter / 2 + offset} ${diameter + offset * 2} ${diameter + offset * 2}`,
|
|
3176
|
-
children: [
|
|
3177
|
-
/* @__PURE__ */ jsxs("g", { id: "arcs", children: [
|
|
3178
|
-
/* @__PURE__ */ jsx(
|
|
3179
|
-
"path",
|
|
3180
|
-
__spreadProps$4(__spreadValues$6({}, gauge.getArcProps({
|
|
3181
|
-
offset: offset - 5,
|
|
3182
|
-
startAngle: 0,
|
|
3183
|
-
endAngle: 360
|
|
3184
|
-
})), {
|
|
3185
|
-
stroke: "gray",
|
|
3186
|
-
fill: backgroundColor != null ? backgroundColor : "none",
|
|
3187
|
-
strokeLinecap: "round",
|
|
3188
|
-
strokeWidth: 5
|
|
3189
|
-
})
|
|
3190
|
-
),
|
|
3191
|
-
valueRanges.map((innerValue, i) => {
|
|
3192
|
-
const valueToAngle = (value2) => {
|
|
3193
|
-
const angleRange = END_ANGLE$4 - START_ANGLE$4;
|
|
3194
|
-
const valueRange = domainMax - domainMin;
|
|
3195
|
-
const angle2 = START_ANGLE$4 + (value2 - domainMin) / valueRange * angleRange;
|
|
3196
|
-
return Math.round(angle2);
|
|
3197
|
-
};
|
|
3198
|
-
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3199
|
-
/* @__PURE__ */ jsx(
|
|
3200
|
-
"path",
|
|
3201
|
-
__spreadProps$4(__spreadValues$6({}, gauge.getArcProps({
|
|
3202
|
-
offset: -50,
|
|
3203
|
-
startAngle: i === 0 ? START_ANGLE$4 : valueToAngle(innerValue),
|
|
3204
|
-
endAngle: i === 0 ? valueToAngle(valueRanges[1]) : i === valueRanges.length - 1 ? END_ANGLE$4 : valueToAngle(valueRanges[i + 1])
|
|
3205
|
-
})), {
|
|
3206
|
-
stroke: getColor(innerValue),
|
|
3207
|
-
opacity: "0.8",
|
|
3208
|
-
fill: "none",
|
|
3209
|
-
strokeLinecap: "round",
|
|
3210
|
-
strokeWidth: 2
|
|
3211
|
-
})
|
|
3212
|
-
),
|
|
3213
|
-
/* @__PURE__ */ createElement(
|
|
3214
|
-
"path",
|
|
3215
|
-
__spreadProps$4(__spreadValues$6({}, gauge.getArcProps({
|
|
3216
|
-
offset: -55,
|
|
3217
|
-
startAngle: i === 0 ? START_ANGLE$4 : valueToAngle(innerValue),
|
|
3218
|
-
endAngle: i === 0 ? valueToAngle(valueRanges[1]) : i === valueRanges.length - 1 ? END_ANGLE$4 : valueToAngle(valueRanges[i + 1])
|
|
3219
|
-
})), {
|
|
3220
|
-
key: `${innerValue}_${i}`,
|
|
3221
|
-
stroke: getColor(innerValue),
|
|
3222
|
-
opacity: "0.8",
|
|
3223
|
-
fill: "none",
|
|
3224
|
-
strokeLinecap: "round",
|
|
3225
|
-
strokeWidth: 2
|
|
3226
|
-
})
|
|
3227
|
-
)
|
|
3228
|
-
] }, `${innerValue}_${i}`);
|
|
3229
|
-
})
|
|
3230
|
-
] }),
|
|
3231
|
-
/* @__PURE__ */ jsx("g", { id: "ticks", children: gauge.ticks.map((angle2) => {
|
|
3232
|
-
const angleToValue = (angle3) => {
|
|
3233
|
-
const angleRange = END_ANGLE$4 - START_ANGLE$4;
|
|
3234
|
-
const valueRange = domainMax - domainMin;
|
|
3235
|
-
const value2 = domainMin + (angle3 - START_ANGLE$4) / angleRange * valueRange;
|
|
3236
|
-
return Math.round(value2);
|
|
3237
|
-
};
|
|
3238
|
-
const asValue = angleToValue(angle2);
|
|
3239
|
-
const showText = asValue % 10 === 0;
|
|
3240
|
-
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
3241
|
-
/* @__PURE__ */ jsx(
|
|
3242
|
-
"line",
|
|
3243
|
-
__spreadValues$6({
|
|
3244
|
-
stroke: "gray",
|
|
3245
|
-
strokeWidth: showText ? 4 : 2
|
|
3246
|
-
}, gauge.getTickProps({ angle: angle2, length: showText ? 12 : 3 }))
|
|
3247
|
-
),
|
|
3248
|
-
showText && /* @__PURE__ */ jsx(
|
|
3249
|
-
"text",
|
|
3250
|
-
__spreadProps$4(__spreadValues$6({
|
|
3251
|
-
fill: "black"
|
|
3252
|
-
}, gauge.getLabelProps({ angle: angle2, offset: 20 })), {
|
|
3253
|
-
style: { fontSize: `${scaleValuesSize != null ? scaleValuesSize : 30}px` },
|
|
3254
|
-
children: asValue
|
|
3255
|
-
})
|
|
3256
|
-
)
|
|
3257
|
-
] }, `tick-group-${angle2}`);
|
|
3258
|
-
}) }),
|
|
3259
|
-
/* @__PURE__ */ jsxs("g", { id: "needle", children: [
|
|
3260
|
-
/* @__PURE__ */ jsx("circle", __spreadProps$4(__spreadValues$6({ fill: pointerColor }, needle.base), { r: 20 })),
|
|
3261
|
-
/* @__PURE__ */ jsx("circle", __spreadValues$6({ fill: pointerColor }, needle.base)),
|
|
3262
|
-
/* @__PURE__ */ jsx(
|
|
3263
|
-
"circle",
|
|
3264
|
-
__spreadProps$4(__spreadValues$6({
|
|
3265
|
-
fill: pointerColor,
|
|
3266
|
-
opacity: "0.5"
|
|
3267
|
-
}, needle.tip), {
|
|
3268
|
-
style: {
|
|
3269
|
-
transform: `rotate(${angle}deg)`,
|
|
3270
|
-
transition: "transform 500ms"
|
|
3271
|
-
}
|
|
3272
|
-
})
|
|
3273
|
-
),
|
|
3274
|
-
/* @__PURE__ */ jsx(
|
|
3275
|
-
"polyline",
|
|
3276
|
-
{
|
|
3277
|
-
style: {
|
|
3278
|
-
transform: `rotate(${angle}deg)`,
|
|
3279
|
-
transition: "transform 500ms"
|
|
3280
|
-
},
|
|
3281
|
-
fill: pointerColor,
|
|
3282
|
-
opacity: "0.5",
|
|
3283
|
-
points: needle.points
|
|
3284
|
-
}
|
|
3285
|
-
),
|
|
3286
|
-
/* @__PURE__ */ jsx("circle", __spreadProps$4(__spreadValues$6({ fill: "white" }, needle.base), { r: 4 }))
|
|
3287
|
-
] }),
|
|
3288
|
-
/* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
3289
|
-
"text",
|
|
3290
|
-
{
|
|
3291
|
-
textAnchor: "middle",
|
|
3292
|
-
y: diameter / 2,
|
|
3293
|
-
fill: currentValueColor,
|
|
3294
|
-
style: { fontSize: `${currentValueFontSize != null ? currentValueFontSize : 30}px` },
|
|
3295
|
-
children: value
|
|
3296
|
-
}
|
|
3297
|
-
) })
|
|
3298
|
-
]
|
|
3299
|
-
})
|
|
3300
|
-
) });
|
|
3301
|
-
};
|
|
3302
|
-
|
|
3303
|
-
var __defProp$5 = Object.defineProperty;
|
|
3304
|
-
var __defProps$3 = Object.defineProperties;
|
|
3305
|
-
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
3306
|
-
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
3307
|
-
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
3308
|
-
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
3309
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3310
|
-
var __spreadValues$5 = (a, b) => {
|
|
3311
|
-
for (var prop in b || (b = {}))
|
|
3312
|
-
if (__hasOwnProp$5.call(b, prop))
|
|
3313
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
3314
|
-
if (__getOwnPropSymbols$5)
|
|
3315
|
-
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
3316
|
-
if (__propIsEnum$5.call(b, prop))
|
|
3317
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
3318
|
-
}
|
|
3319
|
-
return a;
|
|
3320
|
-
};
|
|
3321
|
-
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
3322
|
-
const START_ANGLE$3 = 0;
|
|
3323
|
-
const END_ANGLE$3 = 360;
|
|
3324
|
-
const TLight = ({
|
|
3325
|
-
addBorder = false,
|
|
3326
|
-
colorRanges,
|
|
3327
|
-
maxValue,
|
|
3328
|
-
minValue,
|
|
3329
|
-
currentValue,
|
|
3330
|
-
height,
|
|
3331
|
-
valueRanges,
|
|
3332
|
-
width,
|
|
3333
|
-
currentValueColor,
|
|
3334
|
-
currentValueFontSize
|
|
3335
|
-
}) => {
|
|
3336
|
-
var _a, _b;
|
|
3337
|
-
const [value, setValue] = useState(currentValue);
|
|
3338
|
-
const diameter = Math.min(height, width);
|
|
3339
|
-
const domainMax = (_a = noNaN(maxValue)) != null ? _a : valueRanges[valueRanges.length - 1];
|
|
3340
|
-
const domainMin = (_b = noNaN(minValue)) != null ? _b : valueRanges[0];
|
|
3341
|
-
const gauge = useGauge({
|
|
3342
|
-
domain: [domainMin, domainMax],
|
|
3343
|
-
startAngle: START_ANGLE$3,
|
|
3344
|
-
endAngle: END_ANGLE$3,
|
|
3345
|
-
numTicks: 0,
|
|
3346
|
-
diameter
|
|
3347
|
-
});
|
|
3348
|
-
function getColor(value2) {
|
|
3349
|
-
var _a2;
|
|
3350
|
-
const index = valueRanges.findIndex((range) => value2 < range);
|
|
3351
|
-
if (index === -1) {
|
|
3352
|
-
return colorRanges[0];
|
|
3353
|
-
}
|
|
3354
|
-
return (_a2 = colorRanges[index - 1]) != null ? _a2 : colorRanges[index];
|
|
3355
|
-
}
|
|
3356
|
-
const hasRendered = useRef(false);
|
|
3357
|
-
const onRenderSvg = useCallback(
|
|
3358
|
-
(el) => {
|
|
3359
|
-
if (!el || hasRendered.current)
|
|
3360
|
-
return;
|
|
3361
|
-
hasRendered.current = true;
|
|
3362
|
-
const svgElement = el;
|
|
3363
|
-
const pathElement = el.querySelector("#TLight_arcs");
|
|
3364
|
-
if (!(svgElement && pathElement)) {
|
|
3365
|
-
return;
|
|
3366
|
-
}
|
|
3367
|
-
const pathBox = pathElement.getBoundingClientRect();
|
|
3368
|
-
const svgBox = svgElement.getBoundingClientRect();
|
|
3369
|
-
const pathX = pathBox.x - svgBox.x;
|
|
3370
|
-
const pathY = pathBox.y - svgBox.y;
|
|
3371
|
-
const viewBox = `${pathX - diameter / 2} ${pathY - diameter / 2} ${diameter} ${diameter}`;
|
|
3372
|
-
svgElement.setAttribute("viewBox", viewBox);
|
|
3373
|
-
svgElement.style.visibility = "visible";
|
|
3374
|
-
},
|
|
3375
|
-
[diameter]
|
|
3376
|
-
);
|
|
3377
|
-
const lastCurrentValue = useRef(0);
|
|
3378
|
-
useEffect(() => {
|
|
3379
|
-
const difference = currentValue - lastCurrentValue.current;
|
|
3380
|
-
return animate(
|
|
3381
|
-
500,
|
|
3382
|
-
(progress) => {
|
|
3383
|
-
const step = addBoundary(
|
|
3384
|
-
difference * progress + lastCurrentValue.current,
|
|
3385
|
-
domainMin,
|
|
3386
|
-
domainMax
|
|
3387
|
-
);
|
|
3388
|
-
setValue(Math.round(step));
|
|
3389
|
-
},
|
|
3390
|
-
() => {
|
|
3391
|
-
lastCurrentValue.current = currentValue;
|
|
3392
|
-
}
|
|
3393
|
-
);
|
|
3394
|
-
}, [currentValue]);
|
|
3395
|
-
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
|
|
3396
|
-
"svg",
|
|
3397
|
-
__spreadProps$3(__spreadValues$5({}, gauge.getSVGProps()), {
|
|
3398
|
-
style: { visibility: "hidden" },
|
|
3399
|
-
height: Math.max(width, height),
|
|
3400
|
-
width: Math.max(width, height),
|
|
3401
|
-
id: "TLight_svg",
|
|
3402
|
-
ref: onRenderSvg,
|
|
3403
|
-
viewBox: `-${diameter / 2} -${diameter / 2} ${diameter} ${diameter}`,
|
|
3404
|
-
children: [
|
|
3405
|
-
/* @__PURE__ */ jsxs("g", { id: "TLight_arcs", children: [
|
|
3406
|
-
/* @__PURE__ */ jsx(
|
|
3407
|
-
"path",
|
|
3408
|
-
__spreadProps$3(__spreadValues$5({}, gauge.getArcProps({
|
|
3409
|
-
startAngle: START_ANGLE$3,
|
|
3410
|
-
endAngle: END_ANGLE$3
|
|
3411
|
-
})), {
|
|
3412
|
-
fill: getColor(value),
|
|
3413
|
-
id: "TLight_path",
|
|
3414
|
-
style: { transition: "fill 0.3s" }
|
|
3415
|
-
})
|
|
3416
|
-
),
|
|
3417
|
-
addBorder && /* @__PURE__ */ jsx(
|
|
3418
|
-
"path",
|
|
3419
|
-
__spreadProps$3(__spreadValues$5({}, gauge.getArcProps({
|
|
3420
|
-
offset: -2.5,
|
|
3421
|
-
startAngle: START_ANGLE$3,
|
|
3422
|
-
endAngle: END_ANGLE$3
|
|
3423
|
-
})), {
|
|
3424
|
-
stroke: "black",
|
|
3425
|
-
fill: "transparent",
|
|
3426
|
-
strokeLinecap: "round",
|
|
3427
|
-
strokeWidth: 5,
|
|
3428
|
-
id: "TLight_path"
|
|
3429
|
-
})
|
|
3430
|
-
)
|
|
3431
|
-
] }),
|
|
3432
|
-
/* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
3433
|
-
"text",
|
|
3434
|
-
{
|
|
3435
|
-
textAnchor: "middle",
|
|
3436
|
-
style: { fontSize: `${currentValueFontSize != null ? currentValueFontSize : 100}pt` },
|
|
3437
|
-
alignmentBaseline: "central",
|
|
3438
|
-
fill: currentValueColor,
|
|
3439
|
-
children: value
|
|
3440
|
-
}
|
|
3441
|
-
) })
|
|
3442
|
-
]
|
|
3443
|
-
})
|
|
3444
|
-
) });
|
|
3445
|
-
};
|
|
3446
|
-
|
|
3447
|
-
var __defProp$4 = Object.defineProperty;
|
|
3448
|
-
var __defProps$2 = Object.defineProperties;
|
|
3449
|
-
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
3450
|
-
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
3451
|
-
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
3452
|
-
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
3453
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3454
|
-
var __spreadValues$4 = (a, b) => {
|
|
3455
|
-
for (var prop in b || (b = {}))
|
|
3456
|
-
if (__hasOwnProp$4.call(b, prop))
|
|
3457
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
3458
|
-
if (__getOwnPropSymbols$4)
|
|
3459
|
-
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
3460
|
-
if (__propIsEnum$4.call(b, prop))
|
|
3461
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
3462
|
-
}
|
|
3463
|
-
return a;
|
|
3464
|
-
};
|
|
3465
|
-
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
3466
|
-
const START_ANGLE$2 = 45;
|
|
3467
|
-
const END_ANGLE$2 = 315;
|
|
3468
|
-
const Oxford = ({
|
|
3469
|
-
backgroundColor,
|
|
3470
|
-
colorRanges,
|
|
3471
|
-
currentValue,
|
|
3472
|
-
currentValueColor,
|
|
3473
|
-
currentValueFontSize,
|
|
3474
|
-
height,
|
|
3475
|
-
maxValue,
|
|
3476
|
-
minValue,
|
|
3477
|
-
pointerColor,
|
|
3478
|
-
scaleValuesSize,
|
|
3479
|
-
valueRanges,
|
|
3480
|
-
width
|
|
3481
|
-
}) => {
|
|
3482
|
-
var _a, _b;
|
|
3483
|
-
const value = currentValue;
|
|
3484
|
-
const diameter = Math.min(height, width);
|
|
3485
|
-
const domainMax = (_a = noNaN(maxValue)) != null ? _a : valueRanges[valueRanges.length - 1];
|
|
3486
|
-
const domainMin = (_b = noNaN(minValue)) != null ? _b : valueRanges[0];
|
|
3487
|
-
const offset = 20;
|
|
3488
|
-
const gauge = useGauge({
|
|
3489
|
-
domain: [domainMin, domainMax],
|
|
3490
|
-
startAngle: START_ANGLE$2,
|
|
3491
|
-
endAngle: END_ANGLE$2,
|
|
3492
|
-
numTicks: 10 + 1,
|
|
3493
|
-
diameter
|
|
3494
|
-
});
|
|
3495
|
-
const gauge2 = useGauge({
|
|
3496
|
-
domain: [valueRanges[0], valueRanges[valueRanges.length - 1]],
|
|
3497
|
-
startAngle: START_ANGLE$2,
|
|
3498
|
-
endAngle: END_ANGLE$2,
|
|
3499
|
-
numTicks: valueRanges[valueRanges.length - 1] - valueRanges[0] + 1,
|
|
3500
|
-
diameter
|
|
3501
|
-
});
|
|
3502
|
-
const needle = gauge.getNeedleProps({
|
|
3503
|
-
value: 0,
|
|
3504
|
-
baseRadius: 12,
|
|
3505
|
-
tipRadius: 2
|
|
3506
|
-
});
|
|
3507
|
-
const angle = (END_ANGLE$2 - START_ANGLE$2) * value / (domainMax - domainMin);
|
|
3508
|
-
function getColor(value2) {
|
|
3509
|
-
const index = valueRanges.findIndex((range) => value2 <= range);
|
|
3510
|
-
if (index === -1) {
|
|
3511
|
-
return colorRanges[0];
|
|
3512
|
-
}
|
|
3513
|
-
return colorRanges[index];
|
|
3514
|
-
}
|
|
3515
|
-
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
|
|
3516
|
-
"svg",
|
|
3517
|
-
__spreadProps$2(__spreadValues$4({}, gauge.getSVGProps()), {
|
|
3518
|
-
height: Math.max(width, height),
|
|
3519
|
-
width: Math.max(width, height),
|
|
3520
|
-
viewBox: `-${diameter / 2 + offset} -${diameter / 2 + offset} ${diameter + offset * 2} ${diameter + offset * 2}`,
|
|
3521
|
-
children: [
|
|
3522
|
-
/* @__PURE__ */ jsxs("g", { id: "arcs", children: [
|
|
3523
|
-
/* @__PURE__ */ jsx(
|
|
3524
|
-
"path",
|
|
3525
|
-
__spreadProps$2(__spreadValues$4({}, gauge.getArcProps({
|
|
3526
|
-
offset: offset - 5,
|
|
3527
|
-
startAngle: 0,
|
|
3528
|
-
endAngle: 360
|
|
3529
|
-
})), {
|
|
3530
|
-
stroke: "black",
|
|
3531
|
-
opacity: "1",
|
|
3532
|
-
fill: backgroundColor !== "" && backgroundColor !== void 0 ? tinycolor(backgroundColor).setAlpha(0.5).toPercentageRgbString() : "none",
|
|
3533
|
-
strokeLinecap: "round",
|
|
3534
|
-
strokeWidth: 5,
|
|
3535
|
-
vectorEffect: "non-scaling-stroke"
|
|
3536
|
-
})
|
|
3537
|
-
),
|
|
3538
|
-
valueRanges.map((innerValue, i) => {
|
|
3539
|
-
if (!valueRanges[i + 1]) {
|
|
3540
|
-
return null;
|
|
3541
|
-
}
|
|
3542
|
-
const valueToAngle = (value2) => {
|
|
3543
|
-
const angleRange = END_ANGLE$2 - START_ANGLE$2;
|
|
3544
|
-
const valueRange = domainMax - domainMin;
|
|
3545
|
-
const angle2 = START_ANGLE$2 + (value2 - domainMin) / valueRange * angleRange;
|
|
3546
|
-
return Math.round(angle2);
|
|
3547
|
-
};
|
|
3548
|
-
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3549
|
-
/* @__PURE__ */ jsx(
|
|
3550
|
-
"path",
|
|
3551
|
-
__spreadProps$2(__spreadValues$4({}, gauge.getArcProps({
|
|
3552
|
-
offset: offset - 5,
|
|
3553
|
-
startAngle: i === 0 ? START_ANGLE$2 : valueToAngle(innerValue),
|
|
3554
|
-
endAngle: i === 0 ? valueToAngle(valueRanges[1]) : i === valueRanges.length - 1 ? END_ANGLE$2 : valueToAngle(valueRanges[i + 1])
|
|
3555
|
-
})), {
|
|
3556
|
-
stroke: "black",
|
|
3557
|
-
opacity: "0.8",
|
|
3558
|
-
fill: "none",
|
|
3559
|
-
strokeLinecap: "square",
|
|
3560
|
-
strokeWidth: 5,
|
|
3561
|
-
vectorEffect: "non-scaling-stroke"
|
|
3562
|
-
})
|
|
3563
|
-
),
|
|
3564
|
-
/* @__PURE__ */ jsx(
|
|
3565
|
-
"path",
|
|
3566
|
-
__spreadProps$2(__spreadValues$4({}, gauge.getArcProps({
|
|
3567
|
-
offset: -20,
|
|
3568
|
-
startAngle: i === 0 ? START_ANGLE$2 : valueToAngle(innerValue),
|
|
3569
|
-
endAngle: i === 0 ? valueToAngle(valueRanges[1]) : i === valueRanges.length - 1 ? END_ANGLE$2 : valueToAngle(valueRanges[i + 1])
|
|
3570
|
-
})), {
|
|
3571
|
-
stroke: getColor(innerValue),
|
|
3572
|
-
opacity: "0.1",
|
|
3573
|
-
fill: "none",
|
|
3574
|
-
strokeLinecap: "butt",
|
|
3575
|
-
strokeWidth: 75,
|
|
3576
|
-
vectorEffect: "non-scaling-stroke"
|
|
3577
|
-
})
|
|
3578
|
-
),
|
|
3579
|
-
/* @__PURE__ */ createElement(
|
|
3580
|
-
"path",
|
|
3581
|
-
__spreadProps$2(__spreadValues$4({}, gauge.getArcProps({
|
|
3582
|
-
offset: -55,
|
|
3583
|
-
startAngle: i === 0 ? START_ANGLE$2 : valueToAngle(innerValue),
|
|
3584
|
-
endAngle: i === 0 ? valueToAngle(valueRanges[1]) : i === valueRanges.length - 1 ? END_ANGLE$2 : valueToAngle(valueRanges[i + 1])
|
|
3585
|
-
})), {
|
|
3586
|
-
key: `${innerValue}_${i}`,
|
|
3587
|
-
stroke: getColor(innerValue) || "#999",
|
|
3588
|
-
opacity: "0.8",
|
|
3589
|
-
fill: "none",
|
|
3590
|
-
strokeLinecap: "butt",
|
|
3591
|
-
strokeWidth: 10,
|
|
3592
|
-
vectorEffect: "non-scaling-stroke"
|
|
3593
|
-
})
|
|
3594
|
-
)
|
|
3595
|
-
] }, `${innerValue}_${i}`);
|
|
3596
|
-
})
|
|
3597
|
-
] }),
|
|
3598
|
-
/* @__PURE__ */ jsxs("g", { id: "ticks", children: [
|
|
3599
|
-
gauge.ticks.map((angle2, i) => {
|
|
3600
|
-
const angleToValue = (angle3) => {
|
|
3601
|
-
const angleRange = END_ANGLE$2 - START_ANGLE$2;
|
|
3602
|
-
const valueRange = domainMax - domainMin;
|
|
3603
|
-
const value2 = domainMin + (angle3 - START_ANGLE$2) / angleRange * valueRange;
|
|
3604
|
-
return Math.round(value2);
|
|
3605
|
-
};
|
|
3606
|
-
const asValue = angleToValue(angle2);
|
|
3607
|
-
const showText = asValue % 10 === 0;
|
|
3608
|
-
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
3609
|
-
/* @__PURE__ */ jsx(
|
|
3610
|
-
"line",
|
|
3611
|
-
__spreadProps$2(__spreadValues$4({
|
|
3612
|
-
stroke: "gray",
|
|
3613
|
-
strokeWidth: showText ? 4 : 2
|
|
3614
|
-
}, gauge.getTickProps({ angle: angle2, length: showText ? 12 : 3 })), {
|
|
3615
|
-
vectorEffect: "non-scaling-stroke"
|
|
3616
|
-
})
|
|
3617
|
-
),
|
|
3618
|
-
showText && /* @__PURE__ */ jsx(
|
|
3619
|
-
"text",
|
|
3620
|
-
__spreadProps$2(__spreadValues$4({
|
|
3621
|
-
fill: "black"
|
|
3622
|
-
}, gauge.getLabelProps({
|
|
3623
|
-
angle: angle2,
|
|
3624
|
-
offset: 20
|
|
3625
|
-
})), {
|
|
3626
|
-
style: {
|
|
3627
|
-
fontSize: `${scaleValuesSize != null ? scaleValuesSize : 30}px`
|
|
3628
|
-
},
|
|
3629
|
-
children: asValue
|
|
3630
|
-
})
|
|
3631
|
-
)
|
|
3632
|
-
] }, `tick-group-${angle2}_ ${i}`);
|
|
3633
|
-
}),
|
|
3634
|
-
gauge2.ticks.map((angle2, i) => {
|
|
3635
|
-
return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsx(
|
|
3636
|
-
"line",
|
|
3637
|
-
__spreadProps$2(__spreadValues$4({
|
|
3638
|
-
stroke: "gray",
|
|
3639
|
-
strokeWidth: 2
|
|
3640
|
-
}, gauge.getTickProps({
|
|
3641
|
-
angle: angle2,
|
|
3642
|
-
length: 3
|
|
3643
|
-
})), {
|
|
3644
|
-
vectorEffect: "non-scaling-stroke"
|
|
3645
|
-
})
|
|
3646
|
-
) }, `tick-group-${angle2}_ ${i}_2`);
|
|
3647
|
-
})
|
|
3648
|
-
] }),
|
|
3649
|
-
/* @__PURE__ */ jsxs("g", { id: "needle", children: [
|
|
3650
|
-
/* @__PURE__ */ jsx("circle", __spreadProps$2(__spreadValues$4({ fill: pointerColor }, needle.base), { r: 20 })),
|
|
3651
|
-
/* @__PURE__ */ jsx("circle", __spreadValues$4({ fill: pointerColor }, needle.base)),
|
|
3652
|
-
/* @__PURE__ */ jsx(
|
|
3653
|
-
"circle",
|
|
3654
|
-
__spreadProps$2(__spreadValues$4({
|
|
3655
|
-
fill: pointerColor,
|
|
3656
|
-
opacity: "0.5"
|
|
3657
|
-
}, needle.tip), {
|
|
3658
|
-
style: {
|
|
3659
|
-
transform: `rotate(${angle}deg)`,
|
|
3660
|
-
transition: "transform 500ms"
|
|
3661
|
-
}
|
|
3662
|
-
})
|
|
3663
|
-
),
|
|
3664
|
-
/* @__PURE__ */ jsx(
|
|
3665
|
-
"polyline",
|
|
3666
|
-
{
|
|
3667
|
-
style: {
|
|
3668
|
-
transform: `rotate(${angle}deg)`,
|
|
3669
|
-
transition: "transform 500ms"
|
|
3670
|
-
},
|
|
3671
|
-
fill: pointerColor,
|
|
3672
|
-
opacity: "0.5",
|
|
3673
|
-
points: needle.points
|
|
3674
|
-
}
|
|
3675
|
-
),
|
|
3676
|
-
/* @__PURE__ */ jsx("circle", __spreadProps$2(__spreadValues$4({ fill: "white" }, needle.base), { r: 4 }))
|
|
3677
|
-
] }),
|
|
3678
|
-
/* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
3679
|
-
"text",
|
|
3680
|
-
{
|
|
3681
|
-
textAnchor: "middle",
|
|
3682
|
-
alignmentBaseline: "text-before-edge",
|
|
3683
|
-
y: diameter / 5,
|
|
3684
|
-
style: { fontSize: `${currentValueFontSize != null ? currentValueFontSize : 30}px` },
|
|
3685
|
-
fill: currentValueColor,
|
|
3686
|
-
children: value
|
|
3687
|
-
}
|
|
3688
|
-
) })
|
|
3689
|
-
]
|
|
3690
|
-
})
|
|
3691
|
-
) });
|
|
3692
|
-
};
|
|
3693
|
-
|
|
3694
|
-
var __defProp$3 = Object.defineProperty;
|
|
3695
|
-
var __defProps$1 = Object.defineProperties;
|
|
3696
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
3697
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
3698
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
3699
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
3700
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3701
|
-
var __spreadValues$3 = (a, b) => {
|
|
3702
|
-
for (var prop in b || (b = {}))
|
|
3703
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
3704
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
3705
|
-
if (__getOwnPropSymbols$3)
|
|
3706
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
3707
|
-
if (__propIsEnum$3.call(b, prop))
|
|
3708
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
3709
|
-
}
|
|
3710
|
-
return a;
|
|
3711
|
-
};
|
|
3712
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
3713
|
-
const START_ANGLE$1 = 0;
|
|
3714
|
-
const END_ANGLE$1 = 360;
|
|
3715
|
-
const Counter = ({
|
|
3716
|
-
addBorder = false,
|
|
3717
|
-
colorRanges,
|
|
3718
|
-
currentValue,
|
|
3719
|
-
valueRanges,
|
|
3720
|
-
maxValue,
|
|
3721
|
-
minValue,
|
|
3722
|
-
currentValueFontSize,
|
|
3723
|
-
panelId
|
|
3724
|
-
}) => {
|
|
3725
|
-
var _a, _b;
|
|
3726
|
-
const [value, setValue] = useState(currentValue != null ? currentValue : 0);
|
|
3727
|
-
const actualWidth = (currentValueFontSize != null ? currentValueFontSize : 80) * 3 * 0.8;
|
|
3728
|
-
const diameter = actualWidth;
|
|
3729
|
-
const domainMax = (_a = noNaN(maxValue)) != null ? _a : valueRanges[valueRanges.length - 1];
|
|
3730
|
-
const domainMin = (_b = noNaN(minValue)) != null ? _b : valueRanges[0];
|
|
3731
|
-
const gauge = useGauge({
|
|
3732
|
-
domain: [domainMin, domainMax],
|
|
3733
|
-
startAngle: START_ANGLE$1,
|
|
3734
|
-
endAngle: END_ANGLE$1,
|
|
3735
|
-
numTicks: 0,
|
|
3736
|
-
diameter
|
|
3737
|
-
});
|
|
3738
|
-
function getColor(value2) {
|
|
3739
|
-
var _a2;
|
|
3740
|
-
const index = valueRanges.findIndex((range) => value2 <= range);
|
|
3741
|
-
if (index === -1) {
|
|
3742
|
-
return colorRanges[0];
|
|
3743
|
-
}
|
|
3744
|
-
return (_a2 = colorRanges[index - 1]) != null ? _a2 : colorRanges[index];
|
|
3745
|
-
}
|
|
3746
|
-
const lastCurrentValue = useRef(0);
|
|
3747
|
-
useEffect(() => {
|
|
3748
|
-
const difference = currentValue - lastCurrentValue.current;
|
|
3749
|
-
return animate(
|
|
3750
|
-
500,
|
|
3751
|
-
(progress) => {
|
|
3752
|
-
const step = addBoundary(
|
|
3753
|
-
difference * progress + lastCurrentValue.current,
|
|
3754
|
-
domainMin,
|
|
3755
|
-
domainMax
|
|
3756
|
-
);
|
|
3757
|
-
setValue(Math.round(step));
|
|
3758
|
-
},
|
|
3759
|
-
() => {
|
|
3760
|
-
lastCurrentValue.current = currentValue;
|
|
3761
|
-
}
|
|
3762
|
-
);
|
|
3763
|
-
}, [currentValue]);
|
|
3764
|
-
return /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, className: "widgetContainer__Counter", children: [
|
|
3765
|
-
/* @__PURE__ */ jsx(
|
|
3766
|
-
"svg",
|
|
3767
|
-
__spreadProps$1(__spreadValues$3({}, gauge.getSVGProps()), {
|
|
3768
|
-
height: actualWidth,
|
|
3769
|
-
width: actualWidth,
|
|
3770
|
-
viewBox: void 0,
|
|
3771
|
-
children: /* @__PURE__ */ jsx("g", { id: "arcs", children: addBorder && `${value}`.length < 4 && /* @__PURE__ */ jsx(
|
|
3772
|
-
"ellipse",
|
|
3773
|
-
{
|
|
3774
|
-
cx: actualWidth / 2,
|
|
3775
|
-
cy: actualWidth / 2,
|
|
3776
|
-
rx: actualWidth / 2 - 5,
|
|
3777
|
-
ry: actualWidth / 2 - 5,
|
|
3778
|
-
stroke: "gray",
|
|
3779
|
-
opacity: "0.2",
|
|
3780
|
-
fill: "none",
|
|
3781
|
-
strokeLinecap: "round",
|
|
3782
|
-
strokeWidth: 2
|
|
3783
|
-
}
|
|
3784
|
-
) })
|
|
3785
|
-
})
|
|
3786
|
-
),
|
|
3787
|
-
/* @__PURE__ */ jsx(
|
|
3788
|
-
"svg",
|
|
3789
|
-
{
|
|
3790
|
-
height: actualWidth,
|
|
3791
|
-
width: actualWidth,
|
|
3792
|
-
style: { position: "absolute", left: 0, top: 0 },
|
|
3793
|
-
children: /* @__PURE__ */ jsx(
|
|
3794
|
-
"text",
|
|
3795
|
-
{
|
|
3796
|
-
x: actualWidth / 2,
|
|
3797
|
-
y: actualWidth / 2 - 5,
|
|
3798
|
-
textAnchor: "middle",
|
|
3799
|
-
style: {
|
|
3800
|
-
fontSize: `${currentValueFontSize != null ? currentValueFontSize : 80}px`,
|
|
3801
|
-
transition: "fill 0.5s"
|
|
3802
|
-
},
|
|
3803
|
-
alignmentBaseline: "central",
|
|
3804
|
-
fill: getColor(value),
|
|
3805
|
-
id: `text_${panelId}`,
|
|
3806
|
-
children: value
|
|
3807
|
-
}
|
|
3808
|
-
)
|
|
3809
|
-
}
|
|
3810
|
-
)
|
|
3811
|
-
] });
|
|
3812
|
-
};
|
|
3813
|
-
|
|
3814
|
-
var __defProp$2 = Object.defineProperty;
|
|
3815
|
-
var __defProps = Object.defineProperties;
|
|
3816
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3817
|
-
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
3818
|
-
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
3819
|
-
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
3820
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3821
|
-
var __spreadValues$2 = (a, b) => {
|
|
3822
|
-
for (var prop in b || (b = {}))
|
|
3823
|
-
if (__hasOwnProp$2.call(b, prop))
|
|
3824
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
3825
|
-
if (__getOwnPropSymbols$2)
|
|
3826
|
-
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
3827
|
-
if (__propIsEnum$2.call(b, prop))
|
|
3828
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
3829
|
-
}
|
|
3830
|
-
return a;
|
|
3831
|
-
};
|
|
3832
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
3833
|
-
const START_ANGLE = 0;
|
|
3834
|
-
const END_ANGLE = 360;
|
|
3835
|
-
const Ring = ({
|
|
3836
|
-
colorRanges,
|
|
3837
|
-
maxValue,
|
|
3838
|
-
minValue,
|
|
3839
|
-
currentValue,
|
|
3840
|
-
height,
|
|
3841
|
-
valueRanges,
|
|
3842
|
-
ringEmptyColor,
|
|
3843
|
-
ringWidth,
|
|
3844
|
-
width,
|
|
3845
|
-
currentValueColor,
|
|
3846
|
-
currentValueFontSize
|
|
3847
|
-
}) => {
|
|
3848
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3849
|
-
const [value, setValue] = useState(currentValue);
|
|
3850
|
-
const diameter = Math.min(height, width);
|
|
3851
|
-
const offset = 20;
|
|
3852
|
-
const domainMax = (_a = noNaN(maxValue)) != null ? _a : valueRanges[valueRanges.length - 1];
|
|
3853
|
-
const domainMin = (_b = noNaN(minValue)) != null ? _b : valueRanges[0];
|
|
3854
|
-
const gauge = useGauge({
|
|
3855
|
-
domain: [domainMin, domainMax],
|
|
3856
|
-
startAngle: START_ANGLE,
|
|
3857
|
-
endAngle: END_ANGLE,
|
|
3858
|
-
numTicks: 0,
|
|
3859
|
-
diameter
|
|
3860
|
-
});
|
|
3861
|
-
const lastCurrentValue = useRef(0);
|
|
3862
|
-
useEffect(() => {
|
|
3863
|
-
const difference = currentValue - lastCurrentValue.current;
|
|
3864
|
-
return animate(
|
|
3865
|
-
500,
|
|
3866
|
-
(progress) => {
|
|
3867
|
-
const step = addBoundary(
|
|
3868
|
-
difference * progress + lastCurrentValue.current,
|
|
3869
|
-
domainMin,
|
|
3870
|
-
domainMax
|
|
3871
|
-
);
|
|
3872
|
-
setValue(Math.round(step));
|
|
3873
|
-
},
|
|
3874
|
-
() => {
|
|
3875
|
-
lastCurrentValue.current = currentValue;
|
|
3876
|
-
}
|
|
3877
|
-
);
|
|
3878
|
-
}, [currentValue]);
|
|
3879
|
-
function getColor(value2) {
|
|
3880
|
-
var _a2;
|
|
3881
|
-
const index = valueRanges.findIndex((range) => value2 <= range);
|
|
3882
|
-
if (index === -1) {
|
|
3883
|
-
return colorRanges[0];
|
|
3884
|
-
}
|
|
3885
|
-
return (_a2 = colorRanges[index - 1]) != null ? _a2 : colorRanges[index];
|
|
3886
|
-
}
|
|
3887
|
-
const valueToAngle = (value2) => {
|
|
3888
|
-
const angleRange = 360;
|
|
3889
|
-
const valueRange = domainMax - domainMin;
|
|
3890
|
-
const angle = (value2 - domainMin) / valueRange * angleRange;
|
|
3891
|
-
return Math.round(angle);
|
|
3892
|
-
};
|
|
3893
|
-
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
|
|
3894
|
-
"svg",
|
|
3895
|
-
__spreadProps(__spreadValues$2({}, gauge.getSVGProps()), {
|
|
3896
|
-
height: Math.max(width, height),
|
|
3897
|
-
width: Math.max(width, height),
|
|
3898
|
-
viewBox: `-${diameter / 2 + offset} -${diameter / 2 + offset} ${diameter + offset * 2} ${diameter + offset * 2}`,
|
|
3899
|
-
children: [
|
|
3900
|
-
/* @__PURE__ */ jsxs("g", { id: "arcs", children: [
|
|
3901
|
-
/* @__PURE__ */ jsx(
|
|
3902
|
-
"path",
|
|
3903
|
-
__spreadProps(__spreadValues$2({}, gauge.getArcProps({
|
|
3904
|
-
offset: offset - ((_c = noNaN(ringWidth)) != null ? _c : 0) * 100,
|
|
3905
|
-
startAngle: START_ANGLE,
|
|
3906
|
-
endAngle: END_ANGLE
|
|
3907
|
-
})), {
|
|
3908
|
-
stroke: ringEmptyColor != null ? ringEmptyColor : "transparent",
|
|
3909
|
-
fill: "none",
|
|
3910
|
-
strokeLinecap: "round",
|
|
3911
|
-
strokeWidth: ((_d = noNaN(ringWidth)) != null ? _d : 0) * 100
|
|
3912
|
-
})
|
|
3913
|
-
),
|
|
3914
|
-
/* @__PURE__ */ jsx(
|
|
3915
|
-
"path",
|
|
3916
|
-
__spreadProps(__spreadValues$2({}, gauge.getArcProps({
|
|
3917
|
-
offset: offset - ((_e = noNaN(ringWidth)) != null ? _e : 0) * 100,
|
|
3918
|
-
startAngle: 180,
|
|
3919
|
-
endAngle: valueToAngle(value) === 360 ? 179 + valueToAngle(value) : 180 + valueToAngle(value)
|
|
3920
|
-
})), {
|
|
3921
|
-
stroke: getColor(value),
|
|
3922
|
-
opacity: "0.8",
|
|
3923
|
-
fill: "none",
|
|
3924
|
-
strokeLinecap: "square",
|
|
3925
|
-
strokeWidth: ((_f = noNaN(ringWidth)) != null ? _f : 0) * 100,
|
|
3926
|
-
style: {
|
|
3927
|
-
transition: "stroke 0.5s"
|
|
3928
|
-
}
|
|
3929
|
-
})
|
|
3930
|
-
)
|
|
3931
|
-
] }),
|
|
3932
|
-
/* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
3933
|
-
"text",
|
|
3934
|
-
{
|
|
3935
|
-
textAnchor: "middle",
|
|
3936
|
-
style: { fontSize: `${currentValueFontSize != null ? currentValueFontSize : 30}px` },
|
|
3937
|
-
alignmentBaseline: "central",
|
|
3938
|
-
color: currentValueColor,
|
|
3939
|
-
children: value
|
|
3940
|
-
}
|
|
3941
|
-
) })
|
|
3942
|
-
]
|
|
3943
|
-
})
|
|
3944
|
-
) });
|
|
3945
|
-
};
|
|
3946
|
-
|
|
3947
|
-
const colorGetter = (valueRanges, colorRanges, innerValue) => {
|
|
3948
|
-
let color = "";
|
|
3949
|
-
valueRanges.forEach((value, index) => {
|
|
3950
|
-
if (value >= innerValue && valueRanges[index - 1] <= innerValue) {
|
|
3951
|
-
color = colorRanges[index - 1];
|
|
3952
|
-
}
|
|
3953
|
-
});
|
|
3954
|
-
return color;
|
|
3955
|
-
};
|
|
3956
|
-
function getColor(valueRanges, colorRanges, value) {
|
|
3957
|
-
const index = valueRanges.findIndex((range) => value <= range);
|
|
3958
|
-
if (index === -1) {
|
|
3959
|
-
return colorRanges[0];
|
|
3960
|
-
}
|
|
3961
|
-
return colorRanges[index];
|
|
3962
|
-
}
|
|
3963
|
-
function getInnerColor(valueRanges, colorRanges, value) {
|
|
3964
|
-
var _a;
|
|
3965
|
-
const index = valueRanges.findIndex((range) => value < range);
|
|
3966
|
-
if (index === -1) {
|
|
3967
|
-
return colorRanges[0];
|
|
3968
|
-
}
|
|
3969
|
-
return (_a = colorRanges[index - 1]) != null ? _a : colorRanges[index];
|
|
3970
|
-
}
|
|
3971
|
-
const valueToTickPercent = (domainMax, baseValue, value) => {
|
|
3972
|
-
const range = domainMax - (baseValue != null ? baseValue : 0);
|
|
3973
|
-
const percentage = 100 - (value - (baseValue != null ? baseValue : 0)) / range * 100;
|
|
3974
|
-
return Math.round(percentage);
|
|
3975
|
-
};
|
|
3976
|
-
|
|
3977
|
-
const valueToPercent = (domainMax, baseValue, value) => {
|
|
3978
|
-
const range = domainMax - (baseValue != null ? baseValue : 0);
|
|
3979
|
-
const percentage = 100 - (value - (baseValue != null ? baseValue : 0)) / range * 100;
|
|
3980
|
-
const test = percentage * 69 / 100;
|
|
3981
|
-
return Math.round(test);
|
|
3982
|
-
};
|
|
3983
|
-
|
|
3984
|
-
const useCustomWidget = ({
|
|
3985
|
-
maxValue,
|
|
3986
|
-
minValue,
|
|
3987
|
-
currentValue,
|
|
3988
|
-
panelId
|
|
3989
|
-
}) => {
|
|
3990
|
-
const baseValue = minValue;
|
|
3991
|
-
const domainMax = maxValue;
|
|
3992
|
-
const [yDifference, setYDifference] = useState(0);
|
|
3993
|
-
const svgRect = useRef({});
|
|
3994
|
-
const pathRect = useRef({});
|
|
3995
|
-
const onRenderRect = useCallback(
|
|
3996
|
-
(el) => {
|
|
3997
|
-
if (!el)
|
|
3998
|
-
return;
|
|
3999
|
-
const svgElement = el.closest("svg");
|
|
4000
|
-
const pathElement = svgElement == null ? void 0 : svgElement.querySelector(`#path_${panelId}`);
|
|
4001
|
-
if (!svgElement)
|
|
4002
|
-
throw new Error("No svg");
|
|
4003
|
-
if (!pathElement)
|
|
4004
|
-
throw new Error("No path");
|
|
4005
|
-
const svgBox = svgElement.getBoundingClientRect();
|
|
4006
|
-
const pathBox = pathElement.getBoundingClientRect();
|
|
4007
|
-
const pathY2 = pathBox.y - svgBox.y;
|
|
4008
|
-
svgRect.current = svgBox;
|
|
4009
|
-
pathRect.current = pathBox;
|
|
4010
|
-
setYDifference(pathY2);
|
|
4011
|
-
},
|
|
4012
|
-
[panelId]
|
|
4013
|
-
);
|
|
4014
|
-
const pathX = noNaN(pathRect.current.x - svgRect.current.x);
|
|
4015
|
-
const pathY = noNaN(pathRect.current.y - svgRect.current.y);
|
|
4016
|
-
const pathWidth = noNaN(pathRect.current.width);
|
|
4017
|
-
const pathHeight = noNaN(pathRect.current.height);
|
|
4018
|
-
const viewBox = `${pathX} ${pathY} ${pathWidth} ${pathHeight}`;
|
|
4019
|
-
const rectProps = {
|
|
4020
|
-
y: noNaN(
|
|
4021
|
-
valueToPercent(domainMax, baseValue, currentValue) * pathHeight / 100 + yDifference
|
|
4022
|
-
),
|
|
4023
|
-
x: pathX,
|
|
4024
|
-
width: pathWidth,
|
|
4025
|
-
height: pathHeight,
|
|
4026
|
-
style: {
|
|
4027
|
-
visibility: "visible",
|
|
4028
|
-
transition: "y 0.5s, fill 0.5s"
|
|
4029
|
-
}
|
|
4030
|
-
};
|
|
4031
|
-
return {
|
|
4032
|
-
rectRef: onRenderRect,
|
|
4033
|
-
svgViewBox: viewBox,
|
|
4034
|
-
rectProps,
|
|
4035
|
-
pathX,
|
|
4036
|
-
pathY,
|
|
4037
|
-
pathRect,
|
|
4038
|
-
svgRect
|
|
4039
|
-
};
|
|
4040
|
-
};
|
|
4041
|
-
|
|
4042
|
-
var __defProp$1 = Object.defineProperty;
|
|
4043
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
4044
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
4045
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
4046
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4047
|
-
var __spreadValues$1 = (a, b) => {
|
|
4048
|
-
for (var prop in b || (b = {}))
|
|
4049
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
4050
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
4051
|
-
if (__getOwnPropSymbols$1)
|
|
4052
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
4053
|
-
if (__propIsEnum$1.call(b, prop))
|
|
4054
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
4055
|
-
}
|
|
4056
|
-
return a;
|
|
4057
|
-
};
|
|
4058
|
-
const Thermometer = ({
|
|
4059
|
-
colorRanges,
|
|
4060
|
-
maxValue,
|
|
4061
|
-
minValue,
|
|
4062
|
-
currentValue,
|
|
4063
|
-
height,
|
|
4064
|
-
valueRanges,
|
|
4065
|
-
width,
|
|
4066
|
-
panelId,
|
|
4067
|
-
currentValueFontSize
|
|
4068
|
-
}) => {
|
|
4069
|
-
var _a, _b, _c;
|
|
4070
|
-
const value = currentValue;
|
|
4071
|
-
const baseValue = (_a = noNaN(minValue)) != null ? _a : valueRanges[0];
|
|
4072
|
-
const domainMax = (_b = noNaN(maxValue)) != null ? _b : valueRanges[valueRanges.length - 1];
|
|
4073
|
-
const pathDValue = `m 179.6875,717.73633 c -0.45013,0 -0.8125,0.36237 -0.8125,0.8125 l 0,8.46289 a 2.3125,2.3125 0 0 0 -1.5,2.16211 2.3125,2.3125 0 0 0 2.3125,2.3125 2.3125,2.3125 0 0 0 2.3125,-2.3125 2.3125,2.3125 0 0 0 -1.5,-2.16211 l 0,-8.46289 c 0,-0.45013 -0.36237,-0.8125 -0.8125,-0.8125 z`;
|
|
4074
|
-
const { rectProps, rectRef, svgViewBox, pathX, pathY } = useCustomWidget({
|
|
4075
|
-
currentValue: value,
|
|
4076
|
-
maxValue: domainMax,
|
|
4077
|
-
minValue: baseValue,
|
|
4078
|
-
panelId
|
|
4079
|
-
});
|
|
4080
|
-
const boxValues = {
|
|
4081
|
-
height: noNaN(Math.max(width, height) - Math.max(width, height) * 0.31),
|
|
4082
|
-
width: noNaN(Math.max(width, height)),
|
|
4083
|
-
x: pathX,
|
|
4084
|
-
y: pathY
|
|
4085
|
-
};
|
|
4086
|
-
const tickArray = valueRanges.map((val, i) => {
|
|
4087
|
-
return {
|
|
4088
|
-
height: boxValues.height * (valueToTickPercent(domainMax, baseValue, val) / 100),
|
|
4089
|
-
color: !valueRanges[i + 1] ? "black" : colorGetter(valueRanges, colorRanges, val),
|
|
4090
|
-
value: val
|
|
4091
|
-
};
|
|
4092
|
-
});
|
|
4093
|
-
return /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
|
|
4094
|
-
/* @__PURE__ */ jsxs(
|
|
4095
|
-
"svg",
|
|
4096
|
-
{
|
|
4097
|
-
height: Math.max(width, height),
|
|
4098
|
-
width: Math.max(width, height),
|
|
4099
|
-
id: `svg_${panelId}`,
|
|
4100
|
-
viewBox: svgViewBox,
|
|
4101
|
-
style: { position: "relative", top: "10px" },
|
|
4102
|
-
children: [
|
|
4103
|
-
/* @__PURE__ */ jsx("clipPath", { id: "clipPath", children: /* @__PURE__ */ jsx("path", { d: pathDValue }) }),
|
|
4104
|
-
/* @__PURE__ */ jsx("mask", { id: "myMask", children: /* @__PURE__ */ jsx("path", { d: pathDValue, id: "maskPath", fill: "white" }) }),
|
|
4105
|
-
/* @__PURE__ */ jsx("path", { d: pathDValue, id: `path_${panelId}`, fill: "white" }),
|
|
4106
|
-
/* @__PURE__ */ jsx(
|
|
4107
|
-
"rect",
|
|
4108
|
-
__spreadValues$1({
|
|
4109
|
-
fill: getInnerColor(valueRanges, colorRanges, value),
|
|
4110
|
-
id: `rect_${panelId}`,
|
|
4111
|
-
mask: "url(#myMask)",
|
|
4112
|
-
ref: rectRef
|
|
4113
|
-
}, rectProps)
|
|
4114
|
-
),
|
|
4115
|
-
/* @__PURE__ */ jsx(
|
|
4116
|
-
"path",
|
|
4117
|
-
{
|
|
4118
|
-
d: pathDValue,
|
|
4119
|
-
id: "path",
|
|
4120
|
-
fill: "none",
|
|
4121
|
-
stroke: "white",
|
|
4122
|
-
strokeWidth: 10,
|
|
4123
|
-
clipPath: "url(#clipPath)",
|
|
4124
|
-
vectorEffect: "non-scaling-stroke"
|
|
4125
|
-
}
|
|
4126
|
-
),
|
|
4127
|
-
/* @__PURE__ */ jsx(
|
|
4128
|
-
"path",
|
|
4129
|
-
{
|
|
4130
|
-
clipPath: "url(#clipPath)",
|
|
4131
|
-
d: pathDValue,
|
|
4132
|
-
id: "path",
|
|
4133
|
-
fill: "none",
|
|
4134
|
-
stroke: "black",
|
|
4135
|
-
strokeWidth: 5,
|
|
4136
|
-
vectorEffect: "non-scaling-stroke"
|
|
4137
|
-
}
|
|
4138
|
-
)
|
|
4139
|
-
]
|
|
4140
|
-
}
|
|
4141
|
-
),
|
|
4142
|
-
/* @__PURE__ */ jsxs(
|
|
4143
|
-
"svg",
|
|
4144
|
-
{
|
|
4145
|
-
height: Math.max(width, height) + 10,
|
|
4146
|
-
width: Math.max(width, height),
|
|
4147
|
-
style: { position: "absolute", left: 0, top: 0 },
|
|
4148
|
-
children: [
|
|
4149
|
-
boxValues.x && /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
4150
|
-
"text",
|
|
4151
|
-
{
|
|
4152
|
-
x: Math.max(width, height) / 2,
|
|
4153
|
-
y: Math.max(width, height) - Math.max(width, height) / 6 + 10,
|
|
4154
|
-
style: {
|
|
4155
|
-
fontSize: `${(_c = noNaN(currentValueFontSize)) != null ? _c : 50}px`
|
|
4156
|
-
},
|
|
4157
|
-
textAnchor: "middle",
|
|
4158
|
-
alignmentBaseline: "central",
|
|
4159
|
-
vectorEffect: "non-scaling-stroke",
|
|
4160
|
-
children: value
|
|
4161
|
-
}
|
|
4162
|
-
) }),
|
|
4163
|
-
tickArray.map((tick, i) => {
|
|
4164
|
-
return /* @__PURE__ */ jsxs("g", { children: [
|
|
4165
|
-
/* @__PURE__ */ jsx(
|
|
4166
|
-
"rect",
|
|
4167
|
-
{
|
|
4168
|
-
x: i === 0 ? Math.max(width, height) / 2 + 30 : Math.max(width, height) / 2 + 20,
|
|
4169
|
-
y: tick.height + 10,
|
|
4170
|
-
width: "15px",
|
|
4171
|
-
height: "3px",
|
|
4172
|
-
vectorEffect: "non-scaling-stroke",
|
|
4173
|
-
fill: getColor(valueRanges, colorRanges, tick.value)
|
|
4174
|
-
}
|
|
4175
|
-
),
|
|
4176
|
-
/* @__PURE__ */ jsx(
|
|
4177
|
-
"text",
|
|
4178
|
-
{
|
|
4179
|
-
x: i === 0 ? Math.max(width, height) - Math.max(width, height) / 3 + 10 : Math.max(width, height) - Math.max(width, height) / 3,
|
|
4180
|
-
y: tickArray[i + 1] ? tick.height + 16 : tick.height + 1.5,
|
|
4181
|
-
textAnchor: "middle",
|
|
4182
|
-
alignmentBaseline: tickArray[i + 1] ? "auto" : "text-before-edge",
|
|
4183
|
-
children: tick.value
|
|
4184
|
-
}
|
|
4185
|
-
)
|
|
4186
|
-
] }, i);
|
|
4187
|
-
})
|
|
4188
|
-
]
|
|
4189
|
-
}
|
|
4190
|
-
)
|
|
4191
|
-
] });
|
|
4192
|
-
};
|
|
4193
|
-
|
|
4194
|
-
var __defProp = Object.defineProperty;
|
|
4195
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4196
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4197
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
4198
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4199
|
-
var __spreadValues = (a, b) => {
|
|
4200
|
-
for (var prop in b || (b = {}))
|
|
4201
|
-
if (__hasOwnProp.call(b, prop))
|
|
4202
|
-
__defNormalProp(a, prop, b[prop]);
|
|
4203
|
-
if (__getOwnPropSymbols)
|
|
4204
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
4205
|
-
if (__propIsEnum.call(b, prop))
|
|
4206
|
-
__defNormalProp(a, prop, b[prop]);
|
|
4207
|
-
}
|
|
4208
|
-
return a;
|
|
4209
|
-
};
|
|
4210
|
-
const WidgetContainer = ({
|
|
4211
|
-
data,
|
|
4212
|
-
id
|
|
4213
|
-
}) => {
|
|
4214
|
-
const realData = __spreadValues({}, data);
|
|
4215
|
-
const valueRanges = Array.from(
|
|
4216
|
-
new Set(
|
|
4217
|
-
arrayOrArray(realData.zones.Zone).map((zone) => {
|
|
4218
|
-
return [Number(zone.minimum), Number(zone.maximum)];
|
|
4219
|
-
}).flat().sort((a, b) => a - b)
|
|
4220
|
-
)
|
|
4221
|
-
);
|
|
4222
|
-
const colorRanges = arrayOrArray(realData.zones.Zone).map((zone) => {
|
|
4223
|
-
return tinycolor(zone.color).setAlpha(1 - (255 - zone.transparency) / 255).toPercentageRgbString();
|
|
4224
|
-
}).flat();
|
|
4225
|
-
const CurrentWidget = getIndex(
|
|
4226
|
-
[SpeedMeter, Oxford, Counter, TLight, Thermometer, Scale, Ring],
|
|
4227
|
-
[
|
|
4228
|
-
realData.widKpiType === "1",
|
|
4229
|
-
realData.widKpiType === "2",
|
|
4230
|
-
realData.widKpiType === "3",
|
|
4231
|
-
realData.widKpiType === "4",
|
|
4232
|
-
realData.widKpiType === "5",
|
|
4233
|
-
realData.widKpiType === "6",
|
|
4234
|
-
realData.widKpiType === "7"
|
|
4235
|
-
],
|
|
4236
|
-
0
|
|
4237
|
-
);
|
|
4238
|
-
return /* @__PURE__ */ jsx(
|
|
4239
|
-
CurrentWidget,
|
|
4240
|
-
{
|
|
4241
|
-
addBorder: realData.border,
|
|
4242
|
-
backgroundColor: realData.backgroundColor,
|
|
4243
|
-
colorRanges,
|
|
4244
|
-
currentValue: Number(realData.currentValue),
|
|
4245
|
-
decimals: realData.valueDecimals,
|
|
4246
|
-
currentValueColor: realData.valueColor,
|
|
4247
|
-
currentValueFontSize: realData.valueFontSize,
|
|
4248
|
-
forceProp: realData.forceProp,
|
|
4249
|
-
height: realData.height,
|
|
4250
|
-
panelId: id,
|
|
4251
|
-
maxValue: realData.maxValue,
|
|
4252
|
-
minValue: realData.minValue,
|
|
4253
|
-
pointerColor: realData.pointerColor,
|
|
4254
|
-
ringEmptyColor: realData.noValueColor,
|
|
4255
|
-
ringWidth: realData.ringAnchor,
|
|
4256
|
-
scaleValuesSize: realData.scaleFontSize,
|
|
4257
|
-
valueRanges,
|
|
4258
|
-
width: realData.width
|
|
4259
|
-
}
|
|
4260
|
-
);
|
|
4261
|
-
};
|
|
4262
|
-
|
|
4263
|
-
export { ChartRenderer, EmptyGrid, WidgetContainer };
|
|
1
|
+
export { ChartRenderer } from './charts/ChartRenderer.js';
|
|
2
|
+
export { EmptyGrid } from './charts/util/EmptyGrid.js';
|
|
3
|
+
export { WidgetContainer } from './widgets/WidgetContainer.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|