@apia/charts 2.0.7 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/charts/chartJsRenderer/ChartComponent.d.ts +22 -0
  2. package/dist/charts/chartJsRenderer/ChartComponent.d.ts.map +1 -0
  3. package/dist/charts/chartJsRenderer/ChartComponent.js +244 -0
  4. package/dist/charts/chartJsRenderer/ChartComponent.js.map +1 -0
  5. package/dist/charts/types.d.ts +2 -17
  6. package/dist/index.d.ts +3 -4
  7. package/dist/index.js +2 -3
  8. package/dist/index.js.map +1 -1
  9. package/dist/widgets/WidgetComponent.d.ts +10 -0
  10. package/dist/widgets/WidgetComponent.d.ts.map +1 -0
  11. package/dist/widgets/WidgetComponent.js +54 -0
  12. package/dist/widgets/WidgetComponent.js.map +1 -0
  13. package/dist/widgets/counter/Counter.js +8 -8
  14. package/dist/widgets/counter/Counter.js.map +1 -1
  15. package/dist/widgets/custom/useCustomWidget.js +3 -3
  16. package/dist/widgets/custom/useCustomWidget.js.map +1 -1
  17. package/dist/widgets/custom/util.js.map +1 -1
  18. package/dist/widgets/oxford/Oxford.js +3 -1
  19. package/dist/widgets/oxford/Oxford.js.map +1 -1
  20. package/dist/widgets/ring/Ring.js +4 -4
  21. package/dist/widgets/ring/Ring.js.map +1 -1
  22. package/dist/widgets/scale/Scale.js.map +1 -1
  23. package/dist/widgets/speedMeter/SpeedMeter.js +3 -1
  24. package/dist/widgets/speedMeter/SpeedMeter.js.map +1 -1
  25. package/dist/widgets/tLight/TLight.js +4 -4
  26. package/dist/widgets/tLight/TLight.js.map +1 -1
  27. package/dist/widgets/thermometer/Thermometer.js +7 -5
  28. package/dist/widgets/thermometer/Thermometer.js.map +1 -1
  29. package/dist/widgets/thermometer/util.js +4 -1
  30. package/dist/widgets/thermometer/util.js.map +1 -1
  31. package/dist/widgets/types.d.ts +66 -1
  32. package/package.json +8 -6
  33. package/dist/charts/ChartContext.js +0 -6
  34. package/dist/charts/ChartContext.js.map +0 -1
  35. package/dist/charts/ChartRenderer.d.ts +0 -17
  36. package/dist/charts/ChartRenderer.d.ts.map +0 -1
  37. package/dist/charts/ChartRenderer.js +0 -175
  38. package/dist/charts/ChartRenderer.js.map +0 -1
  39. package/dist/charts/horizontalBars/Bar.js +0 -228
  40. package/dist/charts/horizontalBars/Bar.js.map +0 -1
  41. package/dist/charts/horizontalBars/HorizontalBars.js +0 -374
  42. package/dist/charts/horizontalBars/HorizontalBars.js.map +0 -1
  43. package/dist/charts/linear/LineChart.js +0 -469
  44. package/dist/charts/linear/LineChart.js.map +0 -1
  45. package/dist/charts/linear/Node.js +0 -56
  46. package/dist/charts/linear/Node.js.map +0 -1
  47. package/dist/charts/pie/Pie.js +0 -183
  48. package/dist/charts/pie/Pie.js.map +0 -1
  49. package/dist/charts/pie/Slice.js +0 -96
  50. package/dist/charts/pie/Slice.js.map +0 -1
  51. package/dist/charts/pie/usePieAnimation.js +0 -123
  52. package/dist/charts/pie/usePieAnimation.js.map +0 -1
  53. package/dist/charts/util/ChartSelector.js +0 -36
  54. package/dist/charts/util/ChartSelector.js.map +0 -1
  55. package/dist/charts/util/ColoredLegendItem.js +0 -46
  56. package/dist/charts/util/ColoredLegendItem.js.map +0 -1
  57. package/dist/charts/util/EmptyGrid.d.ts +0 -8
  58. package/dist/charts/util/EmptyGrid.d.ts.map +0 -1
  59. package/dist/charts/util/EmptyGrid.js +0 -51
  60. package/dist/charts/util/EmptyGrid.js.map +0 -1
  61. package/dist/charts/util/LegendContainer.js +0 -54
  62. package/dist/charts/util/LegendContainer.js.map +0 -1
  63. package/dist/charts/util/NumberedLegendItem.js +0 -45
  64. package/dist/charts/util/NumberedLegendItem.js.map +0 -1
  65. package/dist/charts/util/getBarColor.js +0 -29
  66. package/dist/charts/util/getBarColor.js.map +0 -1
  67. package/dist/charts/util/parseMargin.js +0 -11
  68. package/dist/charts/util/parseMargin.js.map +0 -1
  69. package/dist/charts/util/useChartStyles.js +0 -35
  70. package/dist/charts/util/useChartStyles.js.map +0 -1
  71. package/dist/charts/verticalBars/Bar.js +0 -241
  72. package/dist/charts/verticalBars/Bar.js.map +0 -1
  73. package/dist/charts/verticalBars/VerticalBars.js +0 -394
  74. package/dist/charts/verticalBars/VerticalBars.js.map +0 -1
  75. package/dist/charts/waterfallBars/WaterfallBar.js +0 -84
  76. package/dist/charts/waterfallBars/WaterfallBar.js.map +0 -1
  77. package/dist/charts/waterfallBars/WaterfallBars.js +0 -247
  78. package/dist/charts/waterfallBars/WaterfallBars.js.map +0 -1
  79. package/dist/widgets/WidgetContainer.d.ts +0 -10
  80. package/dist/widgets/WidgetContainer.d.ts.map +0 -1
  81. package/dist/widgets/WidgetContainer.js +0 -68
  82. package/dist/widgets/WidgetContainer.js.map +0 -1
@@ -1,183 +0,0 @@
1
- import { jsxs, Fragment, jsx } from '@apia/theme/jsx-runtime';
2
- import { arrayOrArray, usePanAndZoom, getLabel } from '@apia/util';
3
- import { Box, spacing, Heading } from '@apia/theme';
4
- import { Group } from '@visx/group';
5
- import { Slice } from './Slice.js';
6
- import { useChartStyles } from '../util/useChartStyles.js';
7
- import { useState, useMemo, useRef } from 'react';
8
- import { LegendContainer } from '../util/LegendContainer.js';
9
- import { getBarColor } from '../util/getBarColor.js';
10
- import { usePieAnimation } from './usePieAnimation.js';
11
- import uniqueId from 'lodash-es/uniqueId';
12
- import ChartSelector from '../util/ChartSelector.js';
13
- import { Pie } from '@visx/shape';
14
-
15
- function adjustDimensions({
16
- width,
17
- height,
18
- maxWidth
19
- }) {
20
- if (width <= maxWidth) {
21
- return { width, height };
22
- }
23
- const ratio = width / height;
24
- const newWidth = maxWidth;
25
- const newHeight = Math.floor(newWidth / ratio);
26
- return { width: newWidth, height: newHeight };
27
- }
28
- const PieChart = ({
29
- chart,
30
- className,
31
- chartId,
32
- allowZoom
33
- }) => {
34
- const [dataset, setDataset] = useState(
35
- arrayOrArray(chart.dataSets?.data)
36
- );
37
- const [currentPie, setCurrentPie] = useState("0");
38
- const piezas = useMemo(() => {
39
- return dataset.filter((piece) => !!piece.sets).map((piece) => {
40
- return {
41
- ...piece,
42
- coordinate: piece.sets
43
- };
44
- })[dataset[parseInt(currentPie)] ? parseInt(currentPie) : 0];
45
- }, [currentPie, dataset]);
46
- usePieAnimation({
47
- incomingColumn: arrayOrArray(chart.dataSets?.data)[dataset[parseInt(currentPie)] ? parseInt(currentPie) : 0],
48
- piezas,
49
- setDataset
50
- });
51
- let innerWidth = chart.ratio.width > chart.ratio.height ? chart.ratio.width : chart.ratio.height;
52
- let innerHeight = chart.ratio.width > chart.ratio.height ? chart.ratio.width : chart.ratio.height;
53
- if (innerWidth > chart.ratio.maxWidth) {
54
- const newValues = adjustDimensions({
55
- height: innerHeight,
56
- width: innerWidth,
57
- maxWidth: chart.ratio.maxWidth
58
- });
59
- innerWidth = newValues.width;
60
- innerHeight = newValues.height;
61
- }
62
- const centerY = useMemo(() => {
63
- return innerHeight / 2.5;
64
- }, [innerHeight]);
65
- const centerX = useMemo(() => {
66
- return innerWidth / 2.5;
67
- }, [innerWidth]);
68
- const top = centerY;
69
- const left = centerX;
70
- const getValue = (d) => Number(d.value) === 0 && arrayOrArray(piezas.coordinate).length === 1 ? 100 : d.value === void 0 ? 0 : Number(d.value);
71
- const radius = Math.min(innerHeight, innerWidth) / 2.5;
72
- const styles = useChartStyles(chart.colorSchema);
73
- const colorsArray = styles ? styles.schema : ["#7ad6f4", "#45bdee", "#28a7ea", "#006cbb", "#034698", "#032f64"];
74
- const names = arrayOrArray(
75
- (dataset[parseInt(currentPie)] ?? dataset[0]).sets
76
- ).map((coord) => {
77
- return coord.key;
78
- });
79
- const colorReference = names.map((name, index) => {
80
- return {
81
- title: name,
82
- color: getBarColor(arrayOrArray(colorsArray), index)
83
- };
84
- });
85
- const { boxRef, elementRef } = usePanAndZoom(
86
- void 0,
87
- !allowZoom
88
- );
89
- const previousPaths = useRef([]);
90
- const id = useMemo(() => `Pie${uniqueId()}`, []);
91
- const charts = arrayOrArray(chart.dataSets?.data).filter((piece) => !!piece.sets).map((piece) => {
92
- return {
93
- ...piece,
94
- coordinate: piece.sets
95
- };
96
- });
97
- const chartNames = charts.map((piece) => {
98
- return piece.name;
99
- });
100
- if (!piezas) {
101
- return null;
102
- }
103
- return /* @__PURE__ */ jsxs(Fragment, { children: [
104
- /* @__PURE__ */ jsx(
105
- Box,
106
- {
107
- ref: boxRef,
108
- id,
109
- className: `${className ? className : ""} ${chartId} chartBox chartContainer`,
110
- sx: { textAlign: "center", pb: spacing(5) },
111
- children: /* @__PURE__ */ jsx(
112
- "svg",
113
- {
114
- ref: elementRef,
115
- height: radius * 2,
116
- width: radius * 2,
117
- className: `_${chartId} chart__svg`,
118
- children: /* @__PURE__ */ jsx(Group, { top: top ?? 0, left: left ?? 0, children: /* @__PURE__ */ jsx(
119
- Pie,
120
- {
121
- data: arrayOrArray(piezas.coordinate),
122
- pieValue: getValue,
123
- pieSort: null,
124
- outerRadius: radius,
125
- children: (pie) => {
126
- const paths = arrayOrArray(pie.arcs).map((arc) => {
127
- return pie.path(arc);
128
- });
129
- const result = pie.arcs.map((arc) => {
130
- const name = arc.data;
131
- const arcPath = pie.path(arc);
132
- return /* @__PURE__ */ jsx(
133
- Slice,
134
- {
135
- arc,
136
- chartId: id,
137
- arcPath,
138
- chart,
139
- actualColor: colorReference.find((color) => {
140
- return color.title === name.key;
141
- })?.color.startsWith("#") ? colorReference.find((color) => {
142
- return color.title === name.key;
143
- })?.color ?? "" : `#${colorReference.find((color) => {
144
- return color.title === name.key;
145
- })?.color ?? ""}`
146
- },
147
- `${name.key}_${name.value}`
148
- );
149
- });
150
- previousPaths.current = paths;
151
- return result;
152
- }
153
- }
154
- ) })
155
- }
156
- )
157
- },
158
- piezas.name
159
- ),
160
- /* @__PURE__ */ jsxs(Box, { className: "chartLegend__Wrapper", children: [
161
- !chart.hideSelector && charts.length > 1 && /* @__PURE__ */ jsxs(Box, { className: "chart__combo__wrapper", children: [
162
- /* @__PURE__ */ jsx(Heading, { as: "h6", children: getLabel("lblChartSel").text }),
163
- /* @__PURE__ */ jsx(
164
- ChartSelector,
165
- {
166
- chartId,
167
- pieces: chartNames,
168
- className: "chartSelectorCombo",
169
- current: currentPie,
170
- setCurrent: setCurrentPie
171
- }
172
- )
173
- ] }),
174
- chart.showLegend && colorReference.length > 1 && /* @__PURE__ */ jsxs(Box, { className: "chart__legend__wrapper", children: [
175
- /* @__PURE__ */ jsx(Heading, { as: "h6", children: getLabel("mnuLeyends").text }),
176
- /* @__PURE__ */ jsx(LegendContainer, { id: chartId, references: colorReference })
177
- ] })
178
- ] })
179
- ] });
180
- };
181
-
182
- export { PieChart };
183
- //# sourceMappingURL=Pie.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Pie.js","sources":["../../../src/charts/pie/Pie.tsx"],"sourcesContent":["import {\n TApiaChartColumn,\n TApiaChartCoordinate,\n TChartRendererProps,\n} from '../types';\nimport { arrayOrArray, getLabel, usePanAndZoom } from '@apia/util';\nimport { Box, Heading } from '@apia/theme';\nimport { Group } from '@visx/group';\nimport { Slice } from './Slice';\nimport { useChartStyles } from '../util/useChartStyles';\nimport { useRef, useMemo, useState } from 'react';\nimport { LegendContainer, TChartReference } from '../util/LegendContainer';\nimport { getBarColor } from '../util/getBarColor';\nimport { spacing } from '@apia/theme';\nimport { usePieAnimation } from './usePieAnimation';\nimport uniqueId from 'lodash-es/uniqueId';\nimport ChartSelector from '../util/ChartSelector';\nimport { Pie } from '@visx/shape';\n\nfunction adjustDimensions({\n width,\n height,\n maxWidth,\n}: {\n width: number;\n height: number;\n maxWidth: number;\n}) {\n if (width <= maxWidth) {\n return { width, height };\n }\n\n const ratio = width / height;\n const newWidth = maxWidth;\n const newHeight = Math.floor(newWidth / ratio);\n\n return { width: newWidth, height: newHeight };\n}\n\nexport type TPieChartEvents = { highlight: { barName: string } };\n\nconst PieChart = ({\n chart,\n className,\n chartId,\n allowZoom,\n}: TChartRendererProps) => {\n const [dataset, setDataset] = useState<TApiaChartColumn[]>(\n arrayOrArray(chart.dataSets?.data),\n );\n const [currentPie, setCurrentPie] = useState('0');\n const piezas = useMemo(() => {\n return dataset\n .filter((piece) => !!piece.sets)\n .map((piece) => {\n return {\n ...piece,\n coordinate: piece.sets,\n };\n })[dataset[parseInt(currentPie)] ? parseInt(currentPie) : 0];\n }, [currentPie, dataset]);\n\n usePieAnimation({\n incomingColumn: arrayOrArray(chart.dataSets?.data)[\n dataset[parseInt(currentPie)] ? parseInt(currentPie) : 0\n ],\n piezas,\n setDataset,\n });\n\n let innerWidth =\n chart.ratio.width > chart.ratio.height\n ? chart.ratio.width\n : chart.ratio.height;\n let innerHeight =\n chart.ratio.width > chart.ratio.height\n ? chart.ratio.width\n : chart.ratio.height;\n if (innerWidth > chart.ratio.maxWidth) {\n const newValues = adjustDimensions({\n height: innerHeight,\n width: innerWidth,\n maxWidth: chart.ratio.maxWidth,\n });\n innerWidth = newValues.width;\n innerHeight = newValues.height;\n }\n\n const centerY = useMemo(() => {\n return innerHeight / 2.5;\n }, [innerHeight]);\n const centerX = useMemo(() => {\n return innerWidth / 2.5;\n }, [innerWidth]);\n const top = centerY;\n const left = centerX;\n\n const getValue = (d: TApiaChartCoordinate) =>\n Number(d.value) === 0 && arrayOrArray(piezas.coordinate).length === 1\n ? 100\n : d.value === undefined\n ? 0\n : Number(d.value);\n const radius = Math.min(innerHeight, innerWidth) / 2.5;\n\n const styles = useChartStyles(chart.colorSchema);\n\n const colorsArray = styles\n ? styles.schema\n : ['#7ad6f4', '#45bdee', '#28a7ea', '#006cbb', '#034698', '#032f64'];\n const names = arrayOrArray(\n (dataset[parseInt(currentPie)] ?? dataset[0]).sets,\n ).map((coord) => {\n return coord.key;\n });\n const colorReference: TChartReference = names.map((name, index) => {\n return {\n title: name,\n color: getBarColor(arrayOrArray(colorsArray), index),\n };\n });\n\n const { boxRef, elementRef } = usePanAndZoom<HTMLElement, SVGSVGElement>(\n undefined,\n !allowZoom ?? true,\n );\n const previousPaths = useRef<(string | null)[]>([]);\n const id = useMemo(() => `Pie${uniqueId()}`, []);\n const charts = arrayOrArray(chart.dataSets?.data)\n .filter((piece) => !!piece.sets)\n .map((piece) => {\n return {\n ...piece,\n coordinate: piece.sets,\n };\n });\n const chartNames = charts.map((piece) => {\n return piece.name;\n });\n if (!piezas) {\n return null;\n }\n\n return (\n <>\n <Box\n ref={boxRef}\n id={id}\n key={piezas.name}\n className={`${\n className ? className : ''\n } ${chartId} chartBox chartContainer`}\n sx={{ textAlign: 'center', pb: spacing(5) }}\n >\n <svg\n ref={elementRef}\n height={radius * 2}\n width={radius * 2}\n className={`_${chartId} chart__svg`}\n >\n <Group top={top ?? 0} left={left ?? 0}>\n <Pie\n data={arrayOrArray(piezas.coordinate)}\n pieValue={getValue}\n pieSort={null}\n outerRadius={radius}\n >\n {(pie) => {\n const paths = arrayOrArray(pie.arcs).map((arc) => {\n return pie.path(arc);\n });\n\n const result = pie.arcs.map((arc) => {\n const name = arc.data;\n\n const arcPath = pie.path(arc);\n return (\n <Slice\n arc={arc}\n chartId={id}\n arcPath={arcPath}\n chart={chart}\n key={`${name.key}_${name.value}`}\n actualColor={\n colorReference\n .find((color) => {\n return color.title === name.key;\n })\n ?.color.startsWith('#')\n ? colorReference.find((color) => {\n return color.title === name.key;\n })?.color ?? ''\n : `#${\n colorReference.find((color) => {\n return color.title === name.key;\n })?.color ?? ''\n }`\n }\n />\n );\n });\n previousPaths.current = paths;\n\n return result;\n }}\n </Pie>\n </Group>\n </svg>\n </Box>\n <Box className=\"chartLegend__Wrapper\">\n {!chart.hideSelector && charts.length > 1 && (\n <Box className=\"chart__combo__wrapper\">\n {/* TODO LABEL */}\n <Heading as={'h6'}>{getLabel('lblChartSel').text}</Heading>\n <ChartSelector\n chartId={chartId}\n pieces={chartNames}\n className=\"chartSelectorCombo\"\n current={currentPie}\n setCurrent={setCurrentPie}\n />\n </Box>\n )}\n\n {chart.showLegend && colorReference.length > 1 && (\n <Box className=\"chart__legend__wrapper\">\n {/* TODO LABEL */}\n <Heading as={'h6'}>{getLabel('mnuLeyends').text}</Heading>\n <LegendContainer id={chartId} references={colorReference} />\n </Box>\n )}\n </Box>\n </>\n );\n};\n\nexport { PieChart };\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAmBA,SAAS,gBAAiB,CAAA;AAAA,EACxB,KAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AACF,CAIG,EAAA;AACD,EAAA,IAAI,SAAS,QAAU,EAAA;AACrB,IAAO,OAAA,EAAE,OAAO,MAAO,EAAA,CAAA;AAAA,GACzB;AAEA,EAAA,MAAM,QAAQ,KAAQ,GAAA,MAAA,CAAA;AACtB,EAAA,MAAM,QAAW,GAAA,QAAA,CAAA;AACjB,EAAA,MAAM,SAAY,GAAA,IAAA,CAAK,KAAM,CAAA,QAAA,GAAW,KAAK,CAAA,CAAA;AAE7C,EAAA,OAAO,EAAE,KAAA,EAAO,QAAU,EAAA,MAAA,EAAQ,SAAU,EAAA,CAAA;AAC9C,CAAA;AAIA,MAAM,WAAW,CAAC;AAAA,EAChB,KAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AACF,CAA2B,KAAA;AACzB,EAAM,MAAA,CAAC,OAAS,EAAA,UAAU,CAAI,GAAA,QAAA;AAAA,IAC5B,YAAA,CAAa,KAAM,CAAA,QAAA,EAAU,IAAI,CAAA;AAAA,GACnC,CAAA;AACA,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,GAAG,CAAA,CAAA;AAChD,EAAM,MAAA,MAAA,GAAS,QAAQ,MAAM;AAC3B,IAAO,OAAA,OAAA,CACJ,MAAO,CAAA,CAAC,KAAU,KAAA,CAAC,CAAC,KAAA,CAAM,IAAI,CAAA,CAC9B,GAAI,CAAA,CAAC,KAAU,KAAA;AACd,MAAO,OAAA;AAAA,QACL,GAAG,KAAA;AAAA,QACH,YAAY,KAAM,CAAA,IAAA;AAAA,OACpB,CAAA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AM,cAAc,cAAe,CAAA,MAAA,GAAS,qBAC1C,IAAA,CAAA,GAAA,EAAA,EAAI,WAAU,wBAEb,EAAA,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,WAAQ,EAAI,EAAA,IAAA,EAAO,QAAS,EAAA,QAAA,CAAA,YAAY,EAAE,IAAK,EAAA,CAAA;AAAA,wBAC/C,GAAA,CAAA,eAAA,EAAA,EAAgB,EAAI,EAAA,OAAA,EAAS,YAAY,cAAgB,EAAA,CAAA;AAAA,OAC5D,EAAA,CAAA;AAAA,KAEJ,EAAA,CAAA;AAAA,GACF,EAAA,CAAA,CAAA;AAEJ;;;;"}
@@ -1,96 +0,0 @@
1
- import { jsxs, Fragment, jsx } from '@apia/theme/jsx-runtime';
2
- import { useState, useRef, useMemo } from 'react';
3
- import tinycolor from 'tinycolor2';
4
- import { localPoint } from '@visx/event';
5
- import { useImperativeComponentContext, useImperativeComponentEvents } from '@apia/util';
6
- import { legendContainerMethods } from '../util/LegendContainer.js';
7
- import { chartMethods } from '../ChartRenderer.js';
8
- import { ApiaUtil } from '@apia/components';
9
-
10
- const Slice = ({
11
- arc,
12
- arcPath,
13
- chart,
14
- actualColor,
15
- chartId: outerChartId
16
- }) => {
17
- const [isHighlighted, setIsHighlighted] = useState(false);
18
- const [isAnyHighlighted, setIsAnyHighlighted] = useState(false);
19
- const ref = useRef(null);
20
- const name = arc.data;
21
- const { id: chartId } = useImperativeComponentContext();
22
- useImperativeComponentEvents({
23
- highlight(barNameId) {
24
- const barName = barNameId.split("_$_")[0];
25
- setIsHighlighted(barName === arc.data.key);
26
- setIsAnyHighlighted(barName !== arc.data.key && barName !== "");
27
- if (barName === arc.data.key) {
28
- new ApiaUtil().tooltips.open({
29
- children: /* @__PURE__ */ jsxs(Fragment, { children: [
30
- /* @__PURE__ */ jsx(
31
- "div",
32
- {
33
- style: {
34
- color: `#${tinycolor(actualColor).toHex()}`
35
- },
36
- children: /* @__PURE__ */ jsx("strong", { children: arc.data.key })
37
- }
38
- ),
39
- 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 ? "%" : ""}` })
40
- ] }),
41
- attachToElement: () => {
42
- return ref.current;
43
- },
44
- attachToElementAnchorPoint: "center",
45
- closeOnClickOut: () => {
46
- return window.innerWidth > 700;
47
- },
48
- closeOnMouseLeaveAttachedElement: (ev) => {
49
- return !ev.relatedTarget.closest(".legendItem");
50
- },
51
- className: arc.data.key
52
- });
53
- }
54
- }
55
- });
56
- return /* @__PURE__ */ jsx(
57
- "path",
58
- {
59
- id: `arc-${name.key}-${name.value}-${outerChartId}`,
60
- ref,
61
- style: useMemo(
62
- () => ({
63
- "&:hover": {
64
- fill: `#${tinycolor(actualColor).saturate(25).toHex()}`
65
- },
66
- transition: "fill 500ms, opacity 500ms"
67
- }),
68
- [actualColor]
69
- ),
70
- color: isAnyHighlighted ? `#${tinycolor(actualColor).desaturate(70).toHex()}` : actualColor,
71
- fill: isAnyHighlighted ? `#${tinycolor(actualColor).desaturate(70).toHex()}` : actualColor,
72
- opacity: isAnyHighlighted && !isHighlighted ? 0.15 : 1,
73
- d: arcPath ?? "",
74
- onMouseEnter: (ev) => {
75
- legendContainerMethods.highlight(chartId, arc.data.key);
76
- chartMethods(chartId, "highlight", `${name.key}_$_${outerChartId}`);
77
- ev.target.classList?.add("over");
78
- const point = {
79
- x: localPoint(ev)?.x,
80
- y: localPoint(ev)?.y
81
- };
82
- if (!point)
83
- return;
84
- },
85
- onMouseLeave: (ev) => {
86
- legendContainerMethods.highlight(chartId, "");
87
- chartMethods(chartId, "highlight", "");
88
- ev.target.classList?.remove("over");
89
- }
90
- },
91
- `arc-${name.key}-${name.value}-${outerChartId}`
92
- );
93
- };
94
-
95
- export { Slice };
96
- //# sourceMappingURL=Slice.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Slice.js","sources":["../../../src/charts/pie/Slice.tsx"],"sourcesContent":["import { TApiaChartCoordinate, TChartRendererProps } from '../types';\nimport { useMemo, useState, useRef } from 'react';\nimport tinycolor from 'tinycolor2';\nimport { localPoint } from '@visx/event';\nimport { PieArcDatum } from '@visx/shape/lib/shapes/Pie';\nimport {\n useImperativeComponentContext,\n useImperativeComponentEvents,\n} from '@apia/util';\nimport { legendContainerMethods } from '../util/LegendContainer';\nimport { TChartEvents, chartMethods } from '../ChartRenderer';\nimport { ApiaUtil } from '@apia/components';\n// import uniqueId from 'lodash-es/uniqueId';\n\nexport const Slice = ({\n arc,\n arcPath,\n chart,\n actualColor,\n chartId: outerChartId,\n}: Pick<TChartRendererProps, 'chart'> &\n Pick<TChartRendererProps, 'chartId'> & {\n arc: PieArcDatum<TApiaChartCoordinate>;\n arcPath: string | null;\n actualColor: string;\n }) => {\n // const uId = uniqueId();\n const [isHighlighted, setIsHighlighted] = useState(false);\n const [isAnyHighlighted, setIsAnyHighlighted] = useState(false);\n const ref = useRef<SVGPathElement | null>(null);\n const name = arc.data;\n const { id: chartId } = useImperativeComponentContext();\n useImperativeComponentEvents<TChartEvents>({\n highlight(barNameId) {\n const barName = barNameId.split('_$_')[0];\n setIsHighlighted(barName === arc.data.key);\n setIsAnyHighlighted(barName !== arc.data.key && barName !== '');\n if (barName === arc.data.key) {\n new ApiaUtil().tooltips.open({\n children: (\n <>\n <div\n style={{\n color: `#${tinycolor(actualColor).toHex()}`,\n }}\n >\n <strong>{arc.data.key}</strong>\n </div>\n {chart.showValues && (\n <div>{`${arc.value} ${\n arc.data.percentage !== '' &&\n arc.data.percentage !== undefined\n ? '- ' + arc.data.percentage\n : ''\n }${\n arc.data.percentage !== '' &&\n arc.data.percentage !== undefined\n ? '%'\n : ''\n }`}</div>\n )}\n </>\n ),\n attachToElement: () => {\n return ref.current as unknown as HTMLElement;\n },\n attachToElementAnchorPoint: 'center',\n closeOnClickOut: () => {\n return window.innerWidth > 700;\n },\n closeOnMouseLeaveAttachedElement: (ev) => {\n return !(ev.relatedTarget as HTMLElement).closest('.legendItem');\n },\n className: arc.data.key,\n });\n }\n },\n });\n\n return (\n <path\n key={`arc-${name.key}-${name.value}-${outerChartId}`}\n id={`arc-${name.key}-${name.value}-${outerChartId}`}\n ref={ref}\n style={useMemo(\n () => ({\n '&:hover': {\n fill: `#${tinycolor(actualColor).saturate(25).toHex()}`,\n },\n transition: 'fill 500ms, opacity 500ms',\n }),\n [actualColor],\n )}\n color={\n isAnyHighlighted\n ? `#${tinycolor(actualColor).desaturate(70).toHex()}`\n : actualColor\n }\n fill={\n isAnyHighlighted\n ? `#${tinycolor(actualColor).desaturate(70).toHex()}`\n : actualColor\n }\n opacity={isAnyHighlighted && !isHighlighted ? 0.15 : 1}\n d={arcPath ?? ''}\n onMouseEnter={(ev) => {\n legendContainerMethods.highlight(chartId, arc.data.key);\n chartMethods(chartId, 'highlight', `${name.key}_$_${outerChartId}`);\n (ev.target as HTMLElement).classList?.add('over');\n const point = {\n x: localPoint(ev)?.x,\n y: localPoint(ev)?.y,\n };\n if (!point) return;\n }}\n onMouseLeave={(ev) => {\n legendContainerMethods.highlight(chartId, '');\n\n chartMethods(chartId, 'highlight', '');\n (ev.target as HTMLElement).classList?.remove('over');\n }}\n ></path>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAcO,MAAM,QAAQ,CAAC;AAAA,EACpB,GAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAS,EAAA,YAAA;AACX,CAKQ,KAAA;AAEN,EAAA,MAAM,CAAC,aAAA,EAAe,gBAAgB,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AACxD,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AAC9D,EAAM,MAAA,GAAA,GAAM,OAA8B,IAAI,CAAA,CAAA;AAC9C,EAAA,MAAM,OAAO,GAAI,CAAA,IAAA,CAAA;AACjB,EAAA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E,KAAM,EAAC,CACjD,CAAA,GAAA,WAAA;AAAA,MAEN,OAAS,EAAA,gBAAA,IAAoB,CAAC,aAAA,GAAgB,IAAO,GAAA,CAAA;AAAA,MACrD,GAAG,OAAW,IAAA,EAAA;AAAA,MACd,YAAA,EAAc,CAAC,EAAO,KAAA;AACpB,QAAA,sBAAA,CAAuB,SAAU,CAAA,OAAA,EAAS,GAAI,CAAA,IAAA,CAAK,GAAG,CAAA,CAAA;AACtD,QAAA,YAAA,CAAa,SAAS,WAAa,EAAA,CAAA,EAAG,KAAK,GAAG,CAAA,GAAA,EAAM,YAAY,CAAE,CAAA,CAAA,CAAA;AAClE,QAAC,EAAG,CAAA,MAAA,CAAuB,SAAW,EAAA,GAAA,CAAI,MAAM,CAAA,CAAA;AAChD,QAAA,MAAM,KAAQ,GAAA;AAAA,UACZ,CAAA,EAAG,UAAW,CAAA,EAAE,CAAG,EAAA,CAAA;AAAA,UACnB,CAAA,EAAG,UAAW,CAAA,EAAE,CAAG,EAAA,CAAA;AAAA,SACrB,CAAA;AACA,QAAA,IAAI,CAAC,KAAA;AAAO,UAAA,OAAA;AAAA,OACd;AAAA,MACA,YAAA,EAAc,CAAC,EAAO,KAAA;AACpB,QAAuB,sBAAA,CAAA,SAAA,CAAU,SAAS,EAAE,CAAA,CAAA;AAE5C,QAAa,YAAA,CAAA,OAAA,EAAS,aAAa,EAAE,CAAA,CAAA;AACrC,QAAC,EAAG,CAAA,MAAA,CAAuB,SAAW,EAAA,MAAA,CAAO,MAAM,CAAA,CAAA;AAAA,OACrD;AAAA,KAAA;AAAA,IAvCK,OAAO,IAAK,CAAA,GAAG,IAAI,IAAK,CAAA,KAAK,IAAI,YAAY,CAAA,CAAA;AAAA,GAwCnD,CAAA;AAEL;;;;"}
@@ -1,123 +0,0 @@
1
- import { useRef } from 'react';
2
- import { arrayOrArray, animate, addBoundary } from '@apia/util';
3
-
4
- const usePieAnimation = ({
5
- incomingColumn,
6
- piezas,
7
- setDataset
8
- }) => {
9
- const previousObjectRef = useRef(void 0);
10
- const actualObjectRef = useRef(void 0);
11
- const isAnimating = useRef(false);
12
- if (previousObjectRef.current && piezas) {
13
- const previousCoordinates = isAnimating.current && actualObjectRef.current ? arrayOrArray(actualObjectRef.current.coordinate) : arrayOrArray(previousObjectRef.current.coordinate);
14
- const currentCoordinates = arrayOrArray(incomingColumn.sets);
15
- const hasValueChanged = previousCoordinates.some((prevCoord, index) => {
16
- const currentCoord = currentCoordinates[index];
17
- return prevCoord.value !== currentCoord?.value || prevCoord.value === currentCoord?.value && prevCoord.key !== currentCoord.key;
18
- });
19
- if (hasValueChanged) {
20
- isAnimating.current = true;
21
- const difference = [];
22
- for (let i = 0; i < Math.max(previousCoordinates.length, currentCoordinates.length); i++) {
23
- const coord1 = previousCoordinates[i];
24
- const coord2 = currentCoordinates[i];
25
- if (coord1 && coord2) {
26
- const newValue = Math.abs(
27
- parseInt(coord1.value) - parseInt(coord2.value)
28
- ).toString();
29
- const newCoordinate = {
30
- key: coord2.key,
31
- color: coord2.color,
32
- // Assuming color is the same for both coordinates
33
- value: newValue,
34
- percentage: coord2.percentage !== "" && coord2.percentage !== void 0 ? coord2.percentage : void 0
35
- };
36
- difference.push(newCoordinate);
37
- } else if (!coord1 && coord2 && previousCoordinates.length > 0) {
38
- const newValue = Math.abs(0 - parseInt(coord2.value)).toString();
39
- const newCoordinate = {
40
- key: coord2.key,
41
- color: coord2.color,
42
- // Assuming color is the same for both coordinates
43
- value: newValue,
44
- percentage: coord2.percentage !== "" && coord2.percentage !== void 0 ? coord2.percentage : void 0
45
- };
46
- difference.push(newCoordinate);
47
- }
48
- }
49
- return animate(
50
- 500,
51
- (progress) => {
52
- const step = {
53
- color: piezas.color,
54
- name: incomingColumn.name,
55
- sets: difference.map((coord, i) => {
56
- return {
57
- key: coord.key,
58
- color: coord.color,
59
- percentage: coord.percentage,
60
- value: addBoundary(
61
- Number(currentCoordinates[i].value) > Number(
62
- previousCoordinates[i] ? previousCoordinates[i].value : 0
63
- ) ? Number(coord.value) * progress + Number(
64
- previousCoordinates[i] ? previousCoordinates[i].value : 0
65
- ) : Number(
66
- previousCoordinates[i] ? previousCoordinates[i].value : 0
67
- ) - Number(coord.value) * progress,
68
- Math.min(
69
- Number(
70
- previousCoordinates[i] ? previousCoordinates[i].value : 0
71
- ),
72
- Number(currentCoordinates[i].value)
73
- ),
74
- Math.max(
75
- Number(
76
- previousCoordinates[i] ? previousCoordinates[i].value : 0
77
- ),
78
- Number(currentCoordinates[i].value)
79
- )
80
- ).toString()
81
- };
82
- })
83
- };
84
- actualObjectRef.current = {
85
- color: step.color,
86
- coordinate: step.sets,
87
- name: step.name
88
- };
89
- setDataset((prev) => {
90
- const newIndex = prev.findIndex((col) => {
91
- return col.name === step.name;
92
- });
93
- const returnObj = [...prev];
94
- if (newIndex >= 0) {
95
- returnObj[newIndex] = step;
96
- return returnObj;
97
- } else {
98
- return [step];
99
- }
100
- });
101
- },
102
- () => {
103
- const newPrev = {
104
- ...incomingColumn,
105
- coordinate: incomingColumn.sets
106
- };
107
- previousObjectRef.current = newPrev;
108
- isAnimating.current = false;
109
- }
110
- );
111
- }
112
- } else if (!previousObjectRef.current) {
113
- const newPrev = {
114
- ...incomingColumn,
115
- coordinate: incomingColumn.sets
116
- };
117
- previousObjectRef.current = newPrev;
118
- isAnimating.current = false;
119
- }
120
- };
121
-
122
- export { usePieAnimation };
123
- //# sourceMappingURL=usePieAnimation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePieAnimation.js","sources":["../../../src/charts/pie/usePieAnimation.ts"],"sourcesContent":["import React, { useRef } from 'react';\nimport { TApiaChartColumn, TApiaChartCoordinate } from '../types';\nimport {\n addBoundary,\n animate,\n arrayOrArray,\n // useUpdateEffect,\n} from '@apia/util';\n\nexport const usePieAnimation = ({\n incomingColumn,\n piezas,\n setDataset,\n}: {\n incomingColumn: TApiaChartColumn;\n setDataset: React.Dispatch<React.SetStateAction<TApiaChartColumn[]>>;\n piezas: {\n coordinate: TApiaChartCoordinate | TApiaChartCoordinate[];\n color: string;\n sets: TApiaChartCoordinate | TApiaChartCoordinate[];\n name: string;\n };\n}) => {\n const previousObjectRef = useRef<\n | {\n coordinate: TApiaChartCoordinate | TApiaChartCoordinate[];\n color: string;\n name: string;\n }\n | undefined\n >(undefined);\n\n const actualObjectRef = useRef<\n | {\n coordinate: TApiaChartCoordinate | TApiaChartCoordinate[];\n color: string;\n name: string;\n }\n | undefined\n >(undefined);\n\n const isAnimating = useRef(false);\n\n if (previousObjectRef.current && piezas) {\n const previousCoordinates =\n isAnimating.current && actualObjectRef.current\n ? arrayOrArray(actualObjectRef.current.coordinate)\n : arrayOrArray(previousObjectRef.current.coordinate);\n\n const currentCoordinates = arrayOrArray(incomingColumn.sets);\n\n const hasValueChanged = previousCoordinates.some((prevCoord, index) => {\n const currentCoord = currentCoordinates[index];\n\n return (\n prevCoord.value !== currentCoord?.value ||\n (prevCoord.value === currentCoord?.value &&\n prevCoord.key !== currentCoord.key)\n );\n });\n\n if (hasValueChanged) {\n isAnimating.current = true;\n const difference: TApiaChartCoordinate[] = [];\n for (\n let i = 0;\n i < Math.max(previousCoordinates.length, currentCoordinates.length);\n i++\n ) {\n const coord1 = previousCoordinates[i];\n const coord2 = currentCoordinates[i];\n\n if (coord1 && coord2) {\n const newValue = Math.abs(\n parseInt(coord1.value) - parseInt(coord2.value),\n ).toString();\n const newCoordinate: TApiaChartCoordinate = {\n key: coord2.key,\n color: coord2.color, // Assuming color is the same for both coordinates\n value: newValue,\n percentage:\n coord2.percentage !== '' && coord2.percentage !== undefined\n ? coord2.percentage\n : undefined,\n };\n\n difference.push(newCoordinate);\n } else if (!coord1 && coord2 && previousCoordinates.length > 0) {\n const newValue = Math.abs(0 - parseInt(coord2.value)).toString();\n const newCoordinate: TApiaChartCoordinate = {\n key: coord2.key,\n color: coord2.color, // Assuming color is the same for both coordinates\n value: newValue,\n percentage:\n coord2.percentage !== '' && coord2.percentage !== undefined\n ? coord2.percentage\n : undefined,\n };\n\n difference.push(newCoordinate);\n }\n }\n\n return animate(\n 500,\n (progress) => {\n const step: TApiaChartColumn = {\n color: piezas.color,\n name: incomingColumn.name,\n sets: difference.map((coord, i) => {\n return {\n key: coord.key,\n color: coord.color,\n percentage: coord.percentage,\n value: addBoundary(\n Number(currentCoordinates[i].value) >\n Number(\n previousCoordinates[i] ? previousCoordinates[i].value : 0,\n )\n ? Number(coord.value) * progress +\n Number(\n previousCoordinates[i]\n ? previousCoordinates[i].value\n : 0,\n )\n : Number(\n previousCoordinates[i]\n ? previousCoordinates[i].value\n : 0,\n ) -\n Number(coord.value) * progress,\n Math.min(\n Number(\n previousCoordinates[i] ? previousCoordinates[i].value : 0,\n ),\n Number(currentCoordinates[i].value),\n ),\n Math.max(\n Number(\n previousCoordinates[i] ? previousCoordinates[i].value : 0,\n ),\n Number(currentCoordinates[i].value),\n ),\n ).toString(),\n };\n }),\n };\n actualObjectRef.current = {\n color: step.color,\n coordinate: step.sets,\n name: step.name,\n };\n setDataset((prev) => {\n const newIndex = prev.findIndex((col) => {\n return col.name === step.name;\n });\n const returnObj = [...prev];\n if (newIndex >= 0) {\n returnObj[newIndex] = step;\n return returnObj;\n } else {\n return [step];\n }\n });\n },\n () => {\n const newPrev = {\n ...incomingColumn,\n coordinate: incomingColumn.sets,\n };\n previousObjectRef.current = newPrev;\n isAnimating.current = false;\n },\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }\n } else if (!previousObjectRef.current) {\n const newPrev = {\n ...incomingColumn,\n coordinate: incomingColumn.sets,\n };\n previousObjectRef.current = newPrev;\n isAnimating.current = false;\n }\n};\n"],"names":[],"mappings":";;;AASO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,cAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AACF,CASM,KAAA;AACJ,EAAM,MAAA,iBAAA,GAAoB,OAOxB,KAAS,CAAA,CAAA,CAAA;AAEX,EAAM,MAAA,eAAA,GAAkB,OAOtB,KAAS,CAAA,CAAA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AAM,IAAK,CAAA,IAAA;AAAA,WACb,CAAA;AACA,UAAA,UAAA,CAAW,CAAC,IAAS,KAAA;AACnB,YAAA,MAAM,QAAW,GAAA,IAAA,CAAK,SAAU,CAAA,CAAC,GAAQ,KAAA;AACvC,cAAO,OAAA,GAAA,CAAI,SAAS,IAAK,CAAA,IAAA,CAAA;AAAA,aAC1B,CAAA,CAAA;AACD,YAAM,MAAA,SAAA,GAAY,CAAC,GAAG,IAAI,CAAA,CAAA;AAC1B,YAAA,IAAI,YAAY,CAAG,EAAA;AACjB,cAAA,SAAA,CAAU,QAAQ,CAAI,GAAA,IAAA,CAAA;AACtB,cAAO,OAAA,SAAA,CAAA;AAAA,aACF,MAAA;AACL,cAAA,OAAO,CAAC,IAAI,CAAA,CAAA;AAAA,aACd;AAAA,WACD,CAAA,CAAA;AAAA,SACH;AAAA,QACA,MAAM;AACJ,UAAA,MAAM,OAAU,GAAA;AAAA,YACd,GAAG,cAAA;AAAA,YACH,YAAY,cAAe,CAAA,IAAA;AAAA,WAC7B,CAAA;AACA,UAAA,iBAAA,CAAkB,OAAU,GAAA,OAAA,CAAA;AAC5B,UAAA,WAAA,CAAY,OAAU,GAAA,KAAA,CAAA;AAAA,SACxB;AAAA,OACF,CAAA;AAAA,KAEF;AAAA,GACF,MAAA,IAAW,CAAC,iBAAA,CAAkB,OAAS,EAAA;AACrC,IAAA,MAAM,OAAU,GAAA;AAAA,MACd,GAAG,cAAA;AAAA,MACH,YAAY,cAAe,CAAA,IAAA;AAAA,KAC7B,CAAA;AACA,IAAA,iBAAA,CAAkB,OAAU,GAAA,OAAA,CAAA;AAC5B,IAAA,WAAA,CAAY,OAAU,GAAA,KAAA,CAAA;AAAA,GACxB;AACF;;;;"}
@@ -1,36 +0,0 @@
1
- import { jsxs, jsx } from '@apia/theme/jsx-runtime';
2
- import { Select } from '@apia/theme';
3
-
4
- function ChartSelector({
5
- chartId,
6
- pieces,
7
- className,
8
- current,
9
- setCurrent
10
- }) {
11
- return /* @__PURE__ */ jsxs(
12
- Select,
13
- {
14
- sx: { width: "auto" },
15
- name: `chartSelector_${chartId}`,
16
- className: `chartSelector_${chartId} ${className ?? ""}`,
17
- value: current ?? "0",
18
- onChange: (ev) => {
19
- ev.preventDefault();
20
- setCurrent(ev.target.value);
21
- },
22
- children: [
23
- pieces.map((piece, i) => {
24
- return {
25
- label: piece,
26
- value: `${i}`
27
- };
28
- }).map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value)),
29
- " "
30
- ]
31
- }
32
- );
33
- }
34
-
35
- export { ChartSelector as default };
36
- //# sourceMappingURL=ChartSelector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChartSelector.js","sources":["../../../src/charts/util/ChartSelector.tsx"],"sourcesContent":["import { Select } from '@apia/theme';\n\nfunction ChartSelector({\n chartId,\n pieces,\n className,\n current,\n setCurrent,\n}: {\n chartId: string;\n pieces: string[];\n className?: string;\n current: string;\n setCurrent: React.Dispatch<React.SetStateAction<string>>;\n}) {\n return (\n <Select\n sx={{ width: 'auto' }}\n name={`chartSelector_${chartId}`}\n className={`chartSelector_${chartId} ${className ?? ''}`}\n value={current ?? '0'}\n onChange={(ev) => {\n ev.preventDefault();\n setCurrent(ev.target.value);\n }}\n >\n {pieces\n .map((piece, i) => {\n return {\n label: piece,\n value: `${i}`,\n };\n })\n .map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}{' '}\n </Select>\n );\n}\n\nexport default ChartSelector;\n"],"names":[],"mappings":";;;AAEA,SAAS,aAAc,CAAA;AAAA,EACrB,OAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AACF,CAMG,EAAA;AACD,EACE,uBAAA,IAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAI,EAAE,KAAA,EAAO,MAAO,EAAA;AAAA,MACpB,IAAA,EAAM,iBAAiB,OAAO,CAAA,CAAA;AAAA,MAC9B,SAAW,EAAA,CAAA,cAAA,EAAiB,OAAO,CAAA,CAAA,EAAI,aAAa,EAAE,CAAA,CAAA;AAAA,MACtD,OAAO,OAAW,IAAA,GAAA;AAAA,MAClB,QAAA,EAAU,CAAC,EAAO,KAAA;AAChB,QAAA,EAAA,CAAG,cAAe,EAAA,CAAA;AAClB,QAAW,UAAA,CAAA,EAAA,CAAG,OAAO,KAAK,CAAA,CAAA;AAAA,OAC5B;AAAA,MAEC,QAAA,EAAA;AAAA,QACE,MAAA,CAAA,GAAA,CAAI,CAAC,KAAA,EAAO,CAAM,KAAA;AACjB,UAAO,OAAA;AAAA,YACL,KAAO,EAAA,KAAA;AAAA,YACP,KAAA,EAAO,GAAG,CAAC,CAAA,CAAA;AAAA,WACb,CAAA;AAAA,SACD,CAAA,CACA,GAAI,CAAA,CAAC,2BACH,GAAA,CAAA,QAAA,EAAA,EAA0B,KAAO,EAAA,MAAA,CAAO,KACtC,EAAA,QAAA,EAAA,MAAA,CAAO,KADG,EAAA,EAAA,MAAA,CAAO,KAEpB,CACD,CAAA;AAAA,QAAG,GAAA;AAAA,OAAA;AAAA,KAAA;AAAA,GACR,CAAA;AAEJ;;;;"}
@@ -1,46 +0,0 @@
1
- import { jsx } from '@apia/theme/jsx-runtime';
2
- import { ApiaUtil, SimpleButton } from '@apia/components';
3
- import { icons } from '@apia/icons';
4
- import { useCallback } from 'react';
5
- import { chartMethods } from '../ChartRenderer.js';
6
- import { useImperativeComponentContext } from '@apia/util';
7
-
8
- const ColoredLegendItem = ({
9
- groupId,
10
- title,
11
- color,
12
- className,
13
- isHighlighted,
14
- isAnyHighlighted,
15
- avoidEvent
16
- }) => {
17
- const { id: chartId } = useImperativeComponentContext();
18
- const handleMouseEnter = useCallback(() => {
19
- if (avoidEvent) {
20
- return;
21
- }
22
- chartMethods(chartId, "highlight", groupId);
23
- }, [avoidEvent, chartId, groupId]);
24
- const handleMouseLeave = useCallback(() => {
25
- if (avoidEvent) {
26
- return;
27
- }
28
- new ApiaUtil().tooltips.closeAll();
29
- chartMethods(chartId, "highlight", "");
30
- }, [avoidEvent, chartId]);
31
- return /* @__PURE__ */ jsx(
32
- SimpleButton,
33
- {
34
- variant: "link",
35
- className: `${className ?? ""} ${isHighlighted ? "highlight" : ""} ${isAnyHighlighted && !isHighlighted ? "isBlurred" : ""} legendItem`,
36
- iconColor: color || "black",
37
- icon: color === "transparent" ? void 0 : icons.SquareFilled,
38
- onMouseEnter: handleMouseEnter,
39
- onMouseLeave: handleMouseLeave,
40
- children: title
41
- }
42
- );
43
- };
44
-
45
- export { ColoredLegendItem };
46
- //# sourceMappingURL=ColoredLegendItem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColoredLegendItem.js","sources":["../../../src/charts/util/ColoredLegendItem.tsx"],"sourcesContent":["import { SimpleButton } from '@apia/components';\nimport { icons } from '@apia/icons';\nimport { useCallback } from 'react';\nimport { chartMethods } from '../ChartRenderer';\nimport { ApiaUtil } from '@apia/components';\nimport { useImperativeComponentContext } from '@apia/util';\n\nconst ColoredLegendItem = ({\n groupId,\n title,\n color,\n className,\n isHighlighted,\n isAnyHighlighted,\n avoidEvent,\n}: {\n groupId: string;\n title: string;\n color: string;\n className?: string;\n isHighlighted: boolean;\n isAnyHighlighted: boolean;\n avoidEvent: boolean;\n}) => {\n const { id: chartId } = useImperativeComponentContext();\n const handleMouseEnter = useCallback(() => {\n if (avoidEvent) {\n return;\n }\n chartMethods(chartId, 'highlight', groupId);\n }, [avoidEvent, chartId, groupId]);\n const handleMouseLeave = useCallback(() => {\n if (avoidEvent) {\n return;\n }\n new ApiaUtil().tooltips.closeAll();\n chartMethods(chartId, 'highlight', '');\n }, [avoidEvent, chartId]);\n return (\n <SimpleButton\n variant=\"link\"\n className={`${className ?? ''} ${isHighlighted ? 'highlight' : ''} ${\n isAnyHighlighted && !isHighlighted ? 'isBlurred' : ''\n } legendItem`}\n iconColor={color || 'black'}\n icon={color === 'transparent' ? undefined : icons.SquareFilled}\n onMouse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,CAAA,GAAY,KAAM,CAAA,YAAA;AAAA,MAClD,YAAc,EAAA,gBAAA;AAAA,MACd,YAAc,EAAA,gBAAA;AAAA,MAEb,QAAA,EAAA,KAAA;AAAA,KAAA;AAAA,GACH,CAAA;AAEJ;;;;"}
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
-
3
- declare const EmptyGrid: ({ width }: {
4
- width?: number | undefined;
5
- }) => React.JSX.Element;
6
-
7
- export { EmptyGrid };
8
- //# sourceMappingURL=EmptyGrid.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EmptyGrid.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,51 +0,0 @@
1
- import { jsxs, jsx } from '@apia/theme/jsx-runtime';
2
- import { AxisLeft, AxisBottom } from '@visx/axis';
3
- import { scaleBand } from '@visx/scale';
4
- import { Grid } from '@visx/visx';
5
-
6
- const EmptyGrid = ({ width }) => {
7
- const xScale = scaleBand({
8
- range: [0, width ?? 400],
9
- domain: ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"],
10
- padding: 0.2
11
- });
12
- const yScale = scaleBand({
13
- range: [0, 400],
14
- domain: ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"],
15
- padding: 0.2
16
- });
17
- return /* @__PURE__ */ jsxs("svg", { height: 400, width: width ?? 400, children: [
18
- /* @__PURE__ */ jsx(
19
- Grid.Grid,
20
- {
21
- height: 400,
22
- width: width ?? 400,
23
- numTicksRows: 10,
24
- numTicksColumns: 10,
25
- xScale,
26
- yScale
27
- }
28
- ),
29
- /* @__PURE__ */ jsx(
30
- AxisLeft,
31
- {
32
- scale: yScale,
33
- left: 20,
34
- hideTicks: true,
35
- tickLabelProps: { display: "none" }
36
- }
37
- ),
38
- /* @__PURE__ */ jsx(
39
- AxisBottom,
40
- {
41
- scale: xScale,
42
- top: 380,
43
- hideTicks: true,
44
- tickLabelProps: { display: "none" }
45
- }
46
- )
47
- ] });
48
- };
49
-
50
- export { EmptyGrid };
51
- //# sourceMappingURL=EmptyGrid.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EmptyGrid.js","sources":["../../../src/charts/util/EmptyGrid.tsx"],"sourcesContent":["import { AxisBottom, AxisLeft } from '@visx/axis';\nimport { scaleBand } from '@visx/scale';\nimport { Grid } from '@visx/visx';\n\nexport const EmptyGrid = ({ width }: { width?: number }) => {\n const xScale = scaleBand<string>({\n range: [0, width ?? 400],\n domain: ['0', '10', '20', '30', '40', '50', '60', '70', '80', '90', '100'],\n padding: 0.2,\n });\n const yScale = scaleBand<string>({\n range: [0, 400],\n domain: ['0', '10', '20', '30', '40', '50', '60', '70', '80', '90', '100'],\n padding: 0.2,\n });\n return (\n <svg height={400} width={width ?? 400}>\n <Grid.Grid\n height={400}\n width={width ?? 400}\n numTicksRows={10}\n numTicksColumns={10}\n xScale={xScale}\n yScale={yScale}\n />\n <AxisLeft\n scale={yScale}\n left={20}\n hideTicks={true}\n tickLabelProps={{ display: 'none' }}\n />\n <AxisBottom\n scale={xScale}\n top={380}\n hideTicks={true}\n tickLabelProps={{ display: 'none' }}\n />\n </svg>\n );\n};\n"],"names":[],"mappings":";;;;;AAIO,MAAM,SAAY,GAAA,CAAC,EAAE,KAAA,EAAgC,KAAA;AAC1D,EAAA,MAAM,SAAS,SAAkB,CAAA;AAAA,IAC/B,KAAO,EAAA,CAAC,CAAG,EAAA,KAAA,IAAS,GAAG,CAAA;AAAA,IACvB,MAAQ,EAAA,CAAC,GAAK,EAAA,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,KAAK,CAAA;AAAA,IACzE,OAAS,EAAA,GAAA;AAAA,GACV,CAAA,CAAA;AACD,EAAA,MAAM,SAAS,SAAkB,CAAA;AAAA,IAC/B,KAAA,EAAO,CAAC,CAAA,EAAG,GAAG,CAAA;AAAA,IACd,MAAQ,EAAA,CAAC,GAAK,EA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