@m4l/widgets 0.0.2-beta-add-widget-piechart.0 → 0.0.2
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/charts/Pie/Pie.d.ts +4 -4
- package/charts/Pie/Pie.styles.d.ts.map +1 -1
- package/charts/Pie/Pie.styles.js +12 -11
- package/charts/Pie/helpers/options.d.ts +1 -1
- package/charts/Pie/hooks/useChartResize.d.ts +3 -3
- package/charts/Pie/hooks/usePieChartData.d.ts +1 -1
- package/charts/Pie/slots/PieEnum.d.ts +2 -2
- package/charts/Pie/subcomponents/CustomLegend/CustomLegend.d.ts +7 -7
- package/charts/Pie/subcomponents/CustomLegend/types.d.ts +1 -1
- package/charts/Pie/types.d.ts +15 -15
- package/charts/Pie/types.d.ts.map +1 -1
- package/package.json +1 -4
package/charts/Pie/Pie.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PieProps } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param values -
|
|
5
|
-
* @param size -
|
|
6
|
-
* @returns
|
|
3
|
+
* Pie component for the pie chart.
|
|
4
|
+
* @param values - Values for the chart
|
|
5
|
+
* @param size - Component size
|
|
6
|
+
* @returns Pie component
|
|
7
7
|
*/
|
|
8
8
|
export declare function Pie({ values, size }: PieProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
9
|
export default Pie;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pie.styles.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/Pie/Pie.styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"Pie.styles.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/Pie/Pie.styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,eAAO,MAAM,SAAS,EAAE,SAkNvB,CAAC"}
|
package/charts/Pie/Pie.styles.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getTypographyStyles as i } from "@m4l/components";
|
|
|
2
2
|
const a = {
|
|
3
3
|
/**
|
|
4
4
|
* ***************************************************************
|
|
5
|
-
*
|
|
5
|
+
* Root container: container query context for responsive layout.
|
|
6
6
|
* ***************************************************************
|
|
7
7
|
*/
|
|
8
8
|
pieRoot: () => ({
|
|
@@ -13,7 +13,7 @@ const a = {
|
|
|
13
13
|
}),
|
|
14
14
|
/**
|
|
15
15
|
* ******************************************************************
|
|
16
|
-
*
|
|
16
|
+
* Inner flex container wrapping the chart and the legend.
|
|
17
17
|
* ******************************************************************
|
|
18
18
|
*/
|
|
19
19
|
pieParent: () => ({
|
|
@@ -25,7 +25,7 @@ const a = {
|
|
|
25
25
|
}),
|
|
26
26
|
/**
|
|
27
27
|
* *******************************************************************
|
|
28
|
-
*
|
|
28
|
+
* Left box: chart container. ReactECharts is rendered inside.
|
|
29
29
|
* *******************************************************************
|
|
30
30
|
*/
|
|
31
31
|
chartContainer: () => ({
|
|
@@ -62,9 +62,10 @@ const a = {
|
|
|
62
62
|
}),
|
|
63
63
|
/**
|
|
64
64
|
* ********************************************************************
|
|
65
|
-
*
|
|
65
|
+
* Right box: legend container. CustomLegend is rendered inside.
|
|
66
66
|
* ********************************************************************
|
|
67
67
|
*/
|
|
68
|
+
/** Returns style object for the legend grid based on theme and ownerState. */
|
|
68
69
|
legendContainer: ({ theme: e, ownerState: t }) => ({
|
|
69
70
|
display: "grid",
|
|
70
71
|
gridAutoFlow: "row",
|
|
@@ -98,7 +99,7 @@ const a = {
|
|
|
98
99
|
}),
|
|
99
100
|
/**
|
|
100
101
|
* ******************************************************************
|
|
101
|
-
*
|
|
102
|
+
* Legend item (Grid).
|
|
102
103
|
* ******************************************************************
|
|
103
104
|
*/
|
|
104
105
|
legendItem: ({ theme: e }) => ({
|
|
@@ -112,7 +113,7 @@ const a = {
|
|
|
112
113
|
}),
|
|
113
114
|
/**
|
|
114
115
|
* ******************************************************************
|
|
115
|
-
*
|
|
116
|
+
* Color dot of the legend item.
|
|
116
117
|
* ******************************************************************
|
|
117
118
|
*/
|
|
118
119
|
legendItemColor: ({ theme: e, ownerState: t }) => ({
|
|
@@ -124,7 +125,7 @@ const a = {
|
|
|
124
125
|
}),
|
|
125
126
|
/**
|
|
126
127
|
* ******************************************************************
|
|
127
|
-
*
|
|
128
|
+
* Text container of the legend item.
|
|
128
129
|
* ******************************************************************
|
|
129
130
|
*/
|
|
130
131
|
legendItemTextContainer: ({ theme: e }) => ({
|
|
@@ -136,7 +137,7 @@ const a = {
|
|
|
136
137
|
}),
|
|
137
138
|
/**
|
|
138
139
|
* ******************************************************************
|
|
139
|
-
*
|
|
140
|
+
* Sub text container of the legend item.
|
|
140
141
|
* ******************************************************************
|
|
141
142
|
*/
|
|
142
143
|
legendItemTextSubContainer: ({ theme: e }) => ({
|
|
@@ -147,7 +148,7 @@ const a = {
|
|
|
147
148
|
}),
|
|
148
149
|
/**
|
|
149
150
|
* ******************************************************************
|
|
150
|
-
*
|
|
151
|
+
* Name of the legend item.
|
|
151
152
|
* ******************************************************************
|
|
152
153
|
*/
|
|
153
154
|
legendItemName: ({ theme: e, ownerState: t }) => ({
|
|
@@ -159,7 +160,7 @@ const a = {
|
|
|
159
160
|
}),
|
|
160
161
|
/**
|
|
161
162
|
* ******************************************************************
|
|
162
|
-
*
|
|
163
|
+
* Value badge of the legend item.
|
|
163
164
|
* ******************************************************************
|
|
164
165
|
*/
|
|
165
166
|
legendItemValueBadge: ({ theme: e, ownerState: t }) => ({
|
|
@@ -176,7 +177,7 @@ const a = {
|
|
|
176
177
|
}),
|
|
177
178
|
/**
|
|
178
179
|
* ******************************************************************
|
|
179
|
-
*
|
|
180
|
+
* Category of the legend item.
|
|
180
181
|
* ******************************************************************
|
|
181
182
|
*/
|
|
182
183
|
legendItemCategory: ({ theme: e, ownerState: t }) => ({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PieChartData } from '../types';
|
|
2
2
|
import { Theme } from '@mui/material/styles';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Builds the ECharts options configuration for the pie chart from data and theme.
|
|
5
5
|
*/
|
|
6
6
|
export declare function generateOptions(data: PieChartData[], theme: Theme): {
|
|
7
7
|
baseOption: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { default as ReactECharts } from 'echarts-for-react';
|
|
2
2
|
/**
|
|
3
|
-
* Custom hook
|
|
4
|
-
* @param chartRef -
|
|
5
|
-
* @returns
|
|
3
|
+
* Custom hook to resize the chart when the container size changes.
|
|
4
|
+
* @param chartRef - Reference to the chart element
|
|
5
|
+
* @returns Reference setter for the chart parent element
|
|
6
6
|
*/
|
|
7
7
|
export declare function useChartResize(chartRef: React.RefObject<ReactECharts | null>): (node: HTMLDivElement | null) => void;
|
|
8
8
|
//# sourceMappingURL=useChartResize.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PieProps } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Returns the remapped pie chart data and ECharts options for the given values and current theme.
|
|
4
4
|
*/
|
|
5
5
|
export declare function usePieChartData(values: PieProps['values']): {
|
|
6
6
|
data: import('..').PieChartData[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Slot names for the pie chart component.
|
|
3
|
+
* Must match the keys in Pie.styles.ts.
|
|
4
4
|
*/
|
|
5
5
|
export declare enum PieSlots {
|
|
6
6
|
pieRoot = "pieRoot",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CustomLegendProps } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @param data -
|
|
6
|
-
* @param onLegendClick -
|
|
7
|
-
* @param selectedLegendName -
|
|
8
|
-
* @param size -
|
|
9
|
-
* @returns
|
|
3
|
+
* CustomLegend component for the pie chart. Displays segment labels and values.
|
|
4
|
+
* Items are laid out in a row when there is enough space and wrap to the next line (vertical stack) when not.
|
|
5
|
+
* @param data - Data for the chart
|
|
6
|
+
* @param onLegendClick - Handler for legend click
|
|
7
|
+
* @param selectedLegendName - Name of the selected legend
|
|
8
|
+
* @param size - Component size
|
|
9
|
+
* @returns CustomLegend component
|
|
10
10
|
*/
|
|
11
11
|
export declare function CustomLegend({ data, size }: CustomLegendProps): import("@emotion/react/jsx-runtime").JSX.Element[];
|
|
12
12
|
//# sourceMappingURL=CustomLegend.d.ts.map
|
package/charts/Pie/types.d.ts
CHANGED
|
@@ -4,44 +4,44 @@ import { PIE_KEY_COMPONENT } from './constants';
|
|
|
4
4
|
import { M4LOverridesStyleRules } from '@m4l/components';
|
|
5
5
|
import { Theme } from '@mui/material/styles';
|
|
6
6
|
/**
|
|
7
|
-
* Item
|
|
7
|
+
* Item for the Pie chart (API shape).
|
|
8
8
|
*/
|
|
9
9
|
export interface PieValueItem {
|
|
10
|
-
/**
|
|
10
|
+
/** Displays the category name. */
|
|
11
11
|
title: string;
|
|
12
|
-
/**
|
|
12
|
+
/** Displays the formatted value of the category. */
|
|
13
13
|
v: string;
|
|
14
|
-
/**
|
|
14
|
+
/** Displays the numeric value of the category. */
|
|
15
15
|
r: number;
|
|
16
|
-
/**
|
|
16
|
+
/** Displays the category color. */
|
|
17
17
|
palletColor: string;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Props
|
|
20
|
+
* Props for the Pie chart component.
|
|
21
21
|
*/
|
|
22
22
|
export interface PieProps {
|
|
23
|
-
/**
|
|
23
|
+
/** Chart values (name, formatted value, numeric value, color). */
|
|
24
24
|
values: PieValueItem[];
|
|
25
|
-
/**
|
|
25
|
+
/** Component size. */
|
|
26
26
|
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Data for the Pie chart (name, value, itemStyle).
|
|
30
30
|
*/
|
|
31
31
|
export interface PieChartData {
|
|
32
|
-
/**
|
|
32
|
+
/** Displays the category name. */
|
|
33
33
|
name: string;
|
|
34
|
-
/**
|
|
34
|
+
/** Displays the numeric value of the category. */
|
|
35
35
|
value: number;
|
|
36
|
-
/**
|
|
36
|
+
/** Displays the formatted value of the category. */
|
|
37
37
|
valueFormatted: string;
|
|
38
|
-
/**
|
|
38
|
+
/** Displays the category color. */
|
|
39
39
|
itemStyle: {
|
|
40
40
|
color: string;
|
|
41
41
|
};
|
|
42
|
-
/**
|
|
42
|
+
/** Displays the category color. */
|
|
43
43
|
colorName: string;
|
|
44
|
-
/**
|
|
44
|
+
/** Displays the data length. */
|
|
45
45
|
lenght: number;
|
|
46
46
|
}
|
|
47
47
|
export type PieOwnerState = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/Pie/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/Pie/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/widgets",
|
|
3
|
-
"version": "0.0.2
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,9 +24,6 @@
|
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@emotion/react": "11.14.0",
|
|
26
26
|
"@emotion/styled": "11.14.1",
|
|
27
|
-
"@mui/material": "^5.0.0",
|
|
28
|
-
"echarts": "^6.0.0",
|
|
29
|
-
"echarts-for-react": "^3.0.0",
|
|
30
27
|
"react": "^18.0.0 || ^19.0.0",
|
|
31
28
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
32
29
|
},
|