@apia/charts 1.0.4 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/ChartContext.js +6 -0
- package/dist/charts/ChartContext.js.map +1 -0
- package/dist/charts/ChartRenderer.d.ts +17 -0
- package/dist/charts/ChartRenderer.d.ts.map +1 -0
- package/dist/charts/ChartRenderer.js +175 -0
- package/dist/charts/ChartRenderer.js.map +1 -0
- package/dist/charts/horizontalBars/Bar.js +226 -0
- package/dist/charts/horizontalBars/Bar.js.map +1 -0
- package/dist/charts/horizontalBars/HorizontalBars.js +374 -0
- package/dist/charts/horizontalBars/HorizontalBars.js.map +1 -0
- package/dist/charts/linear/LineChart.js +528 -0
- package/dist/charts/linear/LineChart.js.map +1 -0
- package/dist/charts/linear/Node.js +56 -0
- package/dist/charts/linear/Node.js.map +1 -0
- package/dist/charts/pie/Pie.js +184 -0
- package/dist/charts/pie/Pie.js.map +1 -0
- package/dist/charts/pie/Slice.js +96 -0
- package/dist/charts/pie/Slice.js.map +1 -0
- package/dist/charts/pie/usePieAnimation.js +123 -0
- package/dist/charts/pie/usePieAnimation.js.map +1 -0
- package/dist/charts/types.d.ts +188 -0
- package/dist/charts/types.d.ts.map +1 -0
- package/dist/charts/util/ChartSelector.js +36 -0
- package/dist/charts/util/ChartSelector.js.map +1 -0
- package/dist/charts/util/ColoredLegendItem.js +46 -0
- package/dist/charts/util/ColoredLegendItem.js.map +1 -0
- package/dist/charts/util/EmptyGrid.d.ts +8 -0
- package/dist/charts/util/EmptyGrid.d.ts.map +1 -0
- package/dist/charts/util/EmptyGrid.js +51 -0
- package/dist/charts/util/EmptyGrid.js.map +1 -0
- package/dist/charts/util/LegendContainer.js +53 -0
- package/dist/charts/util/LegendContainer.js.map +1 -0
- package/dist/charts/util/NumberedLegendItem.js +45 -0
- package/dist/charts/util/NumberedLegendItem.js.map +1 -0
- package/dist/charts/util/getBarColor.js +29 -0
- package/dist/charts/util/getBarColor.js.map +1 -0
- package/dist/charts/util/parseMargin.js +11 -0
- package/dist/charts/util/parseMargin.js.map +1 -0
- package/dist/charts/util/useChartStyles.js +35 -0
- package/dist/charts/util/useChartStyles.js.map +1 -0
- package/dist/charts/verticalBars/Bar.js +239 -0
- package/dist/charts/verticalBars/Bar.js.map +1 -0
- package/dist/charts/verticalBars/VerticalBars.js +394 -0
- package/dist/charts/verticalBars/VerticalBars.js.map +1 -0
- package/dist/charts/waterfallBars/WaterfallBar.js +84 -0
- package/dist/charts/waterfallBars/WaterfallBar.js.map +1 -0
- package/dist/charts/waterfallBars/WaterfallBars.js +289 -0
- package/dist/charts/waterfallBars/WaterfallBars.js.map +1 -0
- package/dist/index.d.ts +6 -250
- package/dist/index.js +4 -4263
- package/dist/index.js.map +1 -1
- package/dist/widgets/WidgetContainer.d.ts +10 -0
- package/dist/widgets/WidgetContainer.d.ts.map +1 -0
- package/dist/widgets/WidgetContainer.js +68 -0
- package/dist/widgets/WidgetContainer.js.map +1 -0
- package/dist/widgets/counter/Counter.js +108 -0
- package/dist/widgets/counter/Counter.js.map +1 -0
- package/dist/widgets/custom/useCustomWidget.js +64 -0
- package/dist/widgets/custom/useCustomWidget.js.map +1 -0
- package/dist/widgets/custom/util.js +9 -0
- package/dist/widgets/custom/util.js.map +1 -0
- package/dist/widgets/oxford/Oxford.js +241 -0
- package/dist/widgets/oxford/Oxford.js.map +1 -0
- package/dist/widgets/ring/Ring.js +123 -0
- package/dist/widgets/ring/Ring.js.map +1 -0
- package/dist/widgets/scale/Scale.js +145 -0
- package/dist/widgets/scale/Scale.js.map +1 -0
- package/dist/widgets/speedMeter/SpeedMeter.js +187 -0
- package/dist/widgets/speedMeter/SpeedMeter.js.map +1 -0
- package/dist/widgets/tLight/TLight.js +134 -0
- package/dist/widgets/tLight/TLight.js.map +1 -0
- package/dist/widgets/thermometer/Thermometer.js +144 -0
- package/dist/widgets/thermometer/Thermometer.js.map +1 -0
- package/dist/widgets/thermometer/util.js +31 -0
- package/dist/widgets/thermometer/util.js.map +1 -0
- package/dist/widgets/types.d.ts +41 -0
- package/dist/widgets/types.d.ts.map +1 -0
- package/package.json +30 -43
- package/LICENSE.md +0 -21
- package/README.md +0 -1
- package/cleanDist.json +0 -3
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
type TApiaChartCoordinate = {
|
|
2
|
+
/**
|
|
3
|
+
* Value shown in the X axis.
|
|
4
|
+
* In the case of pie charts, it defines the name of each slice.
|
|
5
|
+
*/
|
|
6
|
+
key: string;
|
|
7
|
+
/**
|
|
8
|
+
* Value shown in the Y axis, or to determine the size and value of slices of
|
|
9
|
+
* a pie chart.
|
|
10
|
+
*/
|
|
11
|
+
value: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional value shown only on the slices of pie charts
|
|
14
|
+
*/
|
|
15
|
+
percentage?: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
};
|
|
18
|
+
type TApiaChartColumn = {
|
|
19
|
+
/**
|
|
20
|
+
* Specific color of a column, does not work on pie charts
|
|
21
|
+
*/
|
|
22
|
+
color: string;
|
|
23
|
+
/**
|
|
24
|
+
* Values of each element
|
|
25
|
+
*/
|
|
26
|
+
sets: TApiaChartCoordinate | TApiaChartCoordinate[];
|
|
27
|
+
/**
|
|
28
|
+
* Name of each column.
|
|
29
|
+
*
|
|
30
|
+
* On bars and line based charts, the legend will show this value.
|
|
31
|
+
*
|
|
32
|
+
* On the pie and waterfall charts, a chart will be created for each column.
|
|
33
|
+
*/
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
type TApiaChartDefinition = {
|
|
37
|
+
chartType?: 'barH2D' | 'barV2D' | 'linear' | 'waterfall' | 'pie2D';
|
|
38
|
+
axisXTitle?: string;
|
|
39
|
+
axisYTitle?: string;
|
|
40
|
+
hideSelector?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The colors of the waterfall chart are defined by the bars with positive
|
|
43
|
+
* values and the bars with negative values. So in order to mantain cohesion
|
|
44
|
+
* in the color schema of the chart, this prop establishes the required colors
|
|
45
|
+
* for the chart
|
|
46
|
+
*/
|
|
47
|
+
waterfallColors?: {
|
|
48
|
+
positive: string;
|
|
49
|
+
negative: string;
|
|
50
|
+
total: string;
|
|
51
|
+
stepConnector: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Name of the schema of colors shown in the chart. Pie charts must always include a schema
|
|
55
|
+
*/
|
|
56
|
+
colorSchema?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Main data to be parsed and shown in the chart.
|
|
59
|
+
* Depending on the ```chartType``` and the amount of ```column``` objects,
|
|
60
|
+
* the data can be considered differently.
|
|
61
|
+
*
|
|
62
|
+
* Examples:
|
|
63
|
+
* ```
|
|
64
|
+
* const columnsWithSingleColumnObject = columns: {
|
|
65
|
+
* column: {
|
|
66
|
+
* color: 'red',
|
|
67
|
+
* coordinate: [
|
|
68
|
+
* { xValue: '1', yValue: '1' },
|
|
69
|
+
* ...,
|
|
70
|
+
* ],
|
|
71
|
+
* name: 'col1',
|
|
72
|
+
* }
|
|
73
|
+
* };
|
|
74
|
+
* ```
|
|
75
|
+
* ```
|
|
76
|
+
* const columnsWithMultipleColumnObject = columns: {
|
|
77
|
+
* column: [
|
|
78
|
+
* {
|
|
79
|
+
* color: 'red',
|
|
80
|
+
* coordinate: [
|
|
81
|
+
* { xValue: '1', yValue: '1' },
|
|
82
|
+
* ...,
|
|
83
|
+
* ],
|
|
84
|
+
* name: 'col1',
|
|
85
|
+
* },
|
|
86
|
+
* ...,
|
|
87
|
+
* ]
|
|
88
|
+
* };
|
|
89
|
+
*```
|
|
90
|
+
*
|
|
91
|
+
*
|
|
92
|
+
* ***Horizontal and Vertical bars***:
|
|
93
|
+
*
|
|
94
|
+
* ```1 column object```:
|
|
95
|
+
*
|
|
96
|
+
* Each ```coordinate``` is considered an individual separate 'column bar',
|
|
97
|
+
* and the ```colorSchema``` is separated between each ```coordinate``` made
|
|
98
|
+
* 'column bar'.
|
|
99
|
+
*
|
|
100
|
+
*
|
|
101
|
+
* ```Multiple column objects```:
|
|
102
|
+
*
|
|
103
|
+
* Each ```column``` object should have the same amount of coordinates and
|
|
104
|
+
* the coordinates in the same index of the array should have the same
|
|
105
|
+
* ```xValue```
|
|
106
|
+
*
|
|
107
|
+
* Each ```coordinate``` is considered an individual separate 'column bar',
|
|
108
|
+
* but the coordinates of each column are re-accommodated based on their
|
|
109
|
+
* ```xValue``` in order to make groups of columns with the same value on the
|
|
110
|
+
* X axis.
|
|
111
|
+
*
|
|
112
|
+
* In this case there will be 6 groups of columns (based on the length of the
|
|
113
|
+
* coordinate array), each group containing 3 'column bars' (based on the
|
|
114
|
+
* amount of column objects) and the ```colorSchema``` will be distributed
|
|
115
|
+
* inside each group, meaning each column having one single color.
|
|
116
|
+
*
|
|
117
|
+
*
|
|
118
|
+
* ***Linear***:
|
|
119
|
+
*
|
|
120
|
+
* ```N column objects```:
|
|
121
|
+
|
|
122
|
+
*
|
|
123
|
+
* Each ```column``` object is considered a line path, the coordinates being
|
|
124
|
+
* the nodes of said line.
|
|
125
|
+
*
|
|
126
|
+
* ***Pie charts***:
|
|
127
|
+
*
|
|
128
|
+
* ```N column objects```:
|
|
129
|
+
*
|
|
130
|
+
* Each ```column``` object is considered a unique Pie chart, the coordinates
|
|
131
|
+
* being the slices of said pie.
|
|
132
|
+
*
|
|
133
|
+
* ***Waterfall***:
|
|
134
|
+
*
|
|
135
|
+
* ```N column objects```:
|
|
136
|
+
*
|
|
137
|
+
* Each ```column``` object is considered a unique Waterfall chart, the coordinates
|
|
138
|
+
* being bars with the ```yValue``` determining if it goes up or down. Only this
|
|
139
|
+
* type of chart admits negative values on its coordinates.
|
|
140
|
+
*
|
|
141
|
+
*/
|
|
142
|
+
dataSets: {
|
|
143
|
+
data: TApiaChartColumn | TApiaChartColumn[];
|
|
144
|
+
};
|
|
145
|
+
margin?: {
|
|
146
|
+
top: number;
|
|
147
|
+
left: number;
|
|
148
|
+
bottom: number;
|
|
149
|
+
right: number;
|
|
150
|
+
} | number;
|
|
151
|
+
pnl_id?: string;
|
|
152
|
+
showAxisXTitle?: boolean;
|
|
153
|
+
showAxisYTitle?: boolean;
|
|
154
|
+
showGrid?: boolean;
|
|
155
|
+
showLegend?: boolean;
|
|
156
|
+
showValues?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Specific for waterfall charts to show the total sum of the values of the
|
|
159
|
+
* chart at the end while each column shows its value. Otherwise the values
|
|
160
|
+
* shown on each bar will represent the current sum of values
|
|
161
|
+
*/
|
|
162
|
+
showTotal?: boolean;
|
|
163
|
+
title: string;
|
|
164
|
+
ratio: {
|
|
165
|
+
height: number;
|
|
166
|
+
width: number;
|
|
167
|
+
maxWidth: number;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
type TChartMargin = {
|
|
171
|
+
top: number;
|
|
172
|
+
bottom: number;
|
|
173
|
+
left: number;
|
|
174
|
+
right: number;
|
|
175
|
+
};
|
|
176
|
+
type TChartRendererProps = {
|
|
177
|
+
chart: TApiaChartDefinition;
|
|
178
|
+
margin?: number | TChartMargin;
|
|
179
|
+
disableEvents?: boolean;
|
|
180
|
+
className?: string;
|
|
181
|
+
chartId: string;
|
|
182
|
+
parentRef?: React.MutableRefObject<HTMLElement>;
|
|
183
|
+
outerClassName?: string;
|
|
184
|
+
allowZoom?: boolean;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export type { TApiaChartColumn, TApiaChartCoordinate, TApiaChartDefinition, TChartMargin, TChartRendererProps };
|
|
188
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
ApiaUtil.instance.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
|
|
@@ -0,0 +1 @@
|
|
|
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 ApiaUtil.instance.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 onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n {title}\n </SimpleButton>\n );\n};\n\nexport { ColoredLegendItem };\n"],"names":[],"mappings":";;;;;;;AAOA,MAAM,oBAAoB,CAAC;AAAA,EACzB,OAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA,UAAA;AACF,CAQM,KAAA;AACJ,EAAA,MAAM,EAAE,EAAA,EAAI,OAAQ,EAAA,GAAI,6BAA8B,EAAA,CAAA;AACtD,EAAM,MAAA,gBAAA,GAAmB,YAAY,MAAM;AACzC,IAAA,IAAI,UAAY,EAAA;AACd,MAAA,OAAA;AAAA,KACF;AACA,IAAa,YAAA,CAAA,OAAA,EAAS,aAAa,OAAO,CAAA,CAAA;AAAA,GACzC,EAAA,CAAC,UAAY,EAAA,OAAA,EAAS,OAAO,CAAC,CAAA,CAAA;AACjC,EAAM,MAAA,gBAAA,GAAmB,YAAY,MAAM;AACzC,IAAA,IAAI,UAAY,EAAA;AACd,MAAA,OAAA;AAAA,KACF;AACA,IAAS,QAAA,CAAA,QAAA,CAAS,SAAS,QAAS,EAAA,CAAA;AACpC,IAAa,YAAA,CAAA,OAAA,EAAS,aAAa,EAAE,CAAA,CAAA;AAAA,GACpC,EAAA,CAAC,UAAY,EAAA,OAAO,CAAC,CAAA,CAAA;AACxB,EACE,uBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,OAAQ,EAAA,MAAA;AAAA,MACR,SAAW,EAAA,CAAA,EAAG,SAAa,IAAA,EAAE,CAAI,CAAA,EAAA,aAAA,GAAgB,WAAc,GAAA,EAAE,CAC/D,CAAA,EAAA,gBAAA,IAAoB,CAAC,aAAA,GAAgB,cAAc,EACrD,CAAA,WAAA,CAAA;AAAA,MACA,WAAW,KAAS,IAAA,OAAA;AAAA,MACpB,IAAM,EAAA,KAAA,KAAU,aAAgB,GAAA,KAAA,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;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmptyGrid.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,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,4BACG,KAAI,EAAA,EAAA,MAAA,EAAQ,GAAK,EAAA,KAAA,EAAO,SAAS,GAChC,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,IAAK,CAAA,IAAA;AAAA,MAAL;AAAA,QACC,MAAQ,EAAA,GAAA;AAAA,QACR,OAAO,KAAS,IAAA,GAAA;AAAA,QAChB,YAAc,EAAA,EAAA;AAAA,QACd,eAAiB,EAAA,EAAA;AAAA,QACjB,MAAA;AAAA,QACA,MAAA;AAAA,OAAA;AAAA,KACF;AAAA,oBACA,GAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,KAAO,EAAA,MAAA;AAAA,QACP,IAAM,EAAA,EAAA;AAAA,QACN,SAAW,EAAA,IAAA;AAAA,QACX,cAAA,EAAgB,EAAE,OAAA,EAAS,MAAO,EAAA;AAAA,OAAA;AAAA,KACpC;AAAA,oBACA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,KAAO,EAAA,MAAA;AAAA,QACP,GAAK,EAAA,GAAA;AAAA,QACL,SAAW,EAAA,IAAA;AAAA,QACX,cAAA,EAAgB,EAAE,OAAA,EAAS,MAAO,EAAA;AAAA,OAAA;AAAA,KACpC;AAAA,GACF,EAAA,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx } from '@apia/theme/jsx-runtime';
|
|
2
|
+
import { Box } from '@apia/theme';
|
|
3
|
+
import { ColoredLegendItem } from './ColoredLegendItem.js';
|
|
4
|
+
import { makeImperativeComponent } from '@apia/util';
|
|
5
|
+
import { NumberedLegendItem } from './NumberedLegendItem.js';
|
|
6
|
+
|
|
7
|
+
const [legendContainerMethods, , LegendContainer] = makeImperativeComponent()({
|
|
8
|
+
initialState: {
|
|
9
|
+
highlightedBarGroup: ""
|
|
10
|
+
},
|
|
11
|
+
methods: {
|
|
12
|
+
highlight(setState, highlightedBarGroup) {
|
|
13
|
+
setState({ highlightedBarGroup });
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
Component: ({
|
|
17
|
+
references,
|
|
18
|
+
highlightedBarGroup,
|
|
19
|
+
avoidEvent,
|
|
20
|
+
useNumbered
|
|
21
|
+
}) => {
|
|
22
|
+
return /* @__PURE__ */ jsx(Box, { className: `legendContainer`, children: !useNumbered ? references.map((data) => {
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
ColoredLegendItem,
|
|
25
|
+
{
|
|
26
|
+
isHighlighted: data.title === highlightedBarGroup,
|
|
27
|
+
isAnyHighlighted: highlightedBarGroup !== "",
|
|
28
|
+
groupId: data.title,
|
|
29
|
+
color: data.color,
|
|
30
|
+
title: data.title,
|
|
31
|
+
avoidEvent: avoidEvent ?? false
|
|
32
|
+
},
|
|
33
|
+
data.title
|
|
34
|
+
);
|
|
35
|
+
}) : references.map((data, i) => {
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
NumberedLegendItem,
|
|
38
|
+
{
|
|
39
|
+
isHighlighted: data.title === highlightedBarGroup,
|
|
40
|
+
isAnyHighlighted: highlightedBarGroup !== "",
|
|
41
|
+
groupId: data.title,
|
|
42
|
+
position: `${i + 1}`,
|
|
43
|
+
title: data.title,
|
|
44
|
+
avoidEvent: avoidEvent ?? false
|
|
45
|
+
},
|
|
46
|
+
data.title
|
|
47
|
+
);
|
|
48
|
+
}) });
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export { LegendContainer, legendContainerMethods };
|
|
53
|
+
//# sourceMappingURL=LegendContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegendContainer.js","sources":["../../../src/charts/util/LegendContainer.tsx"],"sourcesContent":["import { Box } from '@apia/theme';\nimport { ColoredLegendItem } from './ColoredLegendItem';\nimport { makeImperativeComponent } from '@apia/util';\nimport { NumberedLegendItem } from './NumberedLegendItem';\n\nexport type TChartReference = {\n color: string;\n title: string;\n}[];\n\nexport const [legendContainerMethods, , LegendContainer] =\n makeImperativeComponent<\n {\n references: TChartReference;\n itemClassName?: string;\n avoidEvent?: boolean;\n useNumbered?: boolean;\n },\n never\n >()({\n initialState: {\n highlightedBarGroup: '',\n },\n methods: {\n highlight(setState, highlightedBarGroup: string) {\n setState({ highlightedBarGroup });\n },\n },\n Component: ({\n references,\n highlightedBarGroup,\n avoidEvent,\n useNumbered,\n }) => {\n return (\n <Box className={`legendContainer`}>\n {!useNumbered\n ? references.map((data) => {\n return (\n <ColoredLegendItem\n isHighlighted={data.title === highlightedBarGroup}\n isAnyHighlighted={highlightedBarGroup !== ''}\n groupId={data.title}\n key={data.title}\n color={data.color}\n title={data.title}\n avoidEvent={avoidEvent ?? false}\n />\n );\n })\n : references.map((data, i) => {\n return (\n <NumberedLegendItem\n isHighlighted={data.title === highlightedBarGroup}\n isAnyHighlighted={highlightedBarGroup !== ''}\n groupId={data.title}\n key={data.title}\n position={`${i + 1}`}\n title={data.title}\n avoidEvent={avoidEvent ?? false}\n />\n );\n })}\n </Box>\n );\n },\n });\n"],"names":[],"mappings":";;;;;;AAUO,MAAM,CAAC,sBAAwB,IAAE,eAAe,CAAA,GACrD,yBAQI,CAAA;AAAA,EACF,YAAc,EAAA;AAAA,IACZ,mBAAqB,EAAA,EAAA;AAAA,GACvB;AAAA,EACA,OAAS,EAAA;AAAA,IACP,SAAA,CAAU,UAAU,mBAA6B,EAAA;AAC/C,MAAS,QAAA,CAAA,EAAE,qBAAqB,CAAA,CAAA;AAAA,KAClC;AAAA,GACF;AAAA,EACA,WAAW,CAAC;AAAA,IACV,UAAA;AAAA,IACA,mBAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,GACI,KAAA;AACJ,IACE,uBAAA,GAAA,CAAC,OAAI,SAAW,EAAA,CAAA,eAAA,CAAA,EACb,WAAC,WACE,GAAA,UAAA,CAAW,GAAI,CAAA,CAAC,IAAS,KAAA;AACvB,MACE,uBAAA,GAAA;AAAA,QAAC,iBAAA;AAAA,QAAA;AAAA,UACC,aAAA,EAAe,KAAK,KAAU,KAAA,mBAAA;AAAA,UAC9B,kBAAkB,mBAAwB,KAAA,EAAA;AAAA,UAC1C,SAAS,IAAK,CAAA,KAAA;AAAA,UAEd,OAAO,IAAK,CAAA,KAAA;AAAA,UACZ,OAAO,IAAK,CAAA,KAAA;AAAA,UACZ,YAAY,UAAc,IAAA,KAAA;AAAA,SAAA;AAAA,QAHrB,IAAK,CAAA,KAAA;AAAA,OAIZ,CAAA;AAAA,KAEH,CACD,GAAA,UAAA,CAAW,GAAI,CAAA,CAAC,MAAM,CAAM,KAAA;AAC1B,MACE,uBAAA,GAAA;AAAA,QAAC,kBAAA;AAAA,QAAA;AAAA,UACC,aAAA,EAAe,KAAK,KAAU,KAAA,mBAAA;AAAA,UAC9B,kBAAkB,mBAAwB,KAAA,EAAA;AAAA,UAC1C,SAAS,IAAK,CAAA,KAAA;AAAA,UAEd,QAAA,EAAU,CAAG,EAAA,CAAA,GAAI,CAAC,CAAA,CAAA;AAAA,UAClB,OAAO,IAAK,CAAA,KAAA;AAAA,UACZ,YAAY,UAAc,IAAA,KAAA;AAAA,SAAA;AAAA,QAHrB,IAAK,CAAA,KAAA;AAAA,OAIZ,CAAA;AAAA,KAEH,CACP,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from '@apia/theme/jsx-runtime';
|
|
2
|
+
import { ApiaUtil, SimpleButton } from '@apia/components';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { chartMethods } from '../ChartRenderer.js';
|
|
5
|
+
import { useImperativeComponentContext } from '@apia/util';
|
|
6
|
+
|
|
7
|
+
const NumberedLegendItem = ({
|
|
8
|
+
groupId,
|
|
9
|
+
title,
|
|
10
|
+
className,
|
|
11
|
+
isHighlighted,
|
|
12
|
+
isAnyHighlighted,
|
|
13
|
+
avoidEvent
|
|
14
|
+
}) => {
|
|
15
|
+
const { id: chartId } = useImperativeComponentContext();
|
|
16
|
+
const handleMouseEnter = useCallback(() => {
|
|
17
|
+
if (avoidEvent) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
chartMethods(chartId, "highlight", groupId);
|
|
21
|
+
}, [avoidEvent, chartId, groupId]);
|
|
22
|
+
const handleMouseLeave = useCallback(() => {
|
|
23
|
+
if (avoidEvent) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
ApiaUtil.instance.tooltips.closeAll();
|
|
27
|
+
chartMethods(chartId, "highlight", "");
|
|
28
|
+
}, [avoidEvent, chartId]);
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
SimpleButton,
|
|
31
|
+
{
|
|
32
|
+
variant: "link",
|
|
33
|
+
className: `${className ?? ""} ${isHighlighted ? "highlight" : ""} ${isAnyHighlighted && !isHighlighted ? "isBlurred" : ""} legendItem`,
|
|
34
|
+
sx: {
|
|
35
|
+
opacity: isAnyHighlighted && !isHighlighted ? "0.15" : "1"
|
|
36
|
+
},
|
|
37
|
+
onMouseEnter: handleMouseEnter,
|
|
38
|
+
onMouseLeave: handleMouseLeave,
|
|
39
|
+
children: title
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { NumberedLegendItem };
|
|
45
|
+
//# sourceMappingURL=NumberedLegendItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberedLegendItem.js","sources":["../../../src/charts/util/NumberedLegendItem.tsx"],"sourcesContent":["import { SimpleButton } from '@apia/components';\nimport { useCallback } from 'react';\nimport { chartMethods } from '../ChartRenderer';\nimport { useImperativeComponentContext } from '@apia/util';\nimport { ApiaUtil } from '@apia/components';\n\nconst NumberedLegendItem = ({\n groupId,\n title,\n className,\n isHighlighted,\n isAnyHighlighted,\n avoidEvent,\n}: {\n groupId: string;\n title: string;\n position: 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 ApiaUtil.instance.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 sx={{\n opacity: isAnyHighlighted && !isHighlighted ? '0.15' : '1',\n }}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n {title}\n </SimpleButton>\n );\n};\n\nexport { NumberedLegendItem };\n"],"names":[],"mappings":";;;;;;AAMA,MAAM,qBAAqB,CAAC;AAAA,EAC1B,OAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA,UAAA;AACF,CAQM,KAAA;AACJ,EAAA,MAAM,EAAE,EAAA,EAAI,OAAQ,EAAA,GAAI,6BAA8B,EAAA,CAAA;AACtD,EAAM,MAAA,gBAAA,GAAmB,YAAY,MAAM;AACzC,IAAA,IAAI,UAAY,EAAA;AACd,MAAA,OAAA;AAAA,KACF;AACA,IAAa,YAAA,CAAA,OAAA,EAAS,aAAa,OAAO,CAAA,CAAA;AAAA,GACzC,EAAA,CAAC,UAAY,EAAA,OAAA,EAAS,OAAO,CAAC,CAAA,CAAA;AACjC,EAAM,MAAA,gBAAA,GAAmB,YAAY,MAAM;AACzC,IAAA,IAAI,UAAY,EAAA;AACd,MAAA,OAAA;AAAA,KACF;AACA,IAAS,QAAA,CAAA,QAAA,CAAS,SAAS,QAAS,EAAA,CAAA;AACpC,IAAa,YAAA,CAAA,OAAA,EAAS,aAAa,EAAE,CAAA,CAAA;AAAA,GACpC,EAAA,CAAC,UAAY,EAAA,OAAO,CAAC,CAAA,CAAA;AACxB,EACE,uBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,OAAQ,EAAA,MAAA;AAAA,MACR,SAAW,EAAA,CAAA,EAAG,SAAa,IAAA,EAAE,CAAI,CAAA,EAAA,aAAA,GAAgB,WAAc,GAAA,EAAE,CAC/D,CAAA,EAAA,gBAAA,IAAoB,CAAC,aAAA,GAAgB,cAAc,EACrD,CAAA,WAAA,CAAA;AAAA,MACA,EAAI,EAAA;AAAA,QACF,OAAS,EAAA,gBAAA,IAAoB,CAAC,aAAA,GAAgB,MAAS,GAAA,GAAA;AAAA,OACzD;AAAA,MACA,YAAc,EAAA,gBAAA;AAAA,MACd,YAAc,EAAA,gBAAA;AAAA,MAEb,QAAA,EAAA,KAAA;AAAA,KAAA;AAAA,GACH,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import tinycolor from 'tinycolor2';
|
|
2
|
+
|
|
3
|
+
function getBarColor(colors, index, alwaysDiffer = false) {
|
|
4
|
+
const module = colors.length;
|
|
5
|
+
let count = 0;
|
|
6
|
+
let barColor = "";
|
|
7
|
+
if (!alwaysDiffer) {
|
|
8
|
+
if (colors[index]) {
|
|
9
|
+
barColor = colors[index];
|
|
10
|
+
} else {
|
|
11
|
+
let innerIndex = index;
|
|
12
|
+
while (innerIndex >= module) {
|
|
13
|
+
innerIndex = index / module;
|
|
14
|
+
count++;
|
|
15
|
+
}
|
|
16
|
+
barColor = tinycolor(colors[index % module]).desaturate(count * 5).toHex().startsWith("#") ? tinycolor(colors[index % module]).desaturate(count * 5).toHex() : `#${tinycolor(colors[index % module]).desaturate(count * 5).toHex()}`;
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
if (colors[index]) {
|
|
20
|
+
barColor = colors[index];
|
|
21
|
+
} else {
|
|
22
|
+
barColor = tinycolor(colors[index % module]).toHex();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return barColor;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { getBarColor };
|
|
29
|
+
//# sourceMappingURL=getBarColor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBarColor.js","sources":["../../../src/charts/util/getBarColor.tsx"],"sourcesContent":["import tinycolor from 'tinycolor2';\n\nexport function getBarColor(\n colors: string[],\n index: number,\n alwaysDiffer = false,\n) {\n const module = colors.length;\n let count = 0;\n let barColor = '';\n if (!alwaysDiffer) {\n if (colors[index]) {\n barColor = colors[index];\n } else {\n let innerIndex = index;\n while (innerIndex >= module) {\n innerIndex = index / module;\n count++;\n }\n barColor = tinycolor(colors[index % module])\n .desaturate(count * 5)\n .toHex()\n .startsWith('#')\n ? tinycolor(colors[index % module])\n .desaturate(count * 5)\n .toHex()\n : `#${tinycolor(colors[index % module])\n .desaturate(count * 5)\n .toHex()}`;\n }\n } else {\n if (colors[index]) {\n barColor = colors[index];\n } else {\n barColor = tinycolor(colors[index % module]).toHex();\n }\n }\n return barColor;\n}\n"],"names":[],"mappings":";;AAEO,SAAS,WACd,CAAA,MAAA,EACA,KACA,EAAA,YAAA,GAAe,KACf,EAAA;AACA,EAAA,MAAM,SAAS,MAAO,CAAA,MAAA,CAAA;AACtB,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAA,IAAI,QAAW,GAAA,EAAA,CAAA;AACf,EAAA,IAAI,CAAC,YAAc,EAAA;AACjB,IAAI,IAAA,MAAA,CAAO,KAAK,CAAG,EAAA;AACjB,MAAA,QAAA,GAAW,OAAO,KAAK,CAAA,CAAA;AAAA,KAClB,MAAA;AACL,MAAA,IAAI,UAAa,GAAA,KAAA,CAAA;AACjB,MAAA,OAAO,cAAc,MAAQ,EAAA;AAC3B,QAAA,UAAA,GAAa,KAAQ,GAAA,MAAA,CAAA;AACrB,QAAA,KAAA,EAAA,CAAA;AAAA,OACF;AACA,MAAA,QAAA,GAAW,UAAU,MAAO,CAAA,KAAA,GAAQ,MAAM,CAAC,EACxC,UAAW,CAAA,KAAA,GAAQ,CAAC,CAAA,CACpB,OACA,CAAA,UAAA,CAAW,GAAG,CACb,GAAA,SAAA,CAAU,OAAO,KAAQ,GAAA,MAAM,CAAC,CAAA,CAC7B,WAAW,KAAQ,GAAA,CAAC,EACpB,KAAM,EAAA,GACT,IAAI,SAAU,CAAA,MAAA,CAAO,KAAQ,GAAA,MAAM,CAAC,CACjC,CAAA,UAAA,CAAW,QAAQ,CAAC,CAAA,CACpB,OAAO,CAAA,CAAA,CAAA;AAAA,KAChB;AAAA,GACK,MAAA;AACL,IAAI,IAAA,MAAA,CAAO,KAAK,CAAG,EAAA;AACjB,MAAA,QAAA,GAAW,OAAO,KAAK,CAAA,CAAA;AAAA,KAClB,MAAA;AACL,MAAA,QAAA,GAAW,UAAU,MAAO,CAAA,KAAA,GAAQ,MAAM,CAAC,EAAE,KAAM,EAAA,CAAA;AAAA,KACrD;AAAA,GACF;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function parseMargin(margin = {
|
|
2
|
+
left: 100,
|
|
3
|
+
right: 50,
|
|
4
|
+
top: 50,
|
|
5
|
+
bottom: 70
|
|
6
|
+
}) {
|
|
7
|
+
return typeof margin === "number" ? { left: margin, right: margin, top: margin, bottom: margin } : margin;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { parseMargin };
|
|
11
|
+
//# sourceMappingURL=parseMargin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseMargin.js","sources":["../../../src/charts/util/parseMargin.ts"],"sourcesContent":["import { TChartRendererProps } from '../types';\n\nexport function parseMargin(\n margin: TChartRendererProps['margin'] = {\n left: 100,\n right: 50,\n top: 50,\n bottom: 70,\n },\n) {\n return typeof margin === 'number'\n ? { left: margin, right: margin, top: margin, bottom: margin }\n : margin;\n}\n"],"names":[],"mappings":"AAEO,SAAS,YACd,MAAwC,GAAA;AAAA,EACtC,IAAM,EAAA,GAAA;AAAA,EACN,KAAO,EAAA,EAAA;AAAA,EACP,GAAK,EAAA,EAAA;AAAA,EACL,MAAQ,EAAA,EAAA;AACV,CACA,EAAA;AACA,EAAA,OAAO,OAAO,MAAA,KAAW,QACrB,GAAA,EAAE,IAAM,EAAA,MAAA,EAAQ,KAAO,EAAA,MAAA,EAAQ,GAAK,EAAA,MAAA,EAAQ,MAAQ,EAAA,MAAA,EACpD,GAAA,MAAA,CAAA;AACN;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useThemeUI } from '@apia/theme';
|
|
2
|
+
import { getValueByPath } from '@apia/util';
|
|
3
|
+
|
|
4
|
+
function useChartStyles(schemeName) {
|
|
5
|
+
const { theme } = useThemeUI();
|
|
6
|
+
if (!theme.layout)
|
|
7
|
+
console.error("The layout property is missing in the current theme");
|
|
8
|
+
const charts = theme.layout?.charts ?? {};
|
|
9
|
+
const defaultStyles = charts.common;
|
|
10
|
+
const currentStylescheme = {
|
|
11
|
+
schema: getValueByPath(
|
|
12
|
+
theme.colors,
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
14
|
+
charts[schemeName && schemeName !== "0" ? schemeName : "blue"]?.schema
|
|
15
|
+
)
|
|
16
|
+
};
|
|
17
|
+
if (typeof currentStylescheme.schema === "object" && currentStylescheme.schema) {
|
|
18
|
+
const returnStyles = Object.entries(
|
|
19
|
+
currentStylescheme.schema
|
|
20
|
+
).map((e) => {
|
|
21
|
+
const element = document.querySelector("*");
|
|
22
|
+
if (element) {
|
|
23
|
+
if (e[1].startsWith("var(")) {
|
|
24
|
+
return window.getComputedStyle(element).getPropertyValue(e[1].slice(4, -1));
|
|
25
|
+
}
|
|
26
|
+
return window.getComputedStyle(element).getPropertyValue(e[1]);
|
|
27
|
+
}
|
|
28
|
+
return window.getComputedStyle(document.querySelector("*")).getPropertyValue(e[1]);
|
|
29
|
+
});
|
|
30
|
+
return { ...defaultStyles, schema: returnStyles };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { useChartStyles };
|
|
35
|
+
//# sourceMappingURL=useChartStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChartStyles.js","sources":["../../../src/charts/util/useChartStyles.ts"],"sourcesContent":["import { ColorModesScale, ThemeUIStyleObject, useThemeUI } from '@apia/theme';\nimport { IChartStylesSchemes, TChartStylesDefinition } from '../types';\nimport { getValueByPath } from '@apia/util';\n\nexport function useChartStyles(\n schemeName?: string,\n): TChartStylesDefinition | undefined {\n const { theme } = useThemeUI();\n\n if (!theme.layout)\n console.error('The layout property is missing in the current theme');\n\n const charts = ((theme.layout as Record<string, ThemeUIStyleObject>)\n ?.charts ?? {}) as IChartStylesSchemes;\n const defaultStyles = charts.common;\n const currentStylescheme = {\n schema: getValueByPath(\n theme.colors as ColorModesScale,\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n charts[schemeName && schemeName !== '0' ? schemeName : 'blue']\n ?.schema as string,\n ),\n };\n if (\n typeof currentStylescheme.schema === 'object' &&\n currentStylescheme.schema\n ) {\n const returnStyles: string[] = Object.entries(\n currentStylescheme.schema,\n ).map((e) => {\n const element = document.querySelector('*');\n if (element) {\n if ((e[1] as string).startsWith('var(')) {\n return window\n .getComputedStyle(element)\n .getPropertyValue((e[1] as string).slice(4, -1));\n }\n return window\n .getComputedStyle(element)\n .getPropertyValue(e[1] as unknown as string);\n }\n\n return window\n .getComputedStyle(document.querySelector('*') as Element)\n .getPropertyValue(e[1] as unknown as string);\n });\n return { ...defaultStyles, schema: returnStyles };\n }\n // return {\n // ...defaultStyles,\n // ...currentStylescheme,\n // };\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,eACd,UACoC,EAAA;AACpC,EAAM,MAAA,EAAE,KAAM,EAAA,GAAI,UAAW,EAAA,CAAA;AAE7B,EAAA,IAAI,CAAC,KAAM,CAAA,MAAA;AACT,IAAA,OAAA,CAAQ,MAAM,qDAAqD,CAAA,CAAA;AAErE,EAAA,MAAM,MAAW,GAAA,KAAA,CAAM,MACnB,EAAA,MAAA,IAAU,EAAC,CAAA;AACf,EAAA,MAAM,gBAAgB,MAAO,CAAA,MAAA,CAAA;AAC7B,EAAA,MAAM,kBAAqB,GAAA;AAAA,IACzB,MAAQ,EAAA,cAAA;AAAA,MACN,KAAM,CAAA,MAAA;AAAA;AAAA,MAEN,OAAO,UAAc,IAAA,UAAA,KAAe,GAAM,GAAA,UAAA,GAAa,MAAM,CACzD,EAAA,MAAA;AAAA,KACN;AAAA,GACF,CAAA;AACA,EAAA,IACE,OAAO,kBAAA,CAAmB,MAAW,KAAA,QAAA,IACrC,mBAAmB,MACnB,EAAA;AACA,IAAA,MAAM,eAAyB,MAAO,CAAA,OAAA;AAAA,MACpC,kBAAmB,CAAA,MAAA;AAAA,KACrB,CAAE,GAAI,CAAA,CAAC,CAAM,KAAA;AACX,MAAM,MAAA,OAAA,GAAU,QAAS,CAAA,aAAA,CAAc,GAAG,CAAA,CAAA;AAC1C,MAAA,IAAI,OAAS,EAAA;AACX,QAAA,IAAK,CAAE,CAAA,CAAC,CAAa,CAAA,UAAA,CAAW,MAAM,CAAG,EAAA;AACvC,UAAO,OAAA,MAAA,CACJ,gBAAiB,CAAA,OAAO,CACxB,CAAA,gBAAA,CAAkB,CAAE,CAAA,CAAC,CAAa,CAAA,KAAA,CAAM,CAAG,EAAA,CAAA,CAAE,CAAC,CAAA,CAAA;AAAA,SACnD;AACA,QAAA,OAAO,OACJ,gBAAiB,CAAA,OAAO,EACxB,gBAAiB,CAAA,CAAA,CAAE,CAAC,CAAsB,CAAA,CAAA;AAAA,OAC/C;AAEA,MAAO,OAAA,MAAA,CACJ,gBAAiB,CAAA,QAAA,CAAS,aAAc,CAAA,GAAG,CAAY,CACvD,CAAA,gBAAA,CAAiB,CAAE,CAAA,CAAC,CAAsB,CAAA,CAAA;AAAA,KAC9C,CAAA,CAAA;AACD,IAAA,OAAO,EAAE,GAAG,aAAe,EAAA,MAAA,EAAQ,YAAa,EAAA,CAAA;AAAA,GAClD;AAKF;;;;"}
|