@apia/charts 0.3.3 → 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/LICENSE.md +20 -20
- package/dist/index.d.ts +18 -10
- package/dist/index.js +549 -391
- 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 !== void 0 ? "- " + arc.data.percentage : ""}${arc.data.percentage !== "" && arc.data.percentage !== void 0 ? "%" : ""}` })
|
|
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
|
|
|
@@ -950,7 +990,18 @@ const usePieAnimation = ({
|
|
|
950
990
|
coordinate: step.sets,
|
|
951
991
|
name: step.name
|
|
952
992
|
};
|
|
953
|
-
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
|
+
});
|
|
954
1005
|
},
|
|
955
1006
|
() => {
|
|
956
1007
|
const newPrev = __spreadProps$b(__spreadValues$d({}, incomingColumn), {
|
|
@@ -970,6 +1021,37 @@ const usePieAnimation = ({
|
|
|
970
1021
|
}
|
|
971
1022
|
};
|
|
972
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
|
+
|
|
973
1055
|
var __defProp$c = Object.defineProperty;
|
|
974
1056
|
var __defProps$a = Object.defineProperties;
|
|
975
1057
|
var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
|
|
@@ -1008,19 +1090,20 @@ const PieChart = ({
|
|
|
1008
1090
|
chartId,
|
|
1009
1091
|
allowZoom
|
|
1010
1092
|
}) => {
|
|
1011
|
-
var _a, _b;
|
|
1093
|
+
var _a, _b, _c, _d;
|
|
1012
1094
|
const [dataset, setDataset] = useState(
|
|
1013
1095
|
arrayOrArray((_a = chart.dataSets) == null ? void 0 : _a.data)
|
|
1014
1096
|
);
|
|
1097
|
+
const [currentPie, setCurrentPie] = useState("0");
|
|
1015
1098
|
const piezas = useMemo(() => {
|
|
1016
1099
|
return dataset.filter((piece) => !!piece.sets).map((piece) => {
|
|
1017
1100
|
return __spreadProps$a(__spreadValues$c({}, piece), {
|
|
1018
1101
|
coordinate: piece.sets
|
|
1019
1102
|
});
|
|
1020
|
-
})[0];
|
|
1021
|
-
}, [dataset]);
|
|
1103
|
+
})[dataset[parseInt(currentPie)] ? parseInt(currentPie) : 0];
|
|
1104
|
+
}, [currentPie, dataset]);
|
|
1022
1105
|
usePieAnimation({
|
|
1023
|
-
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],
|
|
1024
1107
|
piezas,
|
|
1025
1108
|
setDataset
|
|
1026
1109
|
});
|
|
@@ -1047,7 +1130,9 @@ const PieChart = ({
|
|
|
1047
1130
|
const radius = Math.min(innerHeight, innerWidth) / 2.5;
|
|
1048
1131
|
const styles = useChartStyles(chart.colorSchema);
|
|
1049
1132
|
const colorsArray = styles ? styles.schema : ["#7ad6f4", "#45bdee", "#28a7ea", "#006cbb", "#034698", "#032f64"];
|
|
1050
|
-
const names = arrayOrArray(
|
|
1133
|
+
const names = arrayOrArray(
|
|
1134
|
+
((_c = dataset[parseInt(currentPie)]) != null ? _c : dataset[0]).sets
|
|
1135
|
+
).map((coord) => {
|
|
1051
1136
|
return coord.key;
|
|
1052
1137
|
});
|
|
1053
1138
|
const colorReference = names.map((name, index) => {
|
|
@@ -1061,6 +1146,15 @@ const PieChart = ({
|
|
|
1061
1146
|
!allowZoom
|
|
1062
1147
|
);
|
|
1063
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
|
+
});
|
|
1064
1158
|
if (!piezas) {
|
|
1065
1159
|
return null;
|
|
1066
1160
|
}
|
|
@@ -1069,7 +1163,8 @@ const PieChart = ({
|
|
|
1069
1163
|
Box,
|
|
1070
1164
|
{
|
|
1071
1165
|
ref: boxRef,
|
|
1072
|
-
|
|
1166
|
+
id,
|
|
1167
|
+
className: `${className ? className : ""} ${chartId} chartBox chartContainer`,
|
|
1073
1168
|
sx: { textAlign: "center", pb: spacing(5) },
|
|
1074
1169
|
children: /* @__PURE__ */ jsx(
|
|
1075
1170
|
"svg",
|
|
@@ -1078,74 +1173,64 @@ const PieChart = ({
|
|
|
1078
1173
|
height: radius * 2,
|
|
1079
1174
|
width: radius * 2,
|
|
1080
1175
|
className: `_${chartId} chart__svg`,
|
|
1081
|
-
children: /* @__PURE__ */
|
|
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
|
-
}
|
|
1114
|
-
),
|
|
1115
|
-
/* @__PURE__ */ jsx(
|
|
1116
|
-
Pie,
|
|
1117
|
-
{
|
|
1118
|
-
data: arrayOrArray(piezas.coordinate),
|
|
1119
|
-
pieValue: getValue,
|
|
1120
|
-
pieSort: null,
|
|
1121
|
-
outerRadius: radius,
|
|
1122
|
-
children: (pie) => {
|
|
1123
|
-
return pie.arcs.map((arc) => {
|
|
1124
|
-
const name = arc.data;
|
|
1125
|
-
const angle = (arc.startAngle - Math.PI + arc.endAngle) / 2;
|
|
1126
|
-
const x = Math.cos(angle) * (radius * 0.75);
|
|
1127
|
-
const y = Math.sin(angle) * (radius * 0.75);
|
|
1128
|
-
return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
1129
|
-
TextSlice,
|
|
1130
|
-
{
|
|
1131
|
-
arc,
|
|
1132
|
-
chart,
|
|
1133
|
-
dy: "0.33em",
|
|
1134
|
-
x,
|
|
1135
|
-
y
|
|
1136
|
-
}
|
|
1137
|
-
) }, `arc-${name.key}-${name.value}`);
|
|
1138
|
-
});
|
|
1139
|
-
}
|
|
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;
|
|
1140
1207
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1208
|
+
}
|
|
1209
|
+
) })
|
|
1143
1210
|
}
|
|
1144
1211
|
)
|
|
1145
1212
|
},
|
|
1146
1213
|
piezas.name
|
|
1147
1214
|
),
|
|
1148
|
-
|
|
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
|
+
] })
|
|
1149
1234
|
] });
|
|
1150
1235
|
};
|
|
1151
1236
|
|
|
@@ -1165,32 +1250,66 @@ const Bar = ({
|
|
|
1165
1250
|
)) == null ? void 0 : _a.color;
|
|
1166
1251
|
const [isHighlighted, setIsHighlighted] = useState(false);
|
|
1167
1252
|
const [isAnyHighlighted, setIsAnyHighlighted] = useState(false);
|
|
1168
|
-
const
|
|
1169
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1170
|
-
/* @__PURE__ */ jsx(
|
|
1171
|
-
"div",
|
|
1172
|
-
{
|
|
1173
|
-
style: {
|
|
1174
|
-
color: currentBarColor
|
|
1175
|
-
},
|
|
1176
|
-
children: /* @__PURE__ */ jsx("strong", { children: parsedData[barGroup.index].columnName })
|
|
1177
|
-
}
|
|
1178
|
-
),
|
|
1179
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: bar.value }),
|
|
1180
|
-
/* @__PURE__ */ jsx("div", { children: bar.key })
|
|
1181
|
-
] })
|
|
1182
|
-
});
|
|
1253
|
+
const ref = useRef(null);
|
|
1183
1254
|
useImperativeComponentEvents({
|
|
1184
|
-
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
|
+
}
|
|
1185
1266
|
if (barName.split(" - ").length === 1) {
|
|
1186
1267
|
if (arrayOrArray(chart.dataSets.data).length === 1) {
|
|
1187
1268
|
setIsHighlighted(barName === parsedData[barGroup.index].columnName);
|
|
1188
1269
|
setIsAnyHighlighted(
|
|
1189
1270
|
barName !== parsedData[barGroup.index].columnName && barName !== ""
|
|
1190
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
|
+
}
|
|
1191
1291
|
} else {
|
|
1192
1292
|
setIsHighlighted(barName === bar.key);
|
|
1193
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
|
+
}
|
|
1194
1313
|
}
|
|
1195
1314
|
} else if (barName.split(" - ").length === 2) {
|
|
1196
1315
|
setIsHighlighted(
|
|
@@ -1199,6 +1318,25 @@ const Bar = ({
|
|
|
1199
1318
|
setIsAnyHighlighted(
|
|
1200
1319
|
barName.split(" - ")[0] !== bar.key && barName.split(" - ")[0] !== ""
|
|
1201
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
|
+
}
|
|
1202
1340
|
}
|
|
1203
1341
|
}
|
|
1204
1342
|
});
|
|
@@ -1225,6 +1363,7 @@ const Bar = ({
|
|
|
1225
1363
|
{
|
|
1226
1364
|
as: "rect",
|
|
1227
1365
|
className: "chart__barRect",
|
|
1366
|
+
ref,
|
|
1228
1367
|
sx: useMemo(
|
|
1229
1368
|
() => ({
|
|
1230
1369
|
fill: isAnyHighlighted ? `#${tinycolor(currentBarColor).desaturate(70).toHex()}` : currentBarColor,
|
|
@@ -1253,23 +1392,25 @@ const Bar = ({
|
|
|
1253
1392
|
if (!isSingle) {
|
|
1254
1393
|
legendContainerMethods.highlight(chartId, bar.key);
|
|
1255
1394
|
}
|
|
1395
|
+
chartMethods(
|
|
1396
|
+
chartId,
|
|
1397
|
+
"highlight",
|
|
1398
|
+
`${bar.key}_$_${parsedData[barGroup.index].columnName}`
|
|
1399
|
+
);
|
|
1256
1400
|
(_a2 = ev.target.classList) == null ? void 0 : _a2.add("over");
|
|
1257
1401
|
const point = {
|
|
1258
1402
|
x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
|
|
1259
1403
|
y: (_c = localPoint(ev)) == null ? void 0 : _c.y
|
|
1260
1404
|
};
|
|
1261
|
-
if (!point)
|
|
1405
|
+
if (!point || !chart.showValues)
|
|
1262
1406
|
return;
|
|
1263
|
-
open({
|
|
1264
|
-
attachToElement: () => ev.target,
|
|
1265
|
-
attachToElementAnchorPoint: "center"
|
|
1266
|
-
});
|
|
1267
1407
|
},
|
|
1268
1408
|
onMouseLeave: (ev) => {
|
|
1269
1409
|
var _a2;
|
|
1270
1410
|
if (!isSingle) {
|
|
1271
1411
|
legendContainerMethods.highlight(chartId, "");
|
|
1272
1412
|
}
|
|
1413
|
+
chartMethods(chartId, "highlight", "");
|
|
1273
1414
|
(_a2 = ev.target.classList) == null ? void 0 : _a2.remove("over");
|
|
1274
1415
|
},
|
|
1275
1416
|
children: [
|
|
@@ -1349,7 +1490,7 @@ const VerticalBars = ({
|
|
|
1349
1490
|
effectiveMargin.left = 50;
|
|
1350
1491
|
}
|
|
1351
1492
|
let innerWidth = chart.ratio.width + (-effectiveMargin.left - effectiveMargin.right) / 2;
|
|
1352
|
-
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);
|
|
1353
1494
|
if (innerWidth > chart.ratio.maxWidth) {
|
|
1354
1495
|
const newValues = adjustDimensions$2({
|
|
1355
1496
|
height: innerHeight,
|
|
@@ -1437,16 +1578,11 @@ const VerticalBars = ({
|
|
|
1437
1578
|
domain: columnNames,
|
|
1438
1579
|
range: columnas.map((col) => col.color)
|
|
1439
1580
|
});
|
|
1440
|
-
const
|
|
1441
|
-
return global;
|
|
1442
|
-
});
|
|
1443
|
-
const scale = parameters.PRMT_CHART_SCALE;
|
|
1444
|
-
const isLogScale = scale === "0";
|
|
1581
|
+
const isLogScale = false;
|
|
1445
1582
|
const yScale = useMemo(() => {
|
|
1446
|
-
|
|
1583
|
+
{
|
|
1447
1584
|
return yScaleLine;
|
|
1448
1585
|
}
|
|
1449
|
-
return yScaleLog;
|
|
1450
1586
|
}, [isLogScale, yScaleLine, yScaleLog]);
|
|
1451
1587
|
const id = useMemo(() => `VerticalBars${uniqueId()}`, []);
|
|
1452
1588
|
useLayoutEffect(() => {
|
|
@@ -1565,7 +1701,7 @@ const VerticalBars = ({
|
|
|
1565
1701
|
{
|
|
1566
1702
|
ref: boxRef,
|
|
1567
1703
|
id,
|
|
1568
|
-
className: `${className != null ? className : ""} ${chart.title} chartBox`,
|
|
1704
|
+
className: `${className != null ? className : ""} ${chart.title} chartBox chartContainer`,
|
|
1569
1705
|
sx: {
|
|
1570
1706
|
overflow: "hidden"
|
|
1571
1707
|
},
|
|
@@ -1678,17 +1814,9 @@ const VerticalBars = ({
|
|
|
1678
1814
|
top: innerHeight,
|
|
1679
1815
|
scale: colorReference.length === 1 && numberReference.length > 0 ? numericXScale : xScale,
|
|
1680
1816
|
label: chart.chartType !== "pie2D" && chart.showAxisXTitle ? chart.axisXTitle : "",
|
|
1681
|
-
tickLabelProps:
|
|
1682
|
-
// colorReference.length === 1 && numberReference.length > 0
|
|
1683
|
-
// ? {}
|
|
1684
|
-
// : {
|
|
1685
|
-
// className: 'tickLabel',
|
|
1686
|
-
// textAnchor: 'start',
|
|
1687
|
-
// }
|
|
1688
|
-
{ display: "none" }
|
|
1689
|
-
),
|
|
1817
|
+
tickLabelProps: { display: "none" },
|
|
1690
1818
|
tickLineProps: { display: "none" },
|
|
1691
|
-
labelOffset:
|
|
1819
|
+
labelOffset: 0
|
|
1692
1820
|
}
|
|
1693
1821
|
)
|
|
1694
1822
|
]
|
|
@@ -1696,20 +1824,17 @@ const VerticalBars = ({
|
|
|
1696
1824
|
)
|
|
1697
1825
|
}
|
|
1698
1826
|
),
|
|
1699
|
-
colorReference.length !== 0 && /* @__PURE__ */
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
useNumbered: colorReference.length === 1
|
|
1711
|
-
}
|
|
1712
|
-
)
|
|
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
|
+
] }) })
|
|
1713
1838
|
] });
|
|
1714
1839
|
};
|
|
1715
1840
|
|
|
@@ -1746,7 +1871,7 @@ const Node = ({
|
|
|
1746
1871
|
/* @__PURE__ */ jsx(
|
|
1747
1872
|
"circle",
|
|
1748
1873
|
{
|
|
1749
|
-
r:
|
|
1874
|
+
r: 6,
|
|
1750
1875
|
cx,
|
|
1751
1876
|
cy,
|
|
1752
1877
|
stroke: "transparent",
|
|
@@ -1803,28 +1928,43 @@ function getY(coordinate) {
|
|
|
1803
1928
|
return Number(coordinate.value);
|
|
1804
1929
|
}
|
|
1805
1930
|
function parseData(chart) {
|
|
1806
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1809
|
-
|
|
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(
|
|
1810
1947
|
(rec, d) => arrayOrArray(rec).concat(d),
|
|
1811
1948
|
[]
|
|
1812
1949
|
);
|
|
1813
1950
|
return {
|
|
1814
|
-
|
|
1951
|
+
lines,
|
|
1952
|
+
longestLine,
|
|
1953
|
+
longestLineIndex,
|
|
1954
|
+
tallestLine: [...new Set(nodesData.map((value) => value.value))],
|
|
1815
1955
|
xScale: scaleOrdinal({
|
|
1816
|
-
domain:
|
|
1956
|
+
domain: longestLine.map(getX)
|
|
1817
1957
|
}),
|
|
1818
1958
|
yScale: scaleLinear({
|
|
1819
1959
|
domain: [
|
|
1820
|
-
((
|
|
1821
|
-
(
|
|
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
|
|
1822
1962
|
]
|
|
1823
1963
|
}),
|
|
1824
1964
|
yScaleLog: scaleLog({
|
|
1825
1965
|
domain: [
|
|
1826
|
-
((
|
|
1827
|
-
(
|
|
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
|
|
1828
1968
|
]
|
|
1829
1969
|
})
|
|
1830
1970
|
};
|
|
@@ -1850,25 +1990,39 @@ const LineChart = ({
|
|
|
1850
1990
|
innerWidth = newValues.width;
|
|
1851
1991
|
innerHeight = newValues.height;
|
|
1852
1992
|
}
|
|
1853
|
-
const {
|
|
1993
|
+
const { lines, xScale, yScale, yScaleLog, longestLine } = parseData(chart);
|
|
1854
1994
|
const styles = useChartStyles(chart.colorSchema);
|
|
1855
|
-
const coordinates = arrayOrArray(
|
|
1856
|
-
const coordinatesArray =
|
|
1995
|
+
const coordinates = arrayOrArray(lines[0].sets);
|
|
1996
|
+
const coordinatesArray = lines.map((col) => {
|
|
1857
1997
|
return col.sets;
|
|
1858
1998
|
});
|
|
1859
|
-
const
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
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);
|
|
1872
2026
|
yScaleLog.range([
|
|
1873
2027
|
innerHeight,
|
|
1874
2028
|
typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top
|
|
@@ -1877,7 +2031,7 @@ const LineChart = ({
|
|
|
1877
2031
|
const actualYScale = useMemo(() => {
|
|
1878
2032
|
return yScale;
|
|
1879
2033
|
}, [yScale]);
|
|
1880
|
-
const id = useMemo(() => `
|
|
2034
|
+
const id = useMemo(() => `Linear${uniqueId()}`, []);
|
|
1881
2035
|
useLayoutEffect(() => {
|
|
1882
2036
|
document.querySelectorAll(`#${id} .tickLabel`).forEach((current) => {
|
|
1883
2037
|
const width = current.getBoundingClientRect().width;
|
|
@@ -1892,24 +2046,6 @@ const LineChart = ({
|
|
|
1892
2046
|
return __spreadProps$8(__spreadValues$a({}, object), { columnName: name });
|
|
1893
2047
|
});
|
|
1894
2048
|
}
|
|
1895
|
-
const [nodes, setNodes] = useState([]);
|
|
1896
|
-
useEffect(() => {
|
|
1897
|
-
const coords = coordinatesArray.flat().map((coord) => {
|
|
1898
|
-
return {
|
|
1899
|
-
xValue: coord.key,
|
|
1900
|
-
yValue: coord.value,
|
|
1901
|
-
x: xScale(getX(coord)),
|
|
1902
|
-
y: actualYScale(getY(coord))
|
|
1903
|
-
};
|
|
1904
|
-
});
|
|
1905
|
-
const columnNames = columns.map((column) => {
|
|
1906
|
-
return column.name;
|
|
1907
|
-
});
|
|
1908
|
-
const nodesData = addNameToProps(columnNames, coords, coordinates.length);
|
|
1909
|
-
setNodes(nodesData);
|
|
1910
|
-
}, []);
|
|
1911
|
-
const [nearNodesArray, setNearNodesArray] = useState([]);
|
|
1912
|
-
const previousNearNodesArray = usePrevious(nearNodesArray);
|
|
1913
2049
|
const setsWithColor = arrayOrArray(chart.dataSets.data).map((data, index) => {
|
|
1914
2050
|
const isSingle = arrayOrArray(chart.dataSets.data).length === 1;
|
|
1915
2051
|
const dataColor = data.color !== "" && data.color !== void 0 ? data.color : arrayOrArray(
|
|
@@ -1948,13 +2084,38 @@ const LineChart = ({
|
|
|
1948
2084
|
});
|
|
1949
2085
|
return { returnColumnsArray, columnColor: dataColor };
|
|
1950
2086
|
});
|
|
1951
|
-
const colorReference =
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
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
|
+
);
|
|
1958
2119
|
arrayOrArray(chart.dataSets.data).map((data) => {
|
|
1959
2120
|
const returnArray = [];
|
|
1960
2121
|
arrayOrArray(data.sets).forEach((set) => {
|
|
@@ -1967,29 +2128,6 @@ const LineChart = ({
|
|
|
1967
2128
|
});
|
|
1968
2129
|
return returnArray;
|
|
1969
2130
|
}).flat().forEach((addRef) => colorReference.push(addRef));
|
|
1970
|
-
const { open } = useTooltip({
|
|
1971
|
-
children: nearNodesArray.sort((a, b) => Number(b.yValue) - Number(a.yValue)).map((node, i) => {
|
|
1972
|
-
const useSpecific = colorReference.some(
|
|
1973
|
-
(ref) => ref.title === node.columnName + " - " + node.xValue
|
|
1974
|
-
);
|
|
1975
|
-
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
1976
|
-
/* @__PURE__ */ jsx(
|
|
1977
|
-
"div",
|
|
1978
|
-
{
|
|
1979
|
-
style: {
|
|
1980
|
-
color: colorReference[colorReference.findIndex((ref) => {
|
|
1981
|
-
return ref.title === (useSpecific ? node.columnName + " - " + node.xValue : node.columnName);
|
|
1982
|
-
})].color
|
|
1983
|
-
},
|
|
1984
|
-
children: /* @__PURE__ */ jsx("strong", { children: node.columnName })
|
|
1985
|
-
}
|
|
1986
|
-
),
|
|
1987
|
-
chart.showValues && /* @__PURE__ */ jsx("div", { children: node.yValue }),
|
|
1988
|
-
/* @__PURE__ */ jsx("div", { children: node.xValue }),
|
|
1989
|
-
nearNodesArray[i + 1] && /* @__PURE__ */ jsx("hr", {})
|
|
1990
|
-
] }, `${node.columnName}_${node.xValue}_${node.yValue}`);
|
|
1991
|
-
})
|
|
1992
|
-
});
|
|
1993
2131
|
const [highlightedBar, setHighlightedBar] = useState("");
|
|
1994
2132
|
useImperativeComponentEvents({
|
|
1995
2133
|
highlight(barName) {
|
|
@@ -2004,8 +2142,22 @@ const LineChart = ({
|
|
|
2004
2142
|
void 0,
|
|
2005
2143
|
!allowZoom
|
|
2006
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);
|
|
2007
2159
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2008
|
-
/* @__PURE__ */ jsx(Box, { id, ref: boxRef, className: "chartBox", children: /* @__PURE__ */ jsxs(
|
|
2160
|
+
/* @__PURE__ */ jsx(Box, { id, ref: boxRef, className: "chartBox chartContainer", children: /* @__PURE__ */ jsxs(
|
|
2009
2161
|
"svg",
|
|
2010
2162
|
{
|
|
2011
2163
|
ref: elementRef,
|
|
@@ -2016,7 +2168,7 @@ const LineChart = ({
|
|
|
2016
2168
|
onMouseMove: (ev) => {
|
|
2017
2169
|
var _a;
|
|
2018
2170
|
const rect = (_a = elementRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
2019
|
-
let clientX = ev.clientX;
|
|
2171
|
+
let clientX = ev.clientX - (effectiveMargin.left + effectiveMargin.right) / 2;
|
|
2020
2172
|
let clientY = ev.clientY - (effectiveMargin.top + effectiveMargin.bottom) / 2;
|
|
2021
2173
|
if (rect) {
|
|
2022
2174
|
clientX = ev.clientX - rect.left;
|
|
@@ -2026,7 +2178,7 @@ const LineChart = ({
|
|
|
2026
2178
|
return Math.sqrt(__pow(node.x - clientX, 2) + __pow(node.y - clientY, 2)) < 20;
|
|
2027
2179
|
});
|
|
2028
2180
|
if (previousNearNodesArray.current && nearNodes.length > 0) {
|
|
2029
|
-
const currentColumns =
|
|
2181
|
+
const currentColumns = lines.map((col) => {
|
|
2030
2182
|
let colNames = "";
|
|
2031
2183
|
nearNodes.forEach((node) => {
|
|
2032
2184
|
if (col.name === node.columnName) {
|
|
@@ -2045,10 +2197,45 @@ const LineChart = ({
|
|
|
2045
2197
|
setCurrentCircle([...newCircleValues]);
|
|
2046
2198
|
}
|
|
2047
2199
|
setNearNodesArray(nearNodes);
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
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
|
+
}
|
|
2052
2239
|
} else if (nearNodes.length === 0) {
|
|
2053
2240
|
setCurrentCircle([]);
|
|
2054
2241
|
}
|
|
@@ -2067,7 +2254,7 @@ const LineChart = ({
|
|
|
2067
2254
|
strokeOpacity: styles == null ? void 0 : styles.grid.opacity
|
|
2068
2255
|
}
|
|
2069
2256
|
),
|
|
2070
|
-
|
|
2257
|
+
lines.map((column, i) => {
|
|
2071
2258
|
var _a;
|
|
2072
2259
|
const currentCoordinates = arrayOrArray(column.sets);
|
|
2073
2260
|
const newColor = (_a = setsWithColor.find(
|
|
@@ -2098,7 +2285,8 @@ const LineChart = ({
|
|
|
2098
2285
|
stroke: newColor != null ? newColor : "black",
|
|
2099
2286
|
strokeWidth: 2,
|
|
2100
2287
|
strokeOpacity: 1,
|
|
2101
|
-
shapeRendering: "geometricPrecision"
|
|
2288
|
+
shapeRendering: "geometricPrecision",
|
|
2289
|
+
color: "transparent"
|
|
2102
2290
|
}
|
|
2103
2291
|
),
|
|
2104
2292
|
currentCoordinates.map((coordinate, j) => {
|
|
@@ -2165,41 +2353,13 @@ const LineChart = ({
|
|
|
2165
2353
|
]
|
|
2166
2354
|
}
|
|
2167
2355
|
) }),
|
|
2168
|
-
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
|
+
] }) })
|
|
2169
2360
|
] });
|
|
2170
2361
|
};
|
|
2171
2362
|
|
|
2172
|
-
function ChartSelector({
|
|
2173
|
-
chartId,
|
|
2174
|
-
pieces,
|
|
2175
|
-
className,
|
|
2176
|
-
current,
|
|
2177
|
-
setCurrent
|
|
2178
|
-
}) {
|
|
2179
|
-
return /* @__PURE__ */ jsxs(
|
|
2180
|
-
Select,
|
|
2181
|
-
{
|
|
2182
|
-
sx: { width: "auto" },
|
|
2183
|
-
name: `chartSelector_${chartId}`,
|
|
2184
|
-
className: `chartSelector_${chartId} ${className != null ? className : ""}`,
|
|
2185
|
-
value: current != null ? current : "0",
|
|
2186
|
-
onChange: (ev) => {
|
|
2187
|
-
ev.preventDefault();
|
|
2188
|
-
setCurrent(ev.target.value);
|
|
2189
|
-
},
|
|
2190
|
-
children: [
|
|
2191
|
-
pieces.map((piece, i) => {
|
|
2192
|
-
return {
|
|
2193
|
-
label: piece,
|
|
2194
|
-
value: `${i}`
|
|
2195
|
-
};
|
|
2196
|
-
}).map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value)),
|
|
2197
|
-
" "
|
|
2198
|
-
]
|
|
2199
|
-
}
|
|
2200
|
-
);
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
2363
|
const WaterfallBar = ({
|
|
2204
2364
|
width,
|
|
2205
2365
|
height,
|
|
@@ -2427,7 +2587,7 @@ const WaterfallBars = (_a) => {
|
|
|
2427
2587
|
nice: true,
|
|
2428
2588
|
range: [innerHeight, 0]
|
|
2429
2589
|
});
|
|
2430
|
-
const id = useMemo(() => `
|
|
2590
|
+
const id = useMemo(() => `WaterfallBars${uniqueId()}`, []);
|
|
2431
2591
|
useLayoutEffect(() => {
|
|
2432
2592
|
document.querySelectorAll(`#${id} .tickLabel`).forEach((current) => {
|
|
2433
2593
|
const width = current.getBoundingClientRect().width;
|
|
@@ -2440,21 +2600,11 @@ const WaterfallBars = (_a) => {
|
|
|
2440
2600
|
!allowZoom
|
|
2441
2601
|
);
|
|
2442
2602
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2443
|
-
charts.length > 1 && /* @__PURE__ */ jsx(Box, { className: "chart__combo__wrapper", children: /* @__PURE__ */ jsx(
|
|
2444
|
-
ChartSelector,
|
|
2445
|
-
{
|
|
2446
|
-
chartId,
|
|
2447
|
-
pieces: chartNames,
|
|
2448
|
-
className: "chartSelectorCombo",
|
|
2449
|
-
current: currentPie,
|
|
2450
|
-
setCurrent: setCurrentPie
|
|
2451
|
-
}
|
|
2452
|
-
) }),
|
|
2453
2603
|
/* @__PURE__ */ jsx(
|
|
2454
2604
|
Box,
|
|
2455
2605
|
{
|
|
2456
2606
|
id,
|
|
2457
|
-
className: `${className ? className : ""} chartBox`,
|
|
2607
|
+
className: `${className ? className : ""} chartBox chartContainer`,
|
|
2458
2608
|
ref: boxRef,
|
|
2459
2609
|
children: /* @__PURE__ */ jsx(
|
|
2460
2610
|
"svg",
|
|
@@ -2543,19 +2693,19 @@ const WaterfallBars = (_a) => {
|
|
|
2543
2693
|
)
|
|
2544
2694
|
}
|
|
2545
2695
|
),
|
|
2546
|
-
/* @__PURE__ */ jsx(
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
)
|
|
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
|
+
] }) })
|
|
2559
2709
|
] });
|
|
2560
2710
|
};
|
|
2561
2711
|
|
|
@@ -2647,11 +2797,13 @@ const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
|
|
|
2647
2797
|
lineHeight: "1em"
|
|
2648
2798
|
}
|
|
2649
2799
|
},
|
|
2650
|
-
".chartBox": {
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2800
|
+
".chartBox": () => {
|
|
2801
|
+
return {
|
|
2802
|
+
position: responsive({ 0: "static", 3: "sticky" }),
|
|
2803
|
+
top: "0",
|
|
2804
|
+
background: "white",
|
|
2805
|
+
zIndex: "1"
|
|
2806
|
+
};
|
|
2655
2807
|
},
|
|
2656
2808
|
".legendContainer": {
|
|
2657
2809
|
display: "flex",
|
|
@@ -2669,9 +2821,6 @@ const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
|
|
|
2669
2821
|
}
|
|
2670
2822
|
})
|
|
2671
2823
|
},
|
|
2672
|
-
".chart__combo__wrapper": {
|
|
2673
|
-
position: "absolute"
|
|
2674
|
-
},
|
|
2675
2824
|
".legendItem": {
|
|
2676
2825
|
transition: "opacity 200ms",
|
|
2677
2826
|
"&.isBlurred": {
|
|
@@ -2692,14 +2841,19 @@ const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
|
|
|
2692
2841
|
({
|
|
2693
2842
|
currentChart,
|
|
2694
2843
|
chartId,
|
|
2695
|
-
allowZoom
|
|
2844
|
+
allowZoom,
|
|
2845
|
+
id
|
|
2696
2846
|
}, ref) => {
|
|
2697
2847
|
const innerRef = React.useRef(null);
|
|
2698
2848
|
const setRefs = useMultipleRefs(
|
|
2699
2849
|
ref,
|
|
2700
2850
|
innerRef
|
|
2701
2851
|
);
|
|
2702
|
-
const
|
|
2852
|
+
const { id: imperativeId } = useImperativeComponentContext();
|
|
2853
|
+
const contextValue = useMemo(
|
|
2854
|
+
() => ({ chartId: String(imperativeId) }),
|
|
2855
|
+
[imperativeId]
|
|
2856
|
+
);
|
|
2703
2857
|
const CurrentChart = getIndex(
|
|
2704
2858
|
[PieChart, HorizontalBars, VerticalBars, LineChart, WaterfallBars],
|
|
2705
2859
|
[
|
|
@@ -2717,13 +2871,15 @@ const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
|
|
|
2717
2871
|
ref: setRefs,
|
|
2718
2872
|
className: "chart__chartRenderer"
|
|
2719
2873
|
}, getVariant("layout.charts")), {
|
|
2874
|
+
id,
|
|
2720
2875
|
children: /* @__PURE__ */ jsx(
|
|
2721
2876
|
CurrentChart,
|
|
2722
2877
|
{
|
|
2723
2878
|
chart: currentChart,
|
|
2724
2879
|
chartId,
|
|
2725
2880
|
parentRef: innerRef,
|
|
2726
|
-
allowZoom
|
|
2881
|
+
allowZoom,
|
|
2882
|
+
margin: currentChart.margin
|
|
2727
2883
|
}
|
|
2728
2884
|
)
|
|
2729
2885
|
})
|
|
@@ -4035,7 +4191,10 @@ var __spreadValues = (a, b) => {
|
|
|
4035
4191
|
}
|
|
4036
4192
|
return a;
|
|
4037
4193
|
};
|
|
4038
|
-
const WidgetContainer = ({
|
|
4194
|
+
const WidgetContainer = ({
|
|
4195
|
+
data,
|
|
4196
|
+
id
|
|
4197
|
+
}) => {
|
|
4039
4198
|
const realData = __spreadValues({}, data);
|
|
4040
4199
|
const valueRanges = Array.from(
|
|
4041
4200
|
new Set(
|
|
@@ -4060,7 +4219,6 @@ const WidgetContainer = ({ data }) => {
|
|
|
4060
4219
|
],
|
|
4061
4220
|
0
|
|
4062
4221
|
);
|
|
4063
|
-
const panelData = usePanelIdentity();
|
|
4064
4222
|
return /* @__PURE__ */ jsx(
|
|
4065
4223
|
CurrentWidget,
|
|
4066
4224
|
{
|
|
@@ -4073,7 +4231,7 @@ const WidgetContainer = ({ data }) => {
|
|
|
4073
4231
|
currentValueFontSize: realData.valueFontSize,
|
|
4074
4232
|
forceProp: realData.forceProp,
|
|
4075
4233
|
height: realData.height,
|
|
4076
|
-
panelId:
|
|
4234
|
+
panelId: id,
|
|
4077
4235
|
maxValue: realData.maxValue,
|
|
4078
4236
|
minValue: realData.minValue,
|
|
4079
4237
|
pointerColor: realData.pointerColor,
|