@trackunit/react-chart-components 1.3.23 → 1.3.28
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/index.cjs.js +11 -11
- package/index.esm.js +11 -11
- package/package.json +5 -5
- package/src/Chart/Chart.d.ts +3 -3
- package/src/KPI/KPIDonutChart.d.ts +7 -7
- package/src/KPI/Kpi.d.ts +1 -1
- package/src/LegendItem/LegendItem.d.ts +1 -1
- package/src/PieChart/PieChart.d.ts +3 -2
package/index.cjs.js
CHANGED
|
@@ -15,7 +15,7 @@ var uiDesignTokens = require('@trackunit/ui-design-tokens');
|
|
|
15
15
|
* For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
|
|
16
16
|
*
|
|
17
17
|
* @param {ChartProps} props - The props for the Chart component
|
|
18
|
-
* @returns {
|
|
18
|
+
* @returns {ReactElement} Chart component
|
|
19
19
|
*/
|
|
20
20
|
const Chart = ({ options, unsafeOptions, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart, mouseOverChart, mouseOutChart, merge = true, loadingOption, timezoneLabel, renderer = "canvas", dataTestId, }) => {
|
|
21
21
|
const echartsRef = react.useRef(null);
|
|
@@ -67,14 +67,14 @@ const cvaChartContainer = cssClassVarianceUtilities.cvaMerge(["grid", "gap-1", "
|
|
|
67
67
|
const cvaChartSpinnerContainer = cssClassVarianceUtilities.cvaMerge(["grid", "place-items-center", "overflow-y-auto"]);
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
|
|
71
|
+
A donut chart component to display a KPI value and its total in a circular chart.
|
|
72
72
|
*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
@param {string} countColor - The color to be used for the value portion in the chart.
|
|
74
|
+
@param {string} totalCountColor - The color to be used for the total portion in the chart.
|
|
75
|
+
@param {number} count - The count of the KPI to be displayed.
|
|
76
|
+
@param {number} totalCount - The total count of the KPI to be displayed.
|
|
77
|
+
@returns {ReactElement} - A donut chart displaying the KPI count and total count.
|
|
78
78
|
*/
|
|
79
79
|
const KPIDonutChart = ({ dataTestId, loading, countColor, totalCountColor, count, totalCount = count, }) => {
|
|
80
80
|
return (jsxRuntime.jsx(Chart, { dataTestId: dataTestId, options: {
|
|
@@ -147,7 +147,7 @@ const cvaKpiContainer = cssClassVarianceUtilities.cvaMerge(["flex", "flex-col",
|
|
|
147
147
|
* @param {string[]} colors - Colors of the Kpi.
|
|
148
148
|
* @param {boolean} loading - Whether the value is loading or not.
|
|
149
149
|
* @param {boolean} inline - Boolean to control whether the KPI is displayed inline or not.
|
|
150
|
-
* @returns {
|
|
150
|
+
* @returns {ReactElement} Kpi component
|
|
151
151
|
*/
|
|
152
152
|
const Kpi = ({ className, dataTestId, showChart = false, count, description, totalCount, countColor, totalCountColor, suffix, inline = false, loading = false, }) => {
|
|
153
153
|
return (jsxRuntime.jsxs("div", { className: cvaKpi({ className }), "data-testid": dataTestId, children: [showChart ? (jsxRuntime.jsx(KPIDonutChart, { count: Number(count), countColor: countColor, dataTestId: dataTestId ? dataTestId + "-donut-chart" : undefined, loading: loading, totalCount: totalCount, totalCountColor: totalCountColor })) : null, loading ? (jsxRuntime.jsxs("div", { className: cvaKpiContainer({ inline }), "data-testid": dataTestId ? `${dataTestId}-skeleton-lines` : null, children: [jsxRuntime.jsx(reactComponents.SkeletonLines, { lines: 1, width: 20 }), jsxRuntime.jsx(reactComponents.SkeletonLines, { lines: 1, width: 50 })] })) : (jsxRuntime.jsxs("div", { className: cvaKpiContainer({ inline, showChart }), "data-testid": dataTestId ? `${dataTestId}-container` : null, children: [jsxRuntime.jsxs("span", { className: cvaKpiCountContainer(), children: [jsxRuntime.jsx("span", { className: cvaKpiCount(), children: count ?? "-" }), suffix ? (jsxRuntime.jsx("span", { className: cvaKpiSuffix(), "data-testid": dataTestId ? `${dataTestId}-suffix` : null, children: suffix })) : null] }), jsxRuntime.jsx("span", { className: cvaKpiDescription(), children: description })] }))] }));
|
|
@@ -200,7 +200,7 @@ const cvaLegendItemIndicator = cssClassVarianceUtilities.cvaMerge(["w-3", "h-3",
|
|
|
200
200
|
* The LegendItem component is used to show form legends.
|
|
201
201
|
*
|
|
202
202
|
* @param {LegendItem} props - The props for the LegendItem component
|
|
203
|
-
* @returns {
|
|
203
|
+
* @returns {ReactElement} LegendItem component
|
|
204
204
|
*/
|
|
205
205
|
const LegendItem = ({ className, label, disabled, selected, onClick, color, dataTestId }) => {
|
|
206
206
|
const handleOnClick = onClick && !disabled ? () => onClick() : undefined;
|
|
@@ -211,7 +211,7 @@ const LegendItem = ({ className, label, disabled, selected, onClick, color, data
|
|
|
211
211
|
* Create a PieChart with legends based on our current Chart component
|
|
212
212
|
*
|
|
213
213
|
* @param {PieChartProps} props - The props for the Chart component
|
|
214
|
-
* @returns {
|
|
214
|
+
* @returns {ReactElement} Chart component
|
|
215
215
|
*/
|
|
216
216
|
const PieChart = ({ data, size = "full", loading, onClick, className, dataTestId, }) => {
|
|
217
217
|
const totalCount = data?.map(item => item.count ?? 0).reduce((a, b) => a + b, 0) ?? 0;
|
package/index.esm.js
CHANGED
|
@@ -13,7 +13,7 @@ import { DEFAULT_CHART_COLORS } from '@trackunit/ui-design-tokens';
|
|
|
13
13
|
* For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
|
|
14
14
|
*
|
|
15
15
|
* @param {ChartProps} props - The props for the Chart component
|
|
16
|
-
* @returns {
|
|
16
|
+
* @returns {ReactElement} Chart component
|
|
17
17
|
*/
|
|
18
18
|
const Chart = ({ options, unsafeOptions, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart, mouseOverChart, mouseOutChart, merge = true, loadingOption, timezoneLabel, renderer = "canvas", dataTestId, }) => {
|
|
19
19
|
const echartsRef = useRef(null);
|
|
@@ -65,14 +65,14 @@ const cvaChartContainer = cvaMerge(["grid", "gap-1", "grid-rows-1", "grid-cols-1
|
|
|
65
65
|
const cvaChartSpinnerContainer = cvaMerge(["grid", "place-items-center", "overflow-y-auto"]);
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
|
|
69
|
+
A donut chart component to display a KPI value and its total in a circular chart.
|
|
70
70
|
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
@param {string} countColor - The color to be used for the value portion in the chart.
|
|
72
|
+
@param {string} totalCountColor - The color to be used for the total portion in the chart.
|
|
73
|
+
@param {number} count - The count of the KPI to be displayed.
|
|
74
|
+
@param {number} totalCount - The total count of the KPI to be displayed.
|
|
75
|
+
@returns {ReactElement} - A donut chart displaying the KPI count and total count.
|
|
76
76
|
*/
|
|
77
77
|
const KPIDonutChart = ({ dataTestId, loading, countColor, totalCountColor, count, totalCount = count, }) => {
|
|
78
78
|
return (jsx(Chart, { dataTestId: dataTestId, options: {
|
|
@@ -145,7 +145,7 @@ const cvaKpiContainer = cvaMerge(["flex", "flex-col", "items-baseline"], {
|
|
|
145
145
|
* @param {string[]} colors - Colors of the Kpi.
|
|
146
146
|
* @param {boolean} loading - Whether the value is loading or not.
|
|
147
147
|
* @param {boolean} inline - Boolean to control whether the KPI is displayed inline or not.
|
|
148
|
-
* @returns {
|
|
148
|
+
* @returns {ReactElement} Kpi component
|
|
149
149
|
*/
|
|
150
150
|
const Kpi = ({ className, dataTestId, showChart = false, count, description, totalCount, countColor, totalCountColor, suffix, inline = false, loading = false, }) => {
|
|
151
151
|
return (jsxs("div", { className: cvaKpi({ className }), "data-testid": dataTestId, children: [showChart ? (jsx(KPIDonutChart, { count: Number(count), countColor: countColor, dataTestId: dataTestId ? dataTestId + "-donut-chart" : undefined, loading: loading, totalCount: totalCount, totalCountColor: totalCountColor })) : null, loading ? (jsxs("div", { className: cvaKpiContainer({ inline }), "data-testid": dataTestId ? `${dataTestId}-skeleton-lines` : null, children: [jsx(SkeletonLines, { lines: 1, width: 20 }), jsx(SkeletonLines, { lines: 1, width: 50 })] })) : (jsxs("div", { className: cvaKpiContainer({ inline, showChart }), "data-testid": dataTestId ? `${dataTestId}-container` : null, children: [jsxs("span", { className: cvaKpiCountContainer(), children: [jsx("span", { className: cvaKpiCount(), children: count ?? "-" }), suffix ? (jsx("span", { className: cvaKpiSuffix(), "data-testid": dataTestId ? `${dataTestId}-suffix` : null, children: suffix })) : null] }), jsx("span", { className: cvaKpiDescription(), children: description })] }))] }));
|
|
@@ -198,7 +198,7 @@ const cvaLegendItemIndicator = cvaMerge(["w-3", "h-3", "rounded-[50%]"], {
|
|
|
198
198
|
* The LegendItem component is used to show form legends.
|
|
199
199
|
*
|
|
200
200
|
* @param {LegendItem} props - The props for the LegendItem component
|
|
201
|
-
* @returns {
|
|
201
|
+
* @returns {ReactElement} LegendItem component
|
|
202
202
|
*/
|
|
203
203
|
const LegendItem = ({ className, label, disabled, selected, onClick, color, dataTestId }) => {
|
|
204
204
|
const handleOnClick = onClick && !disabled ? () => onClick() : undefined;
|
|
@@ -209,7 +209,7 @@ const LegendItem = ({ className, label, disabled, selected, onClick, color, data
|
|
|
209
209
|
* Create a PieChart with legends based on our current Chart component
|
|
210
210
|
*
|
|
211
211
|
* @param {PieChartProps} props - The props for the Chart component
|
|
212
|
-
* @returns {
|
|
212
|
+
* @returns {ReactElement} Chart component
|
|
213
213
|
*/
|
|
214
214
|
const PieChart = ({ data, size = "full", loading, onClick, className, dataTestId, }) => {
|
|
215
215
|
const totalCount = data?.map(item => item.count ?? 0).reduce((a, b) => a + b, 0) ?? 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-chart-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.28",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"echarts": "5.6.0",
|
|
11
11
|
"echarts-for-react": "^3.0.2",
|
|
12
|
-
"react": "
|
|
13
|
-
"@trackunit/css-class-variance-utilities": "1.3.
|
|
14
|
-
"@trackunit/react-components": "1.4.
|
|
15
|
-
"@trackunit/ui-design-tokens": "1.3.
|
|
12
|
+
"react": "19.0.0",
|
|
13
|
+
"@trackunit/css-class-variance-utilities": "1.3.28",
|
|
14
|
+
"@trackunit/react-components": "1.4.28",
|
|
15
|
+
"@trackunit/ui-design-tokens": "1.3.28"
|
|
16
16
|
},
|
|
17
17
|
"module": "./index.esm.js",
|
|
18
18
|
"main": "./index.cjs.js",
|
package/src/Chart/Chart.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
2
|
import { EChartsOption, EChartsType } from "echarts";
|
|
3
|
-
import { CSSProperties, ReactNode } from "react";
|
|
3
|
+
import { CSSProperties, ReactElement, ReactNode } from "react";
|
|
4
4
|
interface UnsafeOptions {
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
}
|
|
@@ -105,7 +105,7 @@ export type ChartProps = CommonProps & ConditionalChartOptions & {
|
|
|
105
105
|
* For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
|
|
106
106
|
*
|
|
107
107
|
* @param {ChartProps} props - The props for the Chart component
|
|
108
|
-
* @returns {
|
|
108
|
+
* @returns {ReactElement} Chart component
|
|
109
109
|
*/
|
|
110
|
-
export declare const Chart: ({ options, unsafeOptions, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart, mouseOverChart, mouseOutChart, merge, loadingOption, timezoneLabel, renderer, dataTestId, }: ChartProps) =>
|
|
110
|
+
export declare const Chart: ({ options, unsafeOptions, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart, mouseOverChart, mouseOutChart, merge, loadingOption, timezoneLabel, renderer, dataTestId, }: ChartProps) => ReactElement;
|
|
111
111
|
export {};
|
|
@@ -35,14 +35,14 @@ interface DonutChartProps {
|
|
|
35
35
|
dataTestId?: string;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
|
|
39
|
+
A donut chart component to display a KPI value and its total in a circular chart.
|
|
40
40
|
*
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
@param {string} countColor - The color to be used for the value portion in the chart.
|
|
42
|
+
@param {string} totalCountColor - The color to be used for the total portion in the chart.
|
|
43
|
+
@param {number} count - The count of the KPI to be displayed.
|
|
44
|
+
@param {number} totalCount - The total count of the KPI to be displayed.
|
|
45
|
+
@returns {ReactElement} - A donut chart displaying the KPI count and total count.
|
|
46
46
|
*/
|
|
47
47
|
export declare const KPIDonutChart: ({ dataTestId, loading, countColor, totalCountColor, count, totalCount, }: DonutChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
48
48
|
export {};
|
package/src/KPI/Kpi.d.ts
CHANGED
|
@@ -69,6 +69,6 @@ export interface KpiProps extends CommonProps {
|
|
|
69
69
|
* @param {string[]} colors - Colors of the Kpi.
|
|
70
70
|
* @param {boolean} loading - Whether the value is loading or not.
|
|
71
71
|
* @param {boolean} inline - Boolean to control whether the KPI is displayed inline or not.
|
|
72
|
-
* @returns {
|
|
72
|
+
* @returns {ReactElement} Kpi component
|
|
73
73
|
*/
|
|
74
74
|
export declare const Kpi: ({ className, dataTestId, showChart, count, description, totalCount, countColor, totalCountColor, suffix, inline, loading, }: KpiProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,6 +11,6 @@ export interface LegendItemProps {
|
|
|
11
11
|
* The LegendItem component is used to show form legends.
|
|
12
12
|
*
|
|
13
13
|
* @param {LegendItem} props - The props for the LegendItem component
|
|
14
|
-
* @returns {
|
|
14
|
+
* @returns {ReactElement} LegendItem component
|
|
15
15
|
*/
|
|
16
16
|
export declare const LegendItem: ({ className, label, disabled, selected, onClick, color, dataTestId }: LegendItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import { ReactElement } from "react";
|
|
2
3
|
type Size = "compact" | "full";
|
|
3
4
|
export interface ChartData<TProps extends object = object> {
|
|
4
5
|
/**
|
|
@@ -48,7 +49,7 @@ export interface PieChartProps<TProps extends object> extends CommonProps {
|
|
|
48
49
|
* Create a PieChart with legends based on our current Chart component
|
|
49
50
|
*
|
|
50
51
|
* @param {PieChartProps} props - The props for the Chart component
|
|
51
|
-
* @returns {
|
|
52
|
+
* @returns {ReactElement} Chart component
|
|
52
53
|
*/
|
|
53
|
-
export declare const PieChart: <TProps extends object>({ data, size, loading, onClick, className, dataTestId, }: PieChartProps<TProps>) =>
|
|
54
|
+
export declare const PieChart: <TProps extends object>({ data, size, loading, onClick, className, dataTestId, }: PieChartProps<TProps>) => ReactElement;
|
|
54
55
|
export {};
|