@apia/charts 0.3.2 → 0.3.4
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/index.d.ts +19 -11
- package/dist/index.js +570 -420
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import React, { createContext,
|
|
3
|
-
import { Box, useThemeUI,
|
|
2
|
+
import React, { useCallback, createContext, useState, useRef, useContext, useMemo, useLayoutEffect, createElement, useEffect } from 'react';
|
|
3
|
+
import { Box, useThemeUI, Heading, Select, spacing, makeStyledComponent, responsive, getVariant } from '@apia/theme';
|
|
4
4
|
import { uniqueId } from 'lodash';
|
|
5
|
-
import { makeImperativeComponent, arrayOrArray, useImperativeComponentEvents, getValueByPath, usePanAndZoom, animate, addBoundary, usePrevious, getIndex, noNaN } from '@apia/util';
|
|
5
|
+
import { useImperativeComponentContext, makeImperativeComponent, arrayOrArray, useImperativeComponentEvents, getValueByPath, usePanAndZoom, animate, addBoundary, usePrevious, getIndex, noNaN } from '@apia/util';
|
|
6
6
|
import { scaleBand, scaleLog, scaleLinear, scaleOrdinal } from '@visx/scale';
|
|
7
7
|
import { Grid } from '@visx/visx';
|
|
8
8
|
import { Group } from '@visx/group';
|
|
9
9
|
import { BarGroupHorizontal, BarGroup, LinePath, Line } from '@visx/shape';
|
|
10
10
|
import { AxisLeft, AxisBottom } from '@visx/axis';
|
|
11
|
-
import { usePanelParametersSelector, usePanelIdentity } from '@apia/dashboard';
|
|
12
11
|
import tinycolor from 'tinycolor2';
|
|
13
12
|
import { localPoint } from '@visx/event';
|
|
14
13
|
import { SimpleButton, useTooltip } from '@apia/components';
|
|
15
14
|
import { icons } from '@apia/icons';
|
|
15
|
+
import { ApiaUtil } from '@apia/objects';
|
|
16
16
|
import Pie from '@visx/shape/lib/shapes/Pie';
|
|
17
17
|
import { min, max, extent } from 'd3-array';
|
|
18
18
|
import * as allCurves from '@visx/curve';
|
|
@@ -29,8 +29,6 @@ function parseMargin(margin = {
|
|
|
29
29
|
return typeof margin === "number" ? { left: margin, right: margin, top: margin, bottom: margin } : margin;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const ChartContext = createContext({});
|
|
33
|
-
|
|
34
32
|
const ColoredLegendItem = ({
|
|
35
33
|
groupId,
|
|
36
34
|
title,
|
|
@@ -40,7 +38,7 @@ const ColoredLegendItem = ({
|
|
|
40
38
|
isAnyHighlighted,
|
|
41
39
|
avoidEvent
|
|
42
40
|
}) => {
|
|
43
|
-
const { chartId } =
|
|
41
|
+
const { id: chartId } = useImperativeComponentContext();
|
|
44
42
|
const handleMouseEnter = useCallback(() => {
|
|
45
43
|
if (avoidEvent) {
|
|
46
44
|
return;
|
|
@@ -51,6 +49,7 @@ const ColoredLegendItem = ({
|
|
|
51
49
|
if (avoidEvent) {
|
|
52
50
|
return;
|
|
53
51
|
}
|
|
52
|
+
new ApiaUtil().tooltips.close();
|
|
54
53
|
chartMethods(chartId, "highlight", "");
|
|
55
54
|
}, [avoidEvent, chartId]);
|
|
56
55
|
return /* @__PURE__ */ jsx(
|
|
@@ -76,7 +75,7 @@ const NumberedLegendItem = ({
|
|
|
76
75
|
isAnyHighlighted,
|
|
77
76
|
avoidEvent
|
|
78
77
|
}) => {
|
|
79
|
-
const { chartId } =
|
|
78
|
+
const { id: chartId } = useImperativeComponentContext();
|
|
80
79
|
const handleMouseEnter = useCallback(() => {
|
|
81
80
|
if (avoidEvent) {
|
|
82
81
|
return;
|
|
@@ -87,6 +86,7 @@ const NumberedLegendItem = ({
|
|
|
87
86
|
if (avoidEvent) {
|
|
88
87
|
return;
|
|
89
88
|
}
|
|
89
|
+
new ApiaUtil().tooltips.close();
|
|
90
90
|
chartMethods(chartId, "highlight", "");
|
|
91
91
|
}, [avoidEvent, chartId]);
|
|
92
92
|
return /* @__PURE__ */ jsx(
|
|
@@ -150,6 +150,8 @@ const [legendContainerMethods, , LegendContainer] = makeImperativeComponent()({
|
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
|
|
153
|
+
const ChartContext = createContext({});
|
|
154
|
+
|
|
153
155
|
const Bar$1 = ({
|
|
154
156
|
bar,
|
|
155
157
|
barGroup,
|
|
@@ -167,32 +169,66 @@ const Bar$1 = ({
|
|
|
167
169
|
)) == null ? void 0 : _a.color;
|
|
168
170
|
const [isHighlighted, setIsHighlighted] = useState(false);
|
|
169
171
|
const [isAnyHighlighted, setIsAnyHighlighted] = useState(false);
|
|
170
|
-
const
|
|
171
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
172
|
-
/* @__PURE__ */ jsx(
|
|
173
|
-
"div",
|
|
174
|
-
{
|
|
175
|
-
style: {
|
|
176
|
-
color: currentBarColor
|
|
177
|
-
},
|
|
178
|
-
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
179
|
-
}
|
|
180
|
-
),
|
|
181
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
182
|
-
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
183
|
-
] })
|
|
184
|
-
});
|
|
172
|
+
const ref = useRef(null);
|
|
185
173
|
useImperativeComponentEvents({
|
|
186
|
-
highlight(
|
|
174
|
+
highlight(barNameColumn) {
|
|
175
|
+
let barName = barNameColumn;
|
|
176
|
+
let columnName = "";
|
|
177
|
+
if (barNameColumn.includes("_$_")) {
|
|
178
|
+
barName = barNameColumn.split("_$_")[0];
|
|
179
|
+
columnName = barNameColumn.split("_$_")[1];
|
|
180
|
+
if (isSingle && barNameColumn !== "" && barNameColumn !== void 0) {
|
|
181
|
+
barName = barNameColumn.split("_$_")[1];
|
|
182
|
+
columnName = barNameColumn.split("_$_")[1];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
187
185
|
if (barName.split(" - ").length === 1) {
|
|
188
186
|
if (arrayOrArray(chart.dataSets.data).length === 1) {
|
|
189
187
|
setIsHighlighted(barName === parsedData[barGroup.index].columnName);
|
|
190
188
|
setIsAnyHighlighted(
|
|
191
189
|
barName !== parsedData[barGroup.index].columnName && barName !== ""
|
|
192
190
|
);
|
|
191
|
+
if (barName === parsedData[barGroup.index].columnName && columnName === parsedData[barGroup.index].columnName) {
|
|
192
|
+
new ApiaUtil().tooltips.open({
|
|
193
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
194
|
+
/* @__PURE__ */ jsx(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
style: {
|
|
198
|
+
color: currentBarColor
|
|
199
|
+
},
|
|
200
|
+
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
201
|
+
}
|
|
202
|
+
),
|
|
203
|
+
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
204
|
+
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
205
|
+
] }),
|
|
206
|
+
attachToElement: () => ref.current,
|
|
207
|
+
attachToElementAnchorPoint: "center"
|
|
208
|
+
});
|
|
209
|
+
}
|
|
193
210
|
} else {
|
|
194
211
|
setIsHighlighted(barName === bar.key);
|
|
195
212
|
setIsAnyHighlighted(barName !== bar.key && barName !== "");
|
|
213
|
+
if (barName === bar.key && columnName === parsedData[barGroup.index].columnName) {
|
|
214
|
+
new ApiaUtil().tooltips.open({
|
|
215
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
216
|
+
/* @__PURE__ */ jsx(
|
|
217
|
+
"div",
|
|
218
|
+
{
|
|
219
|
+
style: {
|
|
220
|
+
color: currentBarColor
|
|
221
|
+
},
|
|
222
|
+
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
223
|
+
}
|
|
224
|
+
),
|
|
225
|
+
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
226
|
+
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
227
|
+
] }),
|
|
228
|
+
attachToElement: () => ref.current,
|
|
229
|
+
attachToElementAnchorPoint: "center"
|
|
230
|
+
});
|
|
231
|
+
}
|
|
196
232
|
}
|
|
197
233
|
} else if (barName.split(" - ").length === 2) {
|
|
198
234
|
setIsHighlighted(
|
|
@@ -201,12 +237,31 @@ const Bar$1 = ({
|
|
|
201
237
|
setIsAnyHighlighted(
|
|
202
238
|
barName.split(" - ")[0] !== bar.key && barName.split(" - ")[0] !== ""
|
|
203
239
|
);
|
|
240
|
+
if (barName.split(" - ")[0] === bar.key && barName.split(" - ")[1] === set.key && columnName === parsedData[barGroup.index].columnName) {
|
|
241
|
+
new ApiaUtil().tooltips.open({
|
|
242
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
243
|
+
/* @__PURE__ */ jsx(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
style: {
|
|
247
|
+
color: currentBarColor
|
|
248
|
+
},
|
|
249
|
+
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
250
|
+
}
|
|
251
|
+
),
|
|
252
|
+
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
253
|
+
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
254
|
+
] }),
|
|
255
|
+
attachToElement: () => ref.current,
|
|
256
|
+
attachToElementAnchorPoint: "center"
|
|
257
|
+
});
|
|
258
|
+
}
|
|
204
259
|
}
|
|
205
260
|
}
|
|
206
261
|
});
|
|
207
262
|
const { chartId } = useContext(ChartContext);
|
|
208
263
|
return /* @__PURE__ */ jsxs("g", { children: [
|
|
209
|
-
/* @__PURE__ */
|
|
264
|
+
/* @__PURE__ */ jsx(
|
|
210
265
|
"text",
|
|
211
266
|
{
|
|
212
267
|
x: bar.x + 5,
|
|
@@ -219,11 +274,7 @@ const Bar$1 = ({
|
|
|
219
274
|
opacity: isHighlighted ? 1 : 0,
|
|
220
275
|
transition: "opacity 500ms"
|
|
221
276
|
},
|
|
222
|
-
children:
|
|
223
|
-
bar.value,
|
|
224
|
-
" - ",
|
|
225
|
-
parsedData[barGroup.index].columnName
|
|
226
|
-
]
|
|
277
|
+
children: bar.value
|
|
227
278
|
}
|
|
228
279
|
),
|
|
229
280
|
/* @__PURE__ */ jsx(
|
|
@@ -231,6 +282,7 @@ const Bar$1 = ({
|
|
|
231
282
|
{
|
|
232
283
|
as: "rect",
|
|
233
284
|
className: "chart__barRect",
|
|
285
|
+
ref,
|
|
234
286
|
sx: useMemo(
|
|
235
287
|
() => ({
|
|
236
288
|
fill: isAnyHighlighted ? `#${tinycolor(currentBarColor).desaturate(70).toHex()}` : currentBarColor,
|
|
@@ -260,23 +312,25 @@ const Bar$1 = ({
|
|
|
260
312
|
if (!isSingle) {
|
|
261
313
|
legendContainerMethods.highlight(chartId, bar.key);
|
|
262
314
|
}
|
|
315
|
+
chartMethods(
|
|
316
|
+
chartId,
|
|
317
|
+
"highlight",
|
|
318
|
+
`${bar.key}_$_${parsedData[barGroup.index].columnName}`
|
|
319
|
+
);
|
|
263
320
|
(_a2 = ev.target.classList) == null ? void 0 : _a2.add("over");
|
|
264
321
|
const point = {
|
|
265
322
|
x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
|
|
266
323
|
y: (_c = localPoint(ev)) == null ? void 0 : _c.y
|
|
267
324
|
};
|
|
268
|
-
if (!point)
|
|
325
|
+
if (!point || !chart.showValues)
|
|
269
326
|
return;
|
|
270
|
-
open({
|
|
271
|
-
attachToElement: () => ev.target,
|
|
272
|
-
attachToElementAnchorPoint: "center"
|
|
273
|
-
});
|
|
274
327
|
},
|
|
275
328
|
onMouseLeave: (ev) => {
|
|
276
329
|
var _a2;
|
|
277
330
|
if (!isSingle) {
|
|
278
331
|
legendContainerMethods.highlight(chartId, "");
|
|
279
332
|
}
|
|
333
|
+
chartMethods(chartId, "highlight", "");
|
|
280
334
|
(_a2 = ev.target.classList) == null ? void 0 : _a2.remove("over");
|
|
281
335
|
},
|
|
282
336
|
children: /* @__PURE__ */ jsx(
|
|
@@ -351,7 +405,7 @@ function useChartStyles(schemeName) {
|
|
|
351
405
|
schema: getValueByPath(
|
|
352
406
|
theme.colors,
|
|
353
407
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
354
|
-
(_c = charts[schemeName
|
|
408
|
+
(_c = charts[schemeName && schemeName !== "0" ? schemeName : "blue"]) == null ? void 0 : _c.schema
|
|
355
409
|
)
|
|
356
410
|
};
|
|
357
411
|
if (typeof currentStylescheme.schema === "object" && currentStylescheme.schema) {
|
|
@@ -494,16 +548,11 @@ const HorizontalBars = ({
|
|
|
494
548
|
domain: columnNames,
|
|
495
549
|
range: columnas.map((col) => col.color)
|
|
496
550
|
});
|
|
497
|
-
const
|
|
498
|
-
return global;
|
|
499
|
-
});
|
|
500
|
-
const scale = parameters.PRMT_CHART_SCALE;
|
|
501
|
-
const isLogScale = scale === "0";
|
|
551
|
+
const isLogScale = false;
|
|
502
552
|
const xScale = useMemo(() => {
|
|
503
|
-
|
|
553
|
+
{
|
|
504
554
|
return xScaleLine;
|
|
505
555
|
}
|
|
506
|
-
return xScaleLog;
|
|
507
556
|
}, [isLogScale, xScaleLine, xScaleLog]);
|
|
508
557
|
const id = useMemo(() => `HorizontalBars${uniqueId()}`, []);
|
|
509
558
|
useLayoutEffect(() => {
|
|
@@ -619,7 +668,7 @@ const HorizontalBars = ({
|
|
|
619
668
|
{
|
|
620
669
|
ref: boxRef,
|
|
621
670
|
id,
|
|
622
|
-
className: `${outerClassName != null ? outerClassName : ""} ${chartId} ${chart.title} chartBox`,
|
|
671
|
+
className: `${outerClassName != null ? outerClassName : ""} ${chartId} ${chart.title} chartBox chartContainer`,
|
|
623
672
|
sx: React.useMemo(() => {
|
|
624
673
|
return {
|
|
625
674
|
[`.__${chartId != null ? chartId : outerClassName}`]: {
|
|
@@ -707,6 +756,7 @@ const HorizontalBars = ({
|
|
|
707
756
|
scale: yScale,
|
|
708
757
|
left: effectiveMargin.left,
|
|
709
758
|
label: chart.chartType !== "pie2D" && chart.showAxisYTitle ? chart.axisYTitle : "",
|
|
759
|
+
labelOffset: 10,
|
|
710
760
|
tickLabelProps: () => ({
|
|
711
761
|
display: "none"
|
|
712
762
|
})
|
|
@@ -721,7 +771,7 @@ const HorizontalBars = ({
|
|
|
721
771
|
tickLabelProps: {
|
|
722
772
|
className: "tickLabel"
|
|
723
773
|
},
|
|
724
|
-
labelOffset:
|
|
774
|
+
labelOffset: 30
|
|
725
775
|
}
|
|
726
776
|
)
|
|
727
777
|
]
|
|
@@ -729,20 +779,23 @@ const HorizontalBars = ({
|
|
|
729
779
|
)
|
|
730
780
|
}
|
|
731
781
|
),
|
|
732
|
-
colorReference.length !== 0 && /* @__PURE__ */
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
782
|
+
/* @__PURE__ */ jsx(Box, { className: "chartLegend__Wrapper", children: chart.showLegend && colorReference.length !== 0 && /* @__PURE__ */ jsxs(Box, { className: "chart__legend__wrapper", children: [
|
|
783
|
+
/* @__PURE__ */ jsx(Heading, { as: "h6", children: "Legend" }),
|
|
784
|
+
/* @__PURE__ */ jsx(
|
|
785
|
+
LegendContainer,
|
|
786
|
+
{
|
|
787
|
+
id: chartId,
|
|
788
|
+
references: (
|
|
789
|
+
// hideLegendsColors
|
|
790
|
+
// ? colorReference.map((ref) => {
|
|
791
|
+
// return { ...ref, color: 'transparent' };
|
|
792
|
+
// })
|
|
793
|
+
colorReference.length === 1 && numberReference.length > 0 ? numberReference : colorReference
|
|
794
|
+
),
|
|
795
|
+
useNumbered: colorReference.length === 1
|
|
796
|
+
}
|
|
797
|
+
)
|
|
798
|
+
] }) })
|
|
746
799
|
] });
|
|
747
800
|
};
|
|
748
801
|
|
|
@@ -750,36 +803,53 @@ const Slice = ({
|
|
|
750
803
|
arc,
|
|
751
804
|
arcPath,
|
|
752
805
|
chart,
|
|
753
|
-
actualColor
|
|
806
|
+
actualColor,
|
|
807
|
+
chartId: outerChartId
|
|
754
808
|
}) => {
|
|
755
809
|
const [isHighlighted, setIsHighlighted] = useState(false);
|
|
756
810
|
const [isAnyHighlighted, setIsAnyHighlighted] = useState(false);
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
"div",
|
|
761
|
-
{
|
|
762
|
-
style: {
|
|
763
|
-
color: `#${tinycolor(actualColor).toHex()}`
|
|
764
|
-
},
|
|
765
|
-
children: /* @__PURE__ */ jsx("strong", { children: arc.data.key })
|
|
766
|
-
}
|
|
767
|
-
),
|
|
768
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: `${arc.value} ${arc.data.percentage ? "- " + arc.data.percentage : ""}${arc.data.percentage ? "%" : ""}` })
|
|
769
|
-
] })
|
|
770
|
-
});
|
|
811
|
+
const ref = useRef(null);
|
|
812
|
+
const name = arc.data;
|
|
813
|
+
const { id: chartId } = useImperativeComponentContext();
|
|
771
814
|
useImperativeComponentEvents({
|
|
772
|
-
highlight(
|
|
815
|
+
highlight(barNameId) {
|
|
816
|
+
const barName = barNameId.split("_$_")[0];
|
|
773
817
|
setIsHighlighted(barName === arc.data.key);
|
|
774
818
|
setIsAnyHighlighted(barName !== arc.data.key && barName !== "");
|
|
819
|
+
if (barName === arc.data.key) {
|
|
820
|
+
new ApiaUtil().tooltips.open({
|
|
821
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
822
|
+
/* @__PURE__ */ jsx(
|
|
823
|
+
"div",
|
|
824
|
+
{
|
|
825
|
+
style: {
|
|
826
|
+
color: `#${tinycolor(actualColor).toHex()}`
|
|
827
|
+
},
|
|
828
|
+
children: /* @__PURE__ */ jsx("strong", { children: arc.data.key })
|
|
829
|
+
}
|
|
830
|
+
),
|
|
831
|
+
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 ? "%" : ""}` })
|
|
832
|
+
] }),
|
|
833
|
+
attachToElement: () => {
|
|
834
|
+
return ref.current;
|
|
835
|
+
},
|
|
836
|
+
attachToElementAnchorPoint: "center",
|
|
837
|
+
closeOnClickOut: () => {
|
|
838
|
+
return window.innerWidth > 700;
|
|
839
|
+
},
|
|
840
|
+
closeOnMouseLeaveAttachedElement: (ev) => {
|
|
841
|
+
return !ev.relatedTarget.closest(".legendItem");
|
|
842
|
+
},
|
|
843
|
+
className: arc.data.key
|
|
844
|
+
});
|
|
845
|
+
}
|
|
775
846
|
}
|
|
776
847
|
});
|
|
777
|
-
const { chartId } = useContext(ChartContext);
|
|
778
|
-
const name = arc.data;
|
|
779
848
|
return /* @__PURE__ */ jsx(
|
|
780
849
|
"path",
|
|
781
850
|
{
|
|
782
|
-
id: `arc-${name.key}-${name.value}`,
|
|
851
|
+
id: `arc-${name.key}-${name.value}-${outerChartId}`,
|
|
852
|
+
ref,
|
|
783
853
|
style: useMemo(
|
|
784
854
|
() => ({
|
|
785
855
|
"&:hover": {
|
|
@@ -789,12 +859,14 @@ const Slice = ({
|
|
|
789
859
|
}),
|
|
790
860
|
[actualColor]
|
|
791
861
|
),
|
|
862
|
+
color: isAnyHighlighted ? `#${tinycolor(actualColor).desaturate(70).toHex()}` : actualColor,
|
|
792
863
|
fill: isAnyHighlighted ? `#${tinycolor(actualColor).desaturate(70).toHex()}` : actualColor,
|
|
793
864
|
opacity: isAnyHighlighted && !isHighlighted ? 0.15 : 1,
|
|
794
865
|
d: arcPath != null ? arcPath : "",
|
|
795
866
|
onMouseEnter: (ev) => {
|
|
796
867
|
var _a, _b, _c;
|
|
797
868
|
legendContainerMethods.highlight(chartId, arc.data.key);
|
|
869
|
+
chartMethods(chartId, "highlight", `${name.key}_$_${outerChartId}`);
|
|
798
870
|
(_a = ev.target.classList) == null ? void 0 : _a.add("over");
|
|
799
871
|
const point = {
|
|
800
872
|
x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
|
|
@@ -802,47 +874,15 @@ const Slice = ({
|
|
|
802
874
|
};
|
|
803
875
|
if (!point)
|
|
804
876
|
return;
|
|
805
|
-
open({
|
|
806
|
-
attachToElement: () => ev.target,
|
|
807
|
-
attachToElementAnchorPoint: "center"
|
|
808
|
-
});
|
|
809
877
|
},
|
|
810
878
|
onMouseLeave: (ev) => {
|
|
811
879
|
var _a;
|
|
812
880
|
legendContainerMethods.highlight(chartId, "");
|
|
881
|
+
chartMethods(chartId, "highlight", "");
|
|
813
882
|
(_a = ev.target.classList) == null ? void 0 : _a.remove("over");
|
|
814
883
|
}
|
|
815
884
|
},
|
|
816
|
-
`arc-${name.key}-${name.value}`
|
|
817
|
-
);
|
|
818
|
-
};
|
|
819
|
-
|
|
820
|
-
const TextSlice = ({
|
|
821
|
-
arc,
|
|
822
|
-
x,
|
|
823
|
-
y,
|
|
824
|
-
dy
|
|
825
|
-
}) => {
|
|
826
|
-
const [isHighlighted, setIsHighlighted] = useState(false);
|
|
827
|
-
useImperativeComponentEvents({
|
|
828
|
-
highlight(barName) {
|
|
829
|
-
setIsHighlighted(barName === arc.data.key);
|
|
830
|
-
}
|
|
831
|
-
});
|
|
832
|
-
return /* @__PURE__ */ jsx(
|
|
833
|
-
"text",
|
|
834
|
-
{
|
|
835
|
-
textAnchor: "middle",
|
|
836
|
-
style: {
|
|
837
|
-
opacity: isHighlighted ? 1 : 0,
|
|
838
|
-
display: isHighlighted ? "block" : "none",
|
|
839
|
-
transition: "opacity 500ms"
|
|
840
|
-
},
|
|
841
|
-
x,
|
|
842
|
-
y,
|
|
843
|
-
dy,
|
|
844
|
-
children: arc.value
|
|
845
|
-
}
|
|
885
|
+
`arc-${name.key}-${name.value}-${outerChartId}`
|
|
846
886
|
);
|
|
847
887
|
};
|
|
848
888
|
|
|
@@ -894,7 +934,8 @@ const usePieAnimation = ({
|
|
|
894
934
|
key: coord2.key,
|
|
895
935
|
color: coord2.color,
|
|
896
936
|
// Assuming color is the same for both coordinates
|
|
897
|
-
value: newValue
|
|
937
|
+
value: newValue,
|
|
938
|
+
percentage: coord2.percentage !== "" && coord2.percentage !== void 0 ? coord2.percentage : void 0
|
|
898
939
|
};
|
|
899
940
|
difference.push(newCoordinate);
|
|
900
941
|
} else if (!coord1 && coord2 && previousCoordinates.length > 0) {
|
|
@@ -903,7 +944,8 @@ const usePieAnimation = ({
|
|
|
903
944
|
key: coord2.key,
|
|
904
945
|
color: coord2.color,
|
|
905
946
|
// Assuming color is the same for both coordinates
|
|
906
|
-
value: newValue
|
|
947
|
+
value: newValue,
|
|
948
|
+
percentage: coord2.percentage !== "" && coord2.percentage !== void 0 ? coord2.percentage : void 0
|
|
907
949
|
};
|
|
908
950
|
difference.push(newCoordinate);
|
|
909
951
|
}
|
|
@@ -948,7 +990,18 @@ const usePieAnimation = ({
|
|
|
948
990
|
coordinate: step.sets,
|
|
949
991
|
name: step.name
|
|
950
992
|
};
|
|
951
|
-
setDataset(
|
|
993
|
+
setDataset((prev) => {
|
|
994
|
+
const newIndex = prev.findIndex((col) => {
|
|
995
|
+
return col.name === step.name;
|
|
996
|
+
});
|
|
997
|
+
const returnObj = [...prev];
|
|
998
|
+
if (newIndex >= 0) {
|
|
999
|
+
returnObj[newIndex] = step;
|
|
1000
|
+
return returnObj;
|
|
1001
|
+
} else {
|
|
1002
|
+
return [step];
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
952
1005
|
},
|
|
953
1006
|
() => {
|
|
954
1007
|
const newPrev = __spreadProps$b(__spreadValues$d({}, incomingColumn), {
|
|
@@ -968,6 +1021,37 @@ const usePieAnimation = ({
|
|
|
968
1021
|
}
|
|
969
1022
|
};
|
|
970
1023
|
|
|
1024
|
+
function ChartSelector({
|
|
1025
|
+
chartId,
|
|
1026
|
+
pieces,
|
|
1027
|
+
className,
|
|
1028
|
+
current,
|
|
1029
|
+
setCurrent
|
|
1030
|
+
}) {
|
|
1031
|
+
return /* @__PURE__ */ jsxs(
|
|
1032
|
+
Select,
|
|
1033
|
+
{
|
|
1034
|
+
sx: { width: "auto" },
|
|
1035
|
+
name: `chartSelector_${chartId}`,
|
|
1036
|
+
className: `chartSelector_${chartId} ${className != null ? className : ""}`,
|
|
1037
|
+
value: current != null ? current : "0",
|
|
1038
|
+
onChange: (ev) => {
|
|
1039
|
+
ev.preventDefault();
|
|
1040
|
+
setCurrent(ev.target.value);
|
|
1041
|
+
},
|
|
1042
|
+
children: [
|
|
1043
|
+
pieces.map((piece, i) => {
|
|
1044
|
+
return {
|
|
1045
|
+
label: piece,
|
|
1046
|
+
value: `${i}`
|
|
1047
|
+
};
|
|
1048
|
+
}).map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value)),
|
|
1049
|
+
" "
|
|
1050
|
+
]
|
|
1051
|
+
}
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
|
|
971
1055
|
var __defProp$c = Object.defineProperty;
|
|
972
1056
|
var __defProps$a = Object.defineProperties;
|
|
973
1057
|
var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
|
|
@@ -1006,19 +1090,20 @@ const PieChart = ({
|
|
|
1006
1090
|
chartId,
|
|
1007
1091
|
allowZoom
|
|
1008
1092
|
}) => {
|
|
1009
|
-
var _a, _b;
|
|
1093
|
+
var _a, _b, _c, _d;
|
|
1010
1094
|
const [dataset, setDataset] = useState(
|
|
1011
1095
|
arrayOrArray((_a = chart.dataSets) == null ? void 0 : _a.data)
|
|
1012
1096
|
);
|
|
1097
|
+
const [currentPie, setCurrentPie] = useState("0");
|
|
1013
1098
|
const piezas = useMemo(() => {
|
|
1014
1099
|
return dataset.filter((piece) => !!piece.sets).map((piece) => {
|
|
1015
1100
|
return __spreadProps$a(__spreadValues$c({}, piece), {
|
|
1016
1101
|
coordinate: piece.sets
|
|
1017
1102
|
});
|
|
1018
|
-
})[0];
|
|
1019
|
-
}, [dataset]);
|
|
1103
|
+
})[dataset[parseInt(currentPie)] ? parseInt(currentPie) : 0];
|
|
1104
|
+
}, [currentPie, dataset]);
|
|
1020
1105
|
usePieAnimation({
|
|
1021
|
-
incomingColumn: arrayOrArray((_b = chart.dataSets) == null ? void 0 : _b.data)[0],
|
|
1106
|
+
incomingColumn: arrayOrArray((_b = chart.dataSets) == null ? void 0 : _b.data)[dataset[parseInt(currentPie)] ? parseInt(currentPie) : 0],
|
|
1022
1107
|
piezas,
|
|
1023
1108
|
setDataset
|
|
1024
1109
|
});
|
|
@@ -1045,7 +1130,9 @@ const PieChart = ({
|
|
|
1045
1130
|
const radius = Math.min(innerHeight, innerWidth) / 2.5;
|
|
1046
1131
|
const styles = useChartStyles(chart.colorSchema);
|
|
1047
1132
|
const colorsArray = styles ? styles.schema : ["#7ad6f4", "#45bdee", "#28a7ea", "#006cbb", "#034698", "#032f64"];
|
|
1048
|
-
const names = arrayOrArray(
|
|
1133
|
+
const names = arrayOrArray(
|
|
1134
|
+
((_c = dataset[parseInt(currentPie)]) != null ? _c : dataset[0]).sets
|
|
1135
|
+
).map((coord) => {
|
|
1049
1136
|
return coord.key;
|
|
1050
1137
|
});
|
|
1051
1138
|
const colorReference = names.map((name, index) => {
|
|
@@ -1059,6 +1146,15 @@ const PieChart = ({
|
|
|
1059
1146
|
!allowZoom
|
|
1060
1147
|
);
|
|
1061
1148
|
const previousPaths = useRef([]);
|
|
1149
|
+
const id = useMemo(() => `Pie${uniqueId()}`, []);
|
|
1150
|
+
const charts = arrayOrArray((_d = chart.dataSets) == null ? void 0 : _d.data).filter((piece) => !!piece.sets).map((piece) => {
|
|
1151
|
+
return __spreadProps$a(__spreadValues$c({}, piece), {
|
|
1152
|
+
coordinate: piece.sets
|
|
1153
|
+
});
|
|
1154
|
+
});
|
|
1155
|
+
const chartNames = charts.map((piece) => {
|
|
1156
|
+
return piece.name;
|
|
1157
|
+
});
|
|
1062
1158
|
if (!piezas) {
|
|
1063
1159
|
return null;
|
|
1064
1160
|
}
|
|
@@ -1067,7 +1163,8 @@ const PieChart = ({
|
|
|
1067
1163
|
Box,
|
|
1068
1164
|
{
|
|
1069
1165
|
ref: boxRef,
|
|
1070
|
-
|
|
1166
|
+
id,
|
|
1167
|
+
className: `${className ? className : ""} ${chartId} chartBox chartContainer`,
|
|
1071
1168
|
sx: { textAlign: "center", pb: spacing(5) },
|
|
1072
1169
|
children: /* @__PURE__ */ jsx(
|
|
1073
1170
|
"svg",
|
|
@@ -1076,74 +1173,64 @@ const PieChart = ({
|
|
|
1076
1173
|
height: radius * 2,
|
|
1077
1174
|
width: radius * 2,
|
|
1078
1175
|
className: `_${chartId} chart__svg`,
|
|
1079
|
-
children: /* @__PURE__ */
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
),
|
|
1113
|
-
/* @__PURE__ */ jsx(
|
|
1114
|
-
Pie,
|
|
1115
|
-
{
|
|
1116
|
-
data: arrayOrArray(piezas.coordinate),
|
|
1117
|
-
pieValue: getValue,
|
|
1118
|
-
pieSort: null,
|
|
1119
|
-
outerRadius: radius,
|
|
1120
|
-
children: (pie) => {
|
|
1121
|
-
return pie.arcs.map((arc) => {
|
|
1122
|
-
const name = arc.data;
|
|
1123
|
-
const angle = (arc.startAngle - Math.PI + arc.endAngle) / 2;
|
|
1124
|
-
const x = Math.cos(angle) * (radius * 0.75);
|
|
1125
|
-
const y = Math.sin(angle) * (radius * 0.75);
|
|
1126
|
-
return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
1127
|
-
TextSlice,
|
|
1128
|
-
{
|
|
1129
|
-
arc,
|
|
1130
|
-
chart,
|
|
1131
|
-
dy: "0.33em",
|
|
1132
|
-
x,
|
|
1133
|
-
y
|
|
1134
|
-
}
|
|
1135
|
-
) }, `arc-${name.key}-${name.value}`);
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1176
|
+
children: /* @__PURE__ */ jsx(Group, { top: top != null ? top : 0, left: left != null ? left : 0, children: /* @__PURE__ */ jsx(
|
|
1177
|
+
Pie,
|
|
1178
|
+
{
|
|
1179
|
+
data: arrayOrArray(piezas.coordinate),
|
|
1180
|
+
pieValue: getValue,
|
|
1181
|
+
pieSort: null,
|
|
1182
|
+
outerRadius: radius,
|
|
1183
|
+
children: (pie) => {
|
|
1184
|
+
const paths = arrayOrArray(pie.arcs).map((arc) => {
|
|
1185
|
+
return pie.path(arc);
|
|
1186
|
+
});
|
|
1187
|
+
const result = pie.arcs.map((arc) => {
|
|
1188
|
+
var _a2, _b2;
|
|
1189
|
+
const name = arc.data;
|
|
1190
|
+
const arcPath = pie.path(arc);
|
|
1191
|
+
return /* @__PURE__ */ jsx(
|
|
1192
|
+
Slice,
|
|
1193
|
+
{
|
|
1194
|
+
arc,
|
|
1195
|
+
chartId: id,
|
|
1196
|
+
arcPath,
|
|
1197
|
+
chart,
|
|
1198
|
+
actualColor: (_b2 = (_a2 = colorReference.find((color) => {
|
|
1199
|
+
return color.title === name.key;
|
|
1200
|
+
})) == null ? void 0 : _a2.color) != null ? _b2 : ""
|
|
1201
|
+
},
|
|
1202
|
+
`${name.key}_${name.value}`
|
|
1203
|
+
);
|
|
1204
|
+
});
|
|
1205
|
+
previousPaths.current = paths;
|
|
1206
|
+
return result;
|
|
1138
1207
|
}
|
|
1139
|
-
|
|
1140
|
-
|
|
1208
|
+
}
|
|
1209
|
+
) })
|
|
1141
1210
|
}
|
|
1142
1211
|
)
|
|
1143
1212
|
},
|
|
1144
1213
|
piezas.name
|
|
1145
1214
|
),
|
|
1146
|
-
|
|
1215
|
+
/* @__PURE__ */ jsxs(Box, { className: "chartLegend__Wrapper", children: [
|
|
1216
|
+
!chart.hideSelector && charts.length > 1 && /* @__PURE__ */ jsxs(Box, { className: "chart__combo__wrapper", children: [
|
|
1217
|
+
/* @__PURE__ */ jsx(Heading, { as: "h6", children: "Chart Selector" }),
|
|
1218
|
+
/* @__PURE__ */ jsx(
|
|
1219
|
+
ChartSelector,
|
|
1220
|
+
{
|
|
1221
|
+
chartId,
|
|
1222
|
+
pieces: chartNames,
|
|
1223
|
+
className: "chartSelectorCombo",
|
|
1224
|
+
current: currentPie,
|
|
1225
|
+
setCurrent: setCurrentPie
|
|
1226
|
+
}
|
|
1227
|
+
)
|
|
1228
|
+
] }),
|
|
1229
|
+
chart.showLegend && colorReference.length > 1 && /* @__PURE__ */ jsxs(Box, { className: "chart__legend__wrapper", children: [
|
|
1230
|
+
/* @__PURE__ */ jsx(Heading, { as: "h6", children: "Legend" }),
|
|
1231
|
+
/* @__PURE__ */ jsx(LegendContainer, { id: chartId, references: colorReference })
|
|
1232
|
+
] })
|
|
1233
|
+
] })
|
|
1147
1234
|
] });
|
|
1148
1235
|
};
|
|
1149
1236
|
|
|
@@ -1163,32 +1250,66 @@ const Bar = ({
|
|
|
1163
1250
|
)) == null ? void 0 : _a.color;
|
|
1164
1251
|
const [isHighlighted, setIsHighlighted] = useState(false);
|
|
1165
1252
|
const [isAnyHighlighted, setIsAnyHighlighted] = useState(false);
|
|
1166
|
-
const
|
|
1167
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1168
|
-
/* @__PURE__ */ jsx(
|
|
1169
|
-
"div",
|
|
1170
|
-
{
|
|
1171
|
-
style: {
|
|
1172
|
-
color: currentBarColor
|
|
1173
|
-
},
|
|
1174
|
-
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
1175
|
-
}
|
|
1176
|
-
),
|
|
1177
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
1178
|
-
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
1179
|
-
] })
|
|
1180
|
-
});
|
|
1253
|
+
const ref = useRef(null);
|
|
1181
1254
|
useImperativeComponentEvents({
|
|
1182
|
-
highlight(
|
|
1255
|
+
highlight(barNameColumn) {
|
|
1256
|
+
let barName = barNameColumn;
|
|
1257
|
+
let columnName = "";
|
|
1258
|
+
if (barNameColumn.includes("_$_")) {
|
|
1259
|
+
barName = barNameColumn.split("_$_")[0];
|
|
1260
|
+
columnName = barNameColumn.split("_$_")[1];
|
|
1261
|
+
if (isSingle && barNameColumn !== "" && barNameColumn !== void 0) {
|
|
1262
|
+
barName = barNameColumn.split("_$_")[1];
|
|
1263
|
+
columnName = barNameColumn.split("_$_")[1];
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1183
1266
|
if (barName.split(" - ").length === 1) {
|
|
1184
1267
|
if (arrayOrArray(chart.dataSets.data).length === 1) {
|
|
1185
1268
|
setIsHighlighted(barName === parsedData[barGroup.index].columnName);
|
|
1186
1269
|
setIsAnyHighlighted(
|
|
1187
1270
|
barName !== parsedData[barGroup.index].columnName && barName !== ""
|
|
1188
1271
|
);
|
|
1272
|
+
if (barName === parsedData[barGroup.index].columnName && columnName === parsedData[barGroup.index].columnName) {
|
|
1273
|
+
new ApiaUtil().tooltips.open({
|
|
1274
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1275
|
+
/* @__PURE__ */ jsx(
|
|
1276
|
+
"div",
|
|
1277
|
+
{
|
|
1278
|
+
style: {
|
|
1279
|
+
color: currentBarColor
|
|
1280
|
+
},
|
|
1281
|
+
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
1282
|
+
}
|
|
1283
|
+
),
|
|
1284
|
+
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
1285
|
+
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
1286
|
+
] }),
|
|
1287
|
+
attachToElement: () => ref.current,
|
|
1288
|
+
attachToElementAnchorPoint: "center"
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1189
1291
|
} else {
|
|
1190
1292
|
setIsHighlighted(barName === bar.key);
|
|
1191
1293
|
setIsAnyHighlighted(barName !== bar.key && barName !== "");
|
|
1294
|
+
if (barName === bar.key && columnName === parsedData[barGroup.index].columnName) {
|
|
1295
|
+
new ApiaUtil().tooltips.open({
|
|
1296
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1297
|
+
/* @__PURE__ */ jsx(
|
|
1298
|
+
"div",
|
|
1299
|
+
{
|
|
1300
|
+
style: {
|
|
1301
|
+
color: currentBarColor
|
|
1302
|
+
},
|
|
1303
|
+
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
1304
|
+
}
|
|
1305
|
+
),
|
|
1306
|
+
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
1307
|
+
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
1308
|
+
] }),
|
|
1309
|
+
attachToElement: () => ref.current,
|
|
1310
|
+
attachToElementAnchorPoint: "center"
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1192
1313
|
}
|
|
1193
1314
|
} else if (barName.split(" - ").length === 2) {
|
|
1194
1315
|
setIsHighlighted(
|
|
@@ -1197,6 +1318,25 @@ const Bar = ({
|
|
|
1197
1318
|
setIsAnyHighlighted(
|
|
1198
1319
|
barName.split(" - ")[0] !== bar.key && barName.split(" - ")[0] !== ""
|
|
1199
1320
|
);
|
|
1321
|
+
if (barName.split(" - ")[0] === bar.key && barName.split(" - ")[1] === set.key && columnName === parsedData[barGroup.index].columnName) {
|
|
1322
|
+
new ApiaUtil().tooltips.open({
|
|
1323
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1324
|
+
/* @__PURE__ */ jsx(
|
|
1325
|
+
"div",
|
|
1326
|
+
{
|
|
1327
|
+
style: {
|
|
1328
|
+
color: currentBarColor
|
|
1329
|
+
},
|
|
1330
|
+
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
1331
|
+
}
|
|
1332
|
+
),
|
|
1333
|
+
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
1334
|
+
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
1335
|
+
] }),
|
|
1336
|
+
attachToElement: () => ref.current,
|
|
1337
|
+
attachToElementAnchorPoint: "center"
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1200
1340
|
}
|
|
1201
1341
|
}
|
|
1202
1342
|
});
|
|
@@ -1223,6 +1363,7 @@ const Bar = ({
|
|
|
1223
1363
|
{
|
|
1224
1364
|
as: "rect",
|
|
1225
1365
|
className: "chart__barRect",
|
|
1366
|
+
ref,
|
|
1226
1367
|
sx: useMemo(
|
|
1227
1368
|
() => ({
|
|
1228
1369
|
fill: isAnyHighlighted ? `#${tinycolor(currentBarColor).desaturate(70).toHex()}` : currentBarColor,
|
|
@@ -1251,23 +1392,25 @@ const Bar = ({
|
|
|
1251
1392
|
if (!isSingle) {
|
|
1252
1393
|
legendContainerMethods.highlight(chartId, bar.key);
|
|
1253
1394
|
}
|
|
1395
|
+
chartMethods(
|
|
1396
|
+
chartId,
|
|
1397
|
+
"highlight",
|
|
1398
|
+
`${bar.key}_$_${parsedData[barGroup.index].columnName}`
|
|
1399
|
+
);
|
|
1254
1400
|
(_a2 = ev.target.classList) == null ? void 0 : _a2.add("over");
|
|
1255
1401
|
const point = {
|
|
1256
1402
|
x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
|
|
1257
1403
|
y: (_c = localPoint(ev)) == null ? void 0 : _c.y
|
|
1258
1404
|
};
|
|
1259
|
-
if (!point)
|
|
1405
|
+
if (!point || !chart.showValues)
|
|
1260
1406
|
return;
|
|
1261
|
-
open({
|
|
1262
|
-
attachToElement: () => ev.target,
|
|
1263
|
-
attachToElementAnchorPoint: "center"
|
|
1264
|
-
});
|
|
1265
1407
|
},
|
|
1266
1408
|
onMouseLeave: (ev) => {
|
|
1267
1409
|
var _a2;
|
|
1268
1410
|
if (!isSingle) {
|
|
1269
1411
|
legendContainerMethods.highlight(chartId, "");
|
|
1270
1412
|
}
|
|
1413
|
+
chartMethods(chartId, "highlight", "");
|
|
1271
1414
|
(_a2 = ev.target.classList) == null ? void 0 : _a2.remove("over");
|
|
1272
1415
|
},
|
|
1273
1416
|
children: [
|
|
@@ -1347,7 +1490,7 @@ const VerticalBars = ({
|
|
|
1347
1490
|
effectiveMargin.left = 50;
|
|
1348
1491
|
}
|
|
1349
1492
|
let innerWidth = chart.ratio.width + (-effectiveMargin.left - effectiveMargin.right) / 2;
|
|
1350
|
-
let innerHeight = chart.ratio.height + (-effectiveMargin.top - effectiveMargin.bottom) / 2;
|
|
1493
|
+
let innerHeight = chart.ratio.height + (chart.showAxisXTitle ? -effectiveMargin.top - effectiveMargin.bottom : (-effectiveMargin.top - effectiveMargin.bottom) / 2);
|
|
1351
1494
|
if (innerWidth > chart.ratio.maxWidth) {
|
|
1352
1495
|
const newValues = adjustDimensions$2({
|
|
1353
1496
|
height: innerHeight,
|
|
@@ -1435,16 +1578,11 @@ const VerticalBars = ({
|
|
|
1435
1578
|
domain: columnNames,
|
|
1436
1579
|
range: columnas.map((col) => col.color)
|
|
1437
1580
|
});
|
|
1438
|
-
const
|
|
1439
|
-
return global;
|
|
1440
|
-
});
|
|
1441
|
-
const scale = parameters.PRMT_CHART_SCALE;
|
|
1442
|
-
const isLogScale = scale === "0";
|
|
1581
|
+
const isLogScale = false;
|
|
1443
1582
|
const yScale = useMemo(() => {
|
|
1444
|
-
|
|
1583
|
+
{
|
|
1445
1584
|
return yScaleLine;
|
|
1446
1585
|
}
|
|
1447
|
-
return yScaleLog;
|
|
1448
1586
|
}, [isLogScale, yScaleLine, yScaleLog]);
|
|
1449
1587
|
const id = useMemo(() => `VerticalBars${uniqueId()}`, []);
|
|
1450
1588
|
useLayoutEffect(() => {
|
|
@@ -1563,7 +1701,7 @@ const VerticalBars = ({
|
|
|
1563
1701
|
{
|
|
1564
1702
|
ref: boxRef,
|
|
1565
1703
|
id,
|
|
1566
|
-
className: `${className != null ? className : ""} ${chart.title} chartBox`,
|
|
1704
|
+
className: `${className != null ? className : ""} ${chart.title} chartBox chartContainer`,
|
|
1567
1705
|
sx: {
|
|
1568
1706
|
overflow: "hidden"
|
|
1569
1707
|
},
|
|
@@ -1676,17 +1814,9 @@ const VerticalBars = ({
|
|
|
1676
1814
|
top: innerHeight,
|
|
1677
1815
|
scale: colorReference.length === 1 && numberReference.length > 0 ? numericXScale : xScale,
|
|
1678
1816
|
label: chart.chartType !== "pie2D" && chart.showAxisXTitle ? chart.axisXTitle : "",
|
|
1679
|
-
tickLabelProps:
|
|
1680
|
-
// colorReference.length === 1 && numberReference.length > 0
|
|
1681
|
-
// ? {}
|
|
1682
|
-
// : {
|
|
1683
|
-
// className: 'tickLabel',
|
|
1684
|
-
// textAnchor: 'start',
|
|
1685
|
-
// }
|
|
1686
|
-
{ display: "none" }
|
|
1687
|
-
),
|
|
1817
|
+
tickLabelProps: { display: "none" },
|
|
1688
1818
|
tickLineProps: { display: "none" },
|
|
1689
|
-
labelOffset:
|
|
1819
|
+
labelOffset: 0
|
|
1690
1820
|
}
|
|
1691
1821
|
)
|
|
1692
1822
|
]
|
|
@@ -1694,20 +1824,17 @@ const VerticalBars = ({
|
|
|
1694
1824
|
)
|
|
1695
1825
|
}
|
|
1696
1826
|
),
|
|
1697
|
-
colorReference.length !== 0 && /* @__PURE__ */
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
useNumbered: colorReference.length === 1
|
|
1709
|
-
}
|
|
1710
|
-
)
|
|
1827
|
+
/* @__PURE__ */ jsx(Box, { className: "chartLegend__Wrapper", children: chart.showLegend && colorReference.length !== 0 && /* @__PURE__ */ jsxs(Box, { className: "chart__legend__wrapper", children: [
|
|
1828
|
+
/* @__PURE__ */ jsx(Heading, { as: "h6", children: "Legend" }),
|
|
1829
|
+
/* @__PURE__ */ jsx(
|
|
1830
|
+
LegendContainer,
|
|
1831
|
+
{
|
|
1832
|
+
id: chartId,
|
|
1833
|
+
references: colorReference.length === 1 && numberReference.length > 0 ? numberReference : colorReference,
|
|
1834
|
+
useNumbered: colorReference.length === 1
|
|
1835
|
+
}
|
|
1836
|
+
)
|
|
1837
|
+
] }) })
|
|
1711
1838
|
] });
|
|
1712
1839
|
};
|
|
1713
1840
|
|
|
@@ -1744,7 +1871,7 @@ const Node = ({
|
|
|
1744
1871
|
/* @__PURE__ */ jsx(
|
|
1745
1872
|
"circle",
|
|
1746
1873
|
{
|
|
1747
|
-
r:
|
|
1874
|
+
r: 6,
|
|
1748
1875
|
cx,
|
|
1749
1876
|
cy,
|
|
1750
1877
|
stroke: "transparent",
|
|
@@ -1801,28 +1928,43 @@ function getY(coordinate) {
|
|
|
1801
1928
|
return Number(coordinate.value);
|
|
1802
1929
|
}
|
|
1803
1930
|
function parseData(chart) {
|
|
1804
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1807
|
-
|
|
1931
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1932
|
+
const setsArray = arrayOrArray((_a = chart.dataSets) == null ? void 0 : _a.data).map(
|
|
1933
|
+
(col) => arrayOrArray(col.sets)
|
|
1934
|
+
);
|
|
1935
|
+
let longestLine = [];
|
|
1936
|
+
let longestLineIndex = -1;
|
|
1937
|
+
for (let i = 0; i < setsArray.length; i++) {
|
|
1938
|
+
const array = setsArray[i];
|
|
1939
|
+
if (!longestLine || array.length > longestLine.length) {
|
|
1940
|
+
longestLine = array;
|
|
1941
|
+
longestLineIndex = i;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
const lines = arrayOrArray((_b = chart.dataSets) == null ? void 0 : _b.data);
|
|
1945
|
+
const nodesDataArray = lines.map((line) => line.sets);
|
|
1946
|
+
const nodesData = nodesDataArray.reduce(
|
|
1808
1947
|
(rec, d) => arrayOrArray(rec).concat(d),
|
|
1809
1948
|
[]
|
|
1810
1949
|
);
|
|
1811
1950
|
return {
|
|
1812
|
-
|
|
1951
|
+
lines,
|
|
1952
|
+
longestLine,
|
|
1953
|
+
longestLineIndex,
|
|
1954
|
+
tallestLine: [...new Set(nodesData.map((value) => value.value))],
|
|
1813
1955
|
xScale: scaleOrdinal({
|
|
1814
|
-
domain:
|
|
1956
|
+
domain: longestLine.map(getX)
|
|
1815
1957
|
}),
|
|
1816
1958
|
yScale: scaleLinear({
|
|
1817
1959
|
domain: [
|
|
1818
|
-
((
|
|
1819
|
-
(
|
|
1960
|
+
((_c = min(nodesData, getY)) != null ? _c : 0) < 0 ? (_d = min(nodesData, getY)) != null ? _d : 0 : 0,
|
|
1961
|
+
(_e = max(nodesData, getY)) != null ? _e : 1
|
|
1820
1962
|
]
|
|
1821
1963
|
}),
|
|
1822
1964
|
yScaleLog: scaleLog({
|
|
1823
1965
|
domain: [
|
|
1824
|
-
((
|
|
1825
|
-
(
|
|
1966
|
+
((_f = min(nodesData, getY)) != null ? _f : 1) > 0 ? (_g = min(nodesData, getY)) != null ? _g : 1 : 1,
|
|
1967
|
+
(_h = max(nodesData, getY)) != null ? _h : 10
|
|
1826
1968
|
]
|
|
1827
1969
|
})
|
|
1828
1970
|
};
|
|
@@ -1848,25 +1990,39 @@ const LineChart = ({
|
|
|
1848
1990
|
innerWidth = newValues.width;
|
|
1849
1991
|
innerHeight = newValues.height;
|
|
1850
1992
|
}
|
|
1851
|
-
const {
|
|
1993
|
+
const { lines, xScale, yScale, yScaleLog, longestLine } = parseData(chart);
|
|
1852
1994
|
const styles = useChartStyles(chart.colorSchema);
|
|
1853
|
-
const coordinates = arrayOrArray(
|
|
1854
|
-
const coordinatesArray =
|
|
1995
|
+
const coordinates = arrayOrArray(lines[0].sets);
|
|
1996
|
+
const coordinatesArray = lines.map((col) => {
|
|
1855
1997
|
return col.sets;
|
|
1856
1998
|
});
|
|
1857
|
-
const
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1999
|
+
const divideRangeBetweenStrings = (min2, max2, strings) => {
|
|
2000
|
+
const numStrings = strings.length;
|
|
2001
|
+
const step = (max2 - min2) / (numStrings - 1);
|
|
2002
|
+
const resultArray = [];
|
|
2003
|
+
let currentValue = min2;
|
|
2004
|
+
for (let i = 0; i < numStrings; i++) {
|
|
2005
|
+
resultArray.push(currentValue);
|
|
2006
|
+
currentValue += step;
|
|
2007
|
+
}
|
|
2008
|
+
return resultArray;
|
|
2009
|
+
};
|
|
2010
|
+
const xScaleRange = useMemo(() => {
|
|
2011
|
+
const rangeArr = [
|
|
2012
|
+
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.left,
|
|
2013
|
+
innerWidth - effectiveMargin.left
|
|
2014
|
+
];
|
|
2015
|
+
return divideRangeBetweenStrings(rangeArr[0], rangeArr[1], longestLine);
|
|
2016
|
+
}, [effectiveMargin, innerWidth, longestLine]);
|
|
2017
|
+
xScale.range(xScaleRange);
|
|
2018
|
+
const yScaleRange = useMemo(() => {
|
|
2019
|
+
const rangeArr = [
|
|
2020
|
+
innerHeight - (effectiveMargin.top + effectiveMargin.bottom) / 2,
|
|
2021
|
+
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top
|
|
2022
|
+
];
|
|
2023
|
+
return rangeArr;
|
|
2024
|
+
}, [effectiveMargin, innerHeight]);
|
|
2025
|
+
yScale.range(yScaleRange);
|
|
1870
2026
|
yScaleLog.range([
|
|
1871
2027
|
innerHeight,
|
|
1872
2028
|
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top
|
|
@@ -1875,7 +2031,7 @@ const LineChart = ({
|
|
|
1875
2031
|
const actualYScale = useMemo(() => {
|
|
1876
2032
|
return yScale;
|
|
1877
2033
|
}, [yScale]);
|
|
1878
|
-
const id = useMemo(() => `
|
|
2034
|
+
const id = useMemo(() => `Linear${uniqueId()}`, []);
|
|
1879
2035
|
useLayoutEffect(() => {
|
|
1880
2036
|
document.querySelectorAll(`#${id} .tickLabel`).forEach((current) => {
|
|
1881
2037
|
const width = current.getBoundingClientRect().width;
|
|
@@ -1890,24 +2046,6 @@ const LineChart = ({
|
|
|
1890
2046
|
return __spreadProps$8(__spreadValues$a({}, object), { columnName: name });
|
|
1891
2047
|
});
|
|
1892
2048
|
}
|
|
1893
|
-
const [nodes, setNodes] = useState([]);
|
|
1894
|
-
useEffect(() => {
|
|
1895
|
-
const coords = coordinatesArray.flat().map((coord) => {
|
|
1896
|
-
return {
|
|
1897
|
-
xValue: coord.key,
|
|
1898
|
-
yValue: coord.value,
|
|
1899
|
-
x: xScale(getX(coord)),
|
|
1900
|
-
y: actualYScale(getY(coord))
|
|
1901
|
-
};
|
|
1902
|
-
});
|
|
1903
|
-
const columnNames = columns.map((column) => {
|
|
1904
|
-
return column.name;
|
|
1905
|
-
});
|
|
1906
|
-
const nodesData = addNameToProps(columnNames, coords, coordinates.length);
|
|
1907
|
-
setNodes(nodesData);
|
|
1908
|
-
}, []);
|
|
1909
|
-
const [nearNodesArray, setNearNodesArray] = useState([]);
|
|
1910
|
-
const previousNearNodesArray = usePrevious(nearNodesArray);
|
|
1911
2049
|
const setsWithColor = arrayOrArray(chart.dataSets.data).map((data, index) => {
|
|
1912
2050
|
const isSingle = arrayOrArray(chart.dataSets.data).length === 1;
|
|
1913
2051
|
const dataColor = data.color !== "" && data.color !== void 0 ? data.color : arrayOrArray(
|
|
@@ -1946,13 +2084,38 @@ const LineChart = ({
|
|
|
1946
2084
|
});
|
|
1947
2085
|
return { returnColumnsArray, columnColor: dataColor };
|
|
1948
2086
|
});
|
|
1949
|
-
const colorReference =
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
2087
|
+
const colorReference = arrayOrArray(chart.dataSets.data).map(
|
|
2088
|
+
(data, index) => {
|
|
2089
|
+
const isSingle = arrayOrArray(chart.dataSets.data).length === 1;
|
|
2090
|
+
const dataColor = data.color !== "" && data.color !== void 0 ? data.color : arrayOrArray(
|
|
2091
|
+
styles ? styles.schema : [
|
|
2092
|
+
"#7ad6f4",
|
|
2093
|
+
"#45bdee",
|
|
2094
|
+
"#28a7ea",
|
|
2095
|
+
"#006cbb",
|
|
2096
|
+
"#034698",
|
|
2097
|
+
"#032f64"
|
|
2098
|
+
]
|
|
2099
|
+
).length > 0 ? getBarColor(
|
|
2100
|
+
arrayOrArray(
|
|
2101
|
+
styles ? styles.schema : [
|
|
2102
|
+
"#7ad6f4",
|
|
2103
|
+
"#45bdee",
|
|
2104
|
+
"#28a7ea",
|
|
2105
|
+
"#006cbb",
|
|
2106
|
+
"#034698",
|
|
2107
|
+
"#032f64"
|
|
2108
|
+
]
|
|
2109
|
+
),
|
|
2110
|
+
index,
|
|
2111
|
+
isSingle
|
|
2112
|
+
) : "";
|
|
2113
|
+
return {
|
|
2114
|
+
color: dataColor,
|
|
2115
|
+
title: data.name
|
|
2116
|
+
};
|
|
2117
|
+
}
|
|
2118
|
+
);
|
|
1956
2119
|
arrayOrArray(chart.dataSets.data).map((data) => {
|
|
1957
2120
|
const returnArray = [];
|
|
1958
2121
|
arrayOrArray(data.sets).forEach((set) => {
|
|
@@ -1965,29 +2128,6 @@ const LineChart = ({
|
|
|
1965
2128
|
});
|
|
1966
2129
|
return returnArray;
|
|
1967
2130
|
}).flat().forEach((addRef) => colorReference.push(addRef));
|
|
1968
|
-
const { open } = useTooltip({
|
|
1969
|
-
children: nearNodesArray.sort((a, b) => Number(b.yValue) - Number(a.yValue)).map((node, i) => {
|
|
1970
|
-
const useSpecific = colorReference.some(
|
|
1971
|
-
(ref) => ref.title === node.columnName + " - " + node.xValue
|
|
1972
|
-
);
|
|
1973
|
-
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
1974
|
-
/* @__PURE__ */ jsx(
|
|
1975
|
-
"div",
|
|
1976
|
-
{
|
|
1977
|
-
style: {
|
|
1978
|
-
color: colorReference[colorReference.findIndex((ref) => {
|
|
1979
|
-
return ref.title === (useSpecific ? node.columnName + " - " + node.xValue : node.columnName);
|
|
1980
|
-
})].color
|
|
1981
|
-
},
|
|
1982
|
-
children: /* @__PURE__ */ jsx("strong", { children: node.columnName })
|
|
1983
|
-
}
|
|
1984
|
-
),
|
|
1985
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: node.yValue }),
|
|
1986
|
-
/* @__PURE__ */ jsx("div", { children: node.xValue }),
|
|
1987
|
-
nearNodesArray[i + 1] && /* @__PURE__ */ jsx("hr", {})
|
|
1988
|
-
] }, `${node.columnName}_${node.xValue}_${node.yValue}`);
|
|
1989
|
-
})
|
|
1990
|
-
});
|
|
1991
2131
|
const [highlightedBar, setHighlightedBar] = useState("");
|
|
1992
2132
|
useImperativeComponentEvents({
|
|
1993
2133
|
highlight(barName) {
|
|
@@ -2002,8 +2142,22 @@ const LineChart = ({
|
|
|
2002
2142
|
void 0,
|
|
2003
2143
|
!allowZoom
|
|
2004
2144
|
);
|
|
2145
|
+
const coords = coordinatesArray.flat().map((coord) => {
|
|
2146
|
+
return {
|
|
2147
|
+
xValue: coord.key,
|
|
2148
|
+
yValue: coord.value,
|
|
2149
|
+
x: xScale(getX(coord)),
|
|
2150
|
+
y: actualYScale(getY(coord))
|
|
2151
|
+
};
|
|
2152
|
+
});
|
|
2153
|
+
const columnNames = lines.map((column) => {
|
|
2154
|
+
return column.name;
|
|
2155
|
+
});
|
|
2156
|
+
const nodes = addNameToProps(columnNames, coords, coordinates.length);
|
|
2157
|
+
const [nearNodesArray, setNearNodesArray] = useState([]);
|
|
2158
|
+
const previousNearNodesArray = usePrevious(nearNodesArray);
|
|
2005
2159
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2006
|
-
/* @__PURE__ */ jsx(Box, { id, ref: boxRef, className: "chartBox", children: /* @__PURE__ */ jsxs(
|
|
2160
|
+
/* @__PURE__ */ jsx(Box, { id, ref: boxRef, className: "chartBox chartContainer", children: /* @__PURE__ */ jsxs(
|
|
2007
2161
|
"svg",
|
|
2008
2162
|
{
|
|
2009
2163
|
ref: elementRef,
|
|
@@ -2014,7 +2168,7 @@ const LineChart = ({
|
|
|
2014
2168
|
onMouseMove: (ev) => {
|
|
2015
2169
|
var _a;
|
|
2016
2170
|
const rect = (_a = elementRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
2017
|
-
let clientX = ev.clientX;
|
|
2171
|
+
let clientX = ev.clientX - (effectiveMargin.left + effectiveMargin.right) / 2;
|
|
2018
2172
|
let clientY = ev.clientY - (effectiveMargin.top + effectiveMargin.bottom) / 2;
|
|
2019
2173
|
if (rect) {
|
|
2020
2174
|
clientX = ev.clientX - rect.left;
|
|
@@ -2024,7 +2178,7 @@ const LineChart = ({
|
|
|
2024
2178
|
return Math.sqrt(__pow(node.x - clientX, 2) + __pow(node.y - clientY, 2)) < 20;
|
|
2025
2179
|
});
|
|
2026
2180
|
if (previousNearNodesArray.current && nearNodes.length > 0) {
|
|
2027
|
-
const currentColumns =
|
|
2181
|
+
const currentColumns = lines.map((col) => {
|
|
2028
2182
|
let colNames = "";
|
|
2029
2183
|
nearNodes.forEach((node) => {
|
|
2030
2184
|
if (col.name === node.columnName) {
|
|
@@ -2043,10 +2197,45 @@ const LineChart = ({
|
|
|
2043
2197
|
setCurrentCircle([...newCircleValues]);
|
|
2044
2198
|
}
|
|
2045
2199
|
setNearNodesArray(nearNodes);
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2200
|
+
const elementUnderCursor = document.elementFromPoint(
|
|
2201
|
+
ev.clientX,
|
|
2202
|
+
ev.clientY
|
|
2203
|
+
);
|
|
2204
|
+
if (elementUnderCursor && elementUnderCursor.tagName === "circle") {
|
|
2205
|
+
new ApiaUtil().tooltips.open({
|
|
2206
|
+
children: nearNodes.sort((a, b) => Number(b.yValue) - Number(a.yValue)).map((node, i) => {
|
|
2207
|
+
const useSpecific = colorReference.some(
|
|
2208
|
+
(ref) => ref.title === node.columnName + " - " + node.xValue
|
|
2209
|
+
);
|
|
2210
|
+
return /* @__PURE__ */ jsxs(
|
|
2211
|
+
Box,
|
|
2212
|
+
{
|
|
2213
|
+
children: [
|
|
2214
|
+
/* @__PURE__ */ jsx(
|
|
2215
|
+
"div",
|
|
2216
|
+
{
|
|
2217
|
+
style: {
|
|
2218
|
+
color: colorReference[colorReference.findIndex((ref) => {
|
|
2219
|
+
return ref.title === (useSpecific ? node.columnName + " - " + node.xValue : node.columnName);
|
|
2220
|
+
})].color
|
|
2221
|
+
},
|
|
2222
|
+
children: /* @__PURE__ */ jsx("strong", { children: node.columnName })
|
|
2223
|
+
}
|
|
2224
|
+
),
|
|
2225
|
+
chart.showValues && /* @__PURE__ */ jsx("div", { children: node.yValue }),
|
|
2226
|
+
/* @__PURE__ */ jsx("div", { children: node.xValue }),
|
|
2227
|
+
nearNodesArray[i + 1] && /* @__PURE__ */ jsx("hr", {})
|
|
2228
|
+
]
|
|
2229
|
+
},
|
|
2230
|
+
`${node.columnName}_${node.xValue}_${node.yValue}`
|
|
2231
|
+
);
|
|
2232
|
+
}),
|
|
2233
|
+
attachToElement: () => elementUnderCursor,
|
|
2234
|
+
attachToElementAnchorPoint: "bottomRight"
|
|
2235
|
+
});
|
|
2236
|
+
} else {
|
|
2237
|
+
new ApiaUtil().tooltips.close();
|
|
2238
|
+
}
|
|
2050
2239
|
} else if (nearNodes.length === 0) {
|
|
2051
2240
|
setCurrentCircle([]);
|
|
2052
2241
|
}
|
|
@@ -2065,7 +2254,7 @@ const LineChart = ({
|
|
|
2065
2254
|
strokeOpacity: styles == null ? void 0 : styles.grid.opacity
|
|
2066
2255
|
}
|
|
2067
2256
|
),
|
|
2068
|
-
|
|
2257
|
+
lines.map((column, i) => {
|
|
2069
2258
|
var _a;
|
|
2070
2259
|
const currentCoordinates = arrayOrArray(column.sets);
|
|
2071
2260
|
const newColor = (_a = setsWithColor.find(
|
|
@@ -2096,7 +2285,8 @@ const LineChart = ({
|
|
|
2096
2285
|
stroke: newColor != null ? newColor : "black",
|
|
2097
2286
|
strokeWidth: 2,
|
|
2098
2287
|
strokeOpacity: 1,
|
|
2099
|
-
shapeRendering: "geometricPrecision"
|
|
2288
|
+
shapeRendering: "geometricPrecision",
|
|
2289
|
+
color: "transparent"
|
|
2100
2290
|
}
|
|
2101
2291
|
),
|
|
2102
2292
|
currentCoordinates.map((coordinate, j) => {
|
|
@@ -2163,41 +2353,13 @@ const LineChart = ({
|
|
|
2163
2353
|
]
|
|
2164
2354
|
}
|
|
2165
2355
|
) }),
|
|
2166
|
-
colorReference.length
|
|
2356
|
+
/* @__PURE__ */ jsx(Box, { className: "chartLegend__Wrapper", children: chart.showLegend && colorReference.length !== 0 && /* @__PURE__ */ jsxs(Box, { className: "chart__legend__wrapper", children: [
|
|
2357
|
+
/* @__PURE__ */ jsx(Heading, { as: "h6", children: "Legend" }),
|
|
2358
|
+
/* @__PURE__ */ jsx(LegendContainer, { id: chartId, references: colorReference })
|
|
2359
|
+
] }) })
|
|
2167
2360
|
] });
|
|
2168
2361
|
};
|
|
2169
2362
|
|
|
2170
|
-
function ChartSelector({
|
|
2171
|
-
chartId,
|
|
2172
|
-
pieces,
|
|
2173
|
-
className,
|
|
2174
|
-
current,
|
|
2175
|
-
setCurrent
|
|
2176
|
-
}) {
|
|
2177
|
-
return /* @__PURE__ */ jsxs(
|
|
2178
|
-
Select,
|
|
2179
|
-
{
|
|
2180
|
-
sx: { width: "auto" },
|
|
2181
|
-
name: `chartSelector_${chartId}`,
|
|
2182
|
-
className: `chartSelector_${chartId} ${className != null ? className : ""}`,
|
|
2183
|
-
value: current != null ? current : "0",
|
|
2184
|
-
onChange: (ev) => {
|
|
2185
|
-
ev.preventDefault();
|
|
2186
|
-
setCurrent(ev.target.value);
|
|
2187
|
-
},
|
|
2188
|
-
children: [
|
|
2189
|
-
pieces.map((piece, i) => {
|
|
2190
|
-
return {
|
|
2191
|
-
label: piece,
|
|
2192
|
-
value: `${i}`
|
|
2193
|
-
};
|
|
2194
|
-
}).map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value)),
|
|
2195
|
-
" "
|
|
2196
|
-
]
|
|
2197
|
-
}
|
|
2198
|
-
);
|
|
2199
|
-
}
|
|
2200
|
-
|
|
2201
2363
|
const WaterfallBar = ({
|
|
2202
2364
|
width,
|
|
2203
2365
|
height,
|
|
@@ -2425,7 +2587,7 @@ const WaterfallBars = (_a) => {
|
|
|
2425
2587
|
nice: true,
|
|
2426
2588
|
range: [innerHeight, 0]
|
|
2427
2589
|
});
|
|
2428
|
-
const id = useMemo(() => `
|
|
2590
|
+
const id = useMemo(() => `WaterfallBars${uniqueId()}`, []);
|
|
2429
2591
|
useLayoutEffect(() => {
|
|
2430
2592
|
document.querySelectorAll(`#${id} .tickLabel`).forEach((current) => {
|
|
2431
2593
|
const width = current.getBoundingClientRect().width;
|
|
@@ -2438,21 +2600,11 @@ const WaterfallBars = (_a) => {
|
|
|
2438
2600
|
!allowZoom
|
|
2439
2601
|
);
|
|
2440
2602
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2441
|
-
charts.length > 1 && /* @__PURE__ */ jsx(Box, { className: "chart__combo__wrapper", children: /* @__PURE__ */ jsx(
|
|
2442
|
-
ChartSelector,
|
|
2443
|
-
{
|
|
2444
|
-
chartId,
|
|
2445
|
-
pieces: chartNames,
|
|
2446
|
-
className: "chartSelectorCombo",
|
|
2447
|
-
current: currentPie,
|
|
2448
|
-
setCurrent: setCurrentPie
|
|
2449
|
-
}
|
|
2450
|
-
) }),
|
|
2451
2603
|
/* @__PURE__ */ jsx(
|
|
2452
2604
|
Box,
|
|
2453
2605
|
{
|
|
2454
2606
|
id,
|
|
2455
|
-
className: `${className ? className : ""} chartBox`,
|
|
2607
|
+
className: `${className ? className : ""} chartBox chartContainer`,
|
|
2456
2608
|
ref: boxRef,
|
|
2457
2609
|
children: /* @__PURE__ */ jsx(
|
|
2458
2610
|
"svg",
|
|
@@ -2541,19 +2693,19 @@ const WaterfallBars = (_a) => {
|
|
|
2541
2693
|
)
|
|
2542
2694
|
}
|
|
2543
2695
|
),
|
|
2544
|
-
/* @__PURE__ */ jsx(
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
)
|
|
2696
|
+
/* @__PURE__ */ jsx(Box, { className: "chartLegend__Wrapper", children: !chart.hideSelector && charts.length > 1 && /* @__PURE__ */ jsxs(Box, { className: "chart__combo__wrapper", children: [
|
|
2697
|
+
/* @__PURE__ */ jsx(Heading, { as: "h6", children: "Chart Selector" }),
|
|
2698
|
+
/* @__PURE__ */ jsx(
|
|
2699
|
+
ChartSelector,
|
|
2700
|
+
{
|
|
2701
|
+
chartId,
|
|
2702
|
+
pieces: chartNames,
|
|
2703
|
+
className: "chartSelectorCombo",
|
|
2704
|
+
current: currentPie,
|
|
2705
|
+
setCurrent: setCurrentPie
|
|
2706
|
+
}
|
|
2707
|
+
)
|
|
2708
|
+
] }) })
|
|
2557
2709
|
] });
|
|
2558
2710
|
};
|
|
2559
2711
|
|
|
@@ -2645,11 +2797,13 @@ const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
|
|
|
2645
2797
|
lineHeight: "1em"
|
|
2646
2798
|
}
|
|
2647
2799
|
},
|
|
2648
|
-
".chartBox": {
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2800
|
+
".chartBox": () => {
|
|
2801
|
+
return {
|
|
2802
|
+
position: responsive({ 0: "static", 3: "sticky" }),
|
|
2803
|
+
top: "0",
|
|
2804
|
+
background: "white",
|
|
2805
|
+
zIndex: "1"
|
|
2806
|
+
};
|
|
2653
2807
|
},
|
|
2654
2808
|
".legendContainer": {
|
|
2655
2809
|
display: "flex",
|
|
@@ -2667,9 +2821,6 @@ const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
|
|
|
2667
2821
|
}
|
|
2668
2822
|
})
|
|
2669
2823
|
},
|
|
2670
|
-
".chart__combo__wrapper": {
|
|
2671
|
-
position: "absolute"
|
|
2672
|
-
},
|
|
2673
2824
|
".legendItem": {
|
|
2674
2825
|
transition: "opacity 200ms",
|
|
2675
2826
|
"&.isBlurred": {
|
|
@@ -2690,14 +2841,19 @@ const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
|
|
|
2690
2841
|
({
|
|
2691
2842
|
currentChart,
|
|
2692
2843
|
chartId,
|
|
2693
|
-
allowZoom
|
|
2844
|
+
allowZoom,
|
|
2845
|
+
id
|
|
2694
2846
|
}, ref) => {
|
|
2695
2847
|
const innerRef = React.useRef(null);
|
|
2696
2848
|
const setRefs = useMultipleRefs(
|
|
2697
2849
|
ref,
|
|
2698
2850
|
innerRef
|
|
2699
2851
|
);
|
|
2700
|
-
const
|
|
2852
|
+
const { id: imperativeId } = useImperativeComponentContext();
|
|
2853
|
+
const contextValue = useMemo(
|
|
2854
|
+
() => ({ chartId: String(imperativeId) }),
|
|
2855
|
+
[imperativeId]
|
|
2856
|
+
);
|
|
2701
2857
|
const CurrentChart = getIndex(
|
|
2702
2858
|
[PieChart, HorizontalBars, VerticalBars, LineChart, WaterfallBars],
|
|
2703
2859
|
[
|
|
@@ -2715,13 +2871,15 @@ const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
|
|
|
2715
2871
|
ref: setRefs,
|
|
2716
2872
|
className: "chart__chartRenderer"
|
|
2717
2873
|
}, getVariant("layout.charts")), {
|
|
2874
|
+
id,
|
|
2718
2875
|
children: /* @__PURE__ */ jsx(
|
|
2719
2876
|
CurrentChart,
|
|
2720
2877
|
{
|
|
2721
2878
|
chart: currentChart,
|
|
2722
2879
|
chartId,
|
|
2723
2880
|
parentRef: innerRef,
|
|
2724
|
-
allowZoom
|
|
2881
|
+
allowZoom,
|
|
2882
|
+
margin: currentChart.margin
|
|
2725
2883
|
}
|
|
2726
2884
|
)
|
|
2727
2885
|
})
|
|
@@ -3542,9 +3700,7 @@ const Counter = ({
|
|
|
3542
3700
|
addBorder = false,
|
|
3543
3701
|
colorRanges,
|
|
3544
3702
|
currentValue,
|
|
3545
|
-
height,
|
|
3546
3703
|
valueRanges,
|
|
3547
|
-
width,
|
|
3548
3704
|
maxValue,
|
|
3549
3705
|
minValue,
|
|
3550
3706
|
currentValueFontSize,
|
|
@@ -3552,8 +3708,8 @@ const Counter = ({
|
|
|
3552
3708
|
}) => {
|
|
3553
3709
|
var _a, _b;
|
|
3554
3710
|
const [value, setValue] = useState(currentValue != null ? currentValue : 0);
|
|
3555
|
-
const
|
|
3556
|
-
const
|
|
3711
|
+
const actualWidth = (currentValueFontSize != null ? currentValueFontSize : 80) * 3 * 0.8;
|
|
3712
|
+
const diameter = actualWidth;
|
|
3557
3713
|
const domainMax = (_a = noNaN(maxValue)) != null ? _a : valueRanges[valueRanges.length - 1];
|
|
3558
3714
|
const domainMin = (_b = noNaN(minValue)) != null ? _b : valueRanges[0];
|
|
3559
3715
|
const gauge = useGauge({
|
|
@@ -3589,51 +3745,43 @@ const Counter = ({
|
|
|
3589
3745
|
}
|
|
3590
3746
|
);
|
|
3591
3747
|
}, [currentValue]);
|
|
3592
|
-
const widgetContainer = document.querySelector(".widgetContainer__Counter");
|
|
3593
|
-
let actualWidth = width;
|
|
3594
|
-
if (widgetContainer) {
|
|
3595
|
-
const box = widgetContainer.getBoundingClientRect();
|
|
3596
|
-
if (box.width < actualWidth) {
|
|
3597
|
-
actualWidth = box.width;
|
|
3598
|
-
}
|
|
3599
|
-
}
|
|
3600
3748
|
return /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, className: "widgetContainer__Counter", children: [
|
|
3601
3749
|
/* @__PURE__ */ jsx(
|
|
3602
3750
|
"svg",
|
|
3603
3751
|
__spreadProps$1(__spreadValues$3({}, gauge.getSVGProps()), {
|
|
3604
|
-
height,
|
|
3752
|
+
height: actualWidth,
|
|
3605
3753
|
width: actualWidth,
|
|
3606
|
-
viewBox:
|
|
3607
|
-
children: /* @__PURE__ */ jsx("g", { id: "arcs", children: addBorder && /* @__PURE__ */ jsx(
|
|
3608
|
-
"
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3754
|
+
viewBox: void 0,
|
|
3755
|
+
children: /* @__PURE__ */ jsx("g", { id: "arcs", children: addBorder && `${value}`.length < 4 && /* @__PURE__ */ jsx(
|
|
3756
|
+
"ellipse",
|
|
3757
|
+
{
|
|
3758
|
+
cx: actualWidth / 2,
|
|
3759
|
+
cy: actualWidth / 2,
|
|
3760
|
+
rx: actualWidth / 2 - 5,
|
|
3761
|
+
ry: actualWidth / 2 - 5,
|
|
3614
3762
|
stroke: "gray",
|
|
3615
3763
|
opacity: "0.2",
|
|
3616
3764
|
fill: "none",
|
|
3617
3765
|
strokeLinecap: "round",
|
|
3618
3766
|
strokeWidth: 2
|
|
3619
|
-
}
|
|
3767
|
+
}
|
|
3620
3768
|
) })
|
|
3621
3769
|
})
|
|
3622
3770
|
),
|
|
3623
3771
|
/* @__PURE__ */ jsx(
|
|
3624
3772
|
"svg",
|
|
3625
3773
|
{
|
|
3626
|
-
height,
|
|
3774
|
+
height: actualWidth,
|
|
3627
3775
|
width: actualWidth,
|
|
3628
3776
|
style: { position: "absolute", left: 0, top: 0 },
|
|
3629
3777
|
children: /* @__PURE__ */ jsx(
|
|
3630
3778
|
"text",
|
|
3631
3779
|
{
|
|
3632
3780
|
x: actualWidth / 2,
|
|
3633
|
-
y:
|
|
3781
|
+
y: actualWidth / 2 - 5,
|
|
3634
3782
|
textAnchor: "middle",
|
|
3635
3783
|
style: {
|
|
3636
|
-
fontSize: `${currentValueFontSize != null ? currentValueFontSize :
|
|
3784
|
+
fontSize: `${currentValueFontSize != null ? currentValueFontSize : 80}px`,
|
|
3637
3785
|
transition: "fill 0.5s"
|
|
3638
3786
|
},
|
|
3639
3787
|
alignmentBaseline: "central",
|
|
@@ -4043,7 +4191,10 @@ var __spreadValues = (a, b) => {
|
|
|
4043
4191
|
}
|
|
4044
4192
|
return a;
|
|
4045
4193
|
};
|
|
4046
|
-
const WidgetContainer = ({
|
|
4194
|
+
const WidgetContainer = ({
|
|
4195
|
+
data,
|
|
4196
|
+
id
|
|
4197
|
+
}) => {
|
|
4047
4198
|
const realData = __spreadValues({}, data);
|
|
4048
4199
|
const valueRanges = Array.from(
|
|
4049
4200
|
new Set(
|
|
@@ -4068,8 +4219,7 @@ const WidgetContainer = ({ data }) => {
|
|
|
4068
4219
|
],
|
|
4069
4220
|
0
|
|
4070
4221
|
);
|
|
4071
|
-
|
|
4072
|
-
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
4222
|
+
return /* @__PURE__ */ jsx(
|
|
4073
4223
|
CurrentWidget,
|
|
4074
4224
|
{
|
|
4075
4225
|
addBorder: realData.border,
|
|
@@ -4081,7 +4231,7 @@ const WidgetContainer = ({ data }) => {
|
|
|
4081
4231
|
currentValueFontSize: realData.valueFontSize,
|
|
4082
4232
|
forceProp: realData.forceProp,
|
|
4083
4233
|
height: realData.height,
|
|
4084
|
-
panelId:
|
|
4234
|
+
panelId: id,
|
|
4085
4235
|
maxValue: realData.maxValue,
|
|
4086
4236
|
minValue: realData.minValue,
|
|
4087
4237
|
pointerColor: realData.pointerColor,
|
|
@@ -4091,7 +4241,7 @@ const WidgetContainer = ({ data }) => {
|
|
|
4091
4241
|
valueRanges,
|
|
4092
4242
|
width: realData.width
|
|
4093
4243
|
}
|
|
4094
|
-
)
|
|
4244
|
+
);
|
|
4095
4245
|
};
|
|
4096
4246
|
|
|
4097
4247
|
export { ChartRenderer, EmptyGrid, WidgetContainer };
|