@trackunit/react-chart-components 0.0.59 → 0.0.62

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/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@trackunit/react-chart-components",
3
- "version": "0.0.59",
3
+ "version": "0.0.62",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
7
7
  "node": ">=16.x"
8
8
  },
9
9
  "dependencies": {
10
- "@trackunit/react-components": "0.1.116",
11
- "@trackunit/tailwind-styled-components": "0.0.57",
12
- "@trackunit/ui-design-tokens": "0.0.70",
10
+ "@trackunit/react-components": "0.1.119",
11
+ "@trackunit/tailwind-styled-components": "0.0.58",
12
+ "@trackunit/ui-design-tokens": "0.0.72",
13
13
  "echarts": "5.4.0",
14
14
  "echarts-for-react": "3.0.2",
15
15
  "react": "18.2.0"
@@ -1,81 +1,81 @@
1
- import { CommonProps } from "@trackunit/react-components";
2
- import { EChartsType } from "echarts";
3
- import * as React from "react";
4
- export interface IOptionsType {
5
- [key: string]: any;
6
- }
7
- export interface ChartProps extends CommonProps {
8
- /**
9
- * Option values for EChart.
10
- */
11
- options: IOptionsType;
12
- /**
13
- * Whether or not to low the preloader.
14
- */
15
- showLoading?: boolean;
16
- /**
17
- * onClick event.
18
- */
19
- onClick?: (event: any) => void;
20
- /**
21
- * onDataZoom event.
22
- */
23
- onDataZoom?: (event: any) => void;
24
- /**
25
- * onBrush event.
26
- */
27
- onBrush?: (event: any) => void;
28
- /**
29
- * Event fired when brush is selected.
30
- */
31
- onBrushSelected?: (event: any) => void;
32
- /**
33
- * Event fired when mouse leaves the chart.
34
- */
35
- mouseLeaveChart?: () => void;
36
- /**
37
- * Event fired when mouse is moving over the chart.
38
- */
39
- mouseMoveChart?: (event: any, chart: EChartsType | undefined) => void;
40
- /**
41
- * CSS styles for the chart.
42
- */
43
- style?: Record<string, string | number>;
44
- /**
45
- * To denote of chart is ready or not.
46
- */
47
- onChartReady?: (chart: any) => void;
48
- /**
49
- * Whether to merge with previous option.
50
- */
51
- merge?: boolean;
52
- /**
53
- * Values for the loading component.
54
- */
55
- loadingOption?: {
56
- text: string;
57
- };
58
- /**
59
- * Time-zone label.
60
- */
61
- timezoneLabel?: React.ReactNode;
62
- /**
63
- * Type of rendered used. Either "svg" or "canvas".
64
- */
65
- renderer?: "svg" | "canvas";
66
- /**
67
- * Value used to find element by `data-testid` attribute.
68
- */
69
- dataTestId?: string;
70
- }
71
- /**
72
- * The Chart component is a wrapper component for ECharts.
73
- *
74
- * Handles events and click functionality.
75
- *
76
- * For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
77
- *
78
- * @param {ChartProps} props - The props for the Chart component
79
- * @returns {JSX.Element} Chart component
80
- */
81
- export declare const Chart: ({ options, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart, merge, loadingOption, timezoneLabel, renderer, dataTestId, }: ChartProps) => JSX.Element;
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { EChartsType } from "echarts";
3
+ import * as React from "react";
4
+ export interface IOptionsType {
5
+ [key: string]: any;
6
+ }
7
+ export interface ChartProps extends CommonProps {
8
+ /**
9
+ * Option values for EChart.
10
+ */
11
+ options: IOptionsType;
12
+ /**
13
+ * Whether or not to low the preloader.
14
+ */
15
+ showLoading?: boolean;
16
+ /**
17
+ * onClick event.
18
+ */
19
+ onClick?: (event: any) => void;
20
+ /**
21
+ * onDataZoom event.
22
+ */
23
+ onDataZoom?: (event: any) => void;
24
+ /**
25
+ * onBrush event.
26
+ */
27
+ onBrush?: (event: any) => void;
28
+ /**
29
+ * Event fired when brush is selected.
30
+ */
31
+ onBrushSelected?: (event: any) => void;
32
+ /**
33
+ * Event fired when mouse leaves the chart.
34
+ */
35
+ mouseLeaveChart?: () => void;
36
+ /**
37
+ * Event fired when mouse is moving over the chart.
38
+ */
39
+ mouseMoveChart?: (event: any, chart: EChartsType | undefined) => void;
40
+ /**
41
+ * CSS styles for the chart.
42
+ */
43
+ style?: Record<string, string | number>;
44
+ /**
45
+ * To denote of chart is ready or not.
46
+ */
47
+ onChartReady?: (chart: any) => void;
48
+ /**
49
+ * Whether to merge with previous option.
50
+ */
51
+ merge?: boolean;
52
+ /**
53
+ * Values for the loading component.
54
+ */
55
+ loadingOption?: {
56
+ text: string;
57
+ };
58
+ /**
59
+ * Time-zone label.
60
+ */
61
+ timezoneLabel?: React.ReactNode;
62
+ /**
63
+ * Type of rendered used. Either "svg" or "canvas".
64
+ */
65
+ renderer?: "svg" | "canvas";
66
+ /**
67
+ * Value used to find element by `data-testid` attribute.
68
+ */
69
+ dataTestId?: string;
70
+ }
71
+ /**
72
+ * The Chart component is a wrapper component for ECharts.
73
+ *
74
+ * Handles events and click functionality.
75
+ *
76
+ * For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
77
+ *
78
+ * @param {ChartProps} props - The props for the Chart component
79
+ * @returns {JSX.Element} Chart component
80
+ */
81
+ export declare const Chart: ({ options, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart, merge, loadingOption, timezoneLabel, renderer, dataTestId, }: ChartProps) => JSX.Element;
@@ -1,8 +1,6 @@
1
- import { ComponentMeta, Story } from "@storybook/react";
2
- import { ChartProps } from "./Chart";
3
- import "./Chart.css";
4
- declare const _default: ComponentMeta<({ options, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart, merge, loadingOption, timezoneLabel, renderer, dataTestId, }: ChartProps) => JSX.Element>;
5
- export default _default;
6
- export declare const Default: Story<ChartProps>;
7
- export declare const Usage: () => JSX.Element;
8
- export declare const Examples: () => JSX.Element;
1
+ import { Story } from "@storybook/react";
2
+ import { ChartProps } from "./Chart";
3
+ import "./Chart.css";
4
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, ChartProps>;
5
+ export default _default;
6
+ export declare const Default: Story<ChartProps>;
@@ -1 +1 @@
1
- export * from "./Chart";
1
+ export * from "./Chart";
@@ -1,49 +1,49 @@
1
- /// <reference types="react" />
2
- interface DonutChartProps {
3
- /**
4
- * The color to be used for the count portion in the chart.
5
- */
6
- countColor?: string;
7
- /**
8
- * The color to be used for the total count portion in the chart.
9
- */
10
- totalCountColor?: string;
11
- /**
12
- * The count to be displayed in the KPI.
13
- *
14
- * @example
15
- * <Kpi count={29000} />
16
- */
17
- count: number;
18
- /**
19
- * Total count of the Kpi.
20
- * This is useful when you want to display a donut chart.
21
- * The donut chart will be divided into two parts, the count and the total count.
22
- *
23
- * @example
24
- * <Kpi totalCount={29000} />
25
- */
26
- totalCount?: number;
27
- /**
28
- * Whether the value is loading or not.
29
- *
30
- * @default false
31
- */
32
- loading?: boolean;
33
- /**
34
- * The data-testid attribute to be used for testing.
35
- */
36
- dataTestId?: string;
37
- }
38
- /**
1
+ /// <reference types="react" />
2
+ interface DonutChartProps {
3
+ /**
4
+ * The color to be used for the count portion in the chart.
5
+ */
6
+ countColor?: string;
7
+ /**
8
+ * The color to be used for the total count portion in the chart.
9
+ */
10
+ totalCountColor?: string;
11
+ /**
12
+ * The count to be displayed in the KPI.
13
+ *
14
+ * @example
15
+ * <Kpi count={29000} />
16
+ */
17
+ count: number;
18
+ /**
19
+ * Total count of the Kpi.
20
+ * This is useful when you want to display a donut chart.
21
+ * The donut chart will be divided into two parts, the count and the total count.
22
+ *
23
+ * @example
24
+ * <Kpi totalCount={29000} />
25
+ */
26
+ totalCount?: number;
27
+ /**
28
+ * Whether the value is loading or not.
29
+ *
30
+ * @default false
31
+ */
32
+ loading?: boolean;
33
+ /**
34
+ * The data-testid attribute to be used for testing.
35
+ */
36
+ dataTestId?: string;
37
+ }
38
+ /**
39
39
 
40
- A donut chart component to display a KPI value and its total in a circular chart.
41
- *
42
- @param {string} countColor - The color to be used for the value portion in the chart.
43
- @param {string} totalCountColor - The color to be used for the total portion in the chart.
44
- @param {number} count - The count of the KPI to be displayed.
45
- @param {number} totalCount - The total count of the KPI to be displayed.
46
- @returns {JSX.Element} - A donut chart displaying the KPI count and total count.
47
- */
48
- export declare const KPIDonutChart: ({ dataTestId, loading, countColor, totalCountColor, count, totalCount, }: DonutChartProps) => JSX.Element;
49
- export {};
40
+ A donut chart component to display a KPI value and its total in a circular chart.
41
+ *
42
+ @param {string} countColor - The color to be used for the value portion in the chart.
43
+ @param {string} totalCountColor - The color to be used for the total portion in the chart.
44
+ @param {number} count - The count of the KPI to be displayed.
45
+ @param {number} totalCount - The total count of the KPI to be displayed.
46
+ @returns {JSX.Element} - A donut chart displaying the KPI count and total count.
47
+ */
48
+ export declare const KPIDonutChart: ({ dataTestId, loading, countColor, totalCountColor, count, totalCount, }: DonutChartProps) => JSX.Element;
49
+ export {};
package/src/KPI/Kpi.d.ts CHANGED
@@ -1,74 +1,74 @@
1
- /// <reference types="react" />
2
- import { CommonProps } from "@trackunit/react-components";
3
- export interface KpiProps extends CommonProps {
4
- /**
5
- * The count to be displayed in the KPI.
6
- *
7
- * @example
8
- * <Kpi count={29000} />
9
- */
10
- count: number | string;
11
- /**
12
- * Total count of the Kpi.
13
- * This is useful when you want to display a donut chart.
14
- * The donut chart will be divided into two parts, the count and the total count.
15
- *
16
- * @example
17
- * <Kpi count={15000} totalCount={29000} />
18
- */
19
- totalCount?: number;
20
- /**
21
- * Description of the Kpi.
22
- *
23
- * @example <Kpi description="Total Assets" />
24
- */
25
- description?: string;
26
- /**
27
- * Boolean to control the visibility of the chart.
28
- */
29
- showChart?: boolean;
30
- /**
31
- * A suffix that gets added to the end of the count.
32
- * This is useful when you want to display a percentage, unit, etc.
33
- *
34
- * @example <Kpi value={50} suffix="%" /> will display 50%.
35
- * <Kpi value={50} suffix="units" /> will display 50 units.
36
- */
37
- suffix?: string;
38
- /**
39
- * The color to be used for the count portion in the chart.
40
- */
41
- countColor?: string;
42
- /**
43
- * The color to be used for the total count portion in the chart.
44
- */
45
- totalCountColor?: string;
46
- /**
47
- * Boolean to control whether the KPI is displayed inline or not.
48
- *
49
- * @default false
50
- */
51
- inline?: boolean;
52
- /**
53
- * Whether the value is loading or not.
54
- * When set to true, a skeleton will be displayed.
55
- *
56
- * @default false
57
- */
58
- loading?: boolean;
59
- }
60
- /**
61
- * - A KPI component to display a value and its description.
62
- * - It can also display a donut chart to show the value and its total.
63
- * - The donut chart is displayed when the showChart prop is set to true.
64
- *
65
- * @param {boolean} showChart - Boolean to control the visibility of the chart.
66
- * @param {number} count - Value of the Kpi.
67
- * @param {number} totalCount - Total value of the Kpi.
68
- * @param {string} description - Description of the Kpi.
69
- * @param {string[]} colors - Colors of the Kpi.
70
- * @param {boolean} loading - Whether the value is loading or not.
71
- * @param {boolean} inline - Boolean to control whether the KPI is displayed inline or not.
72
- * @returns {JSX.Element} Kpi component
73
- */
74
- export declare const Kpi: ({ className, dataTestId, showChart, count, description, totalCount, countColor, totalCountColor, suffix, inline, loading, }: KpiProps) => JSX.Element;
1
+ /// <reference types="react" />
2
+ import { CommonProps } from "@trackunit/react-components";
3
+ export interface KpiProps extends CommonProps {
4
+ /**
5
+ * The count to be displayed in the KPI.
6
+ *
7
+ * @example
8
+ * <Kpi count={29000} />
9
+ */
10
+ count: number | string;
11
+ /**
12
+ * Total count of the Kpi.
13
+ * This is useful when you want to display a donut chart.
14
+ * The donut chart will be divided into two parts, the count and the total count.
15
+ *
16
+ * @example
17
+ * <Kpi count={15000} totalCount={29000} />
18
+ */
19
+ totalCount?: number;
20
+ /**
21
+ * Description of the Kpi.
22
+ *
23
+ * @example <Kpi description="Total Assets" />
24
+ */
25
+ description?: string;
26
+ /**
27
+ * Boolean to control the visibility of the chart.
28
+ */
29
+ showChart?: boolean;
30
+ /**
31
+ * A suffix that gets added to the end of the count.
32
+ * This is useful when you want to display a percentage, unit, etc.
33
+ *
34
+ * @example <Kpi value={50} suffix="%" /> will display 50%.
35
+ * <Kpi value={50} suffix="units" /> will display 50 units.
36
+ */
37
+ suffix?: string;
38
+ /**
39
+ * The color to be used for the count portion in the chart.
40
+ */
41
+ countColor?: string;
42
+ /**
43
+ * The color to be used for the total count portion in the chart.
44
+ */
45
+ totalCountColor?: string;
46
+ /**
47
+ * Boolean to control whether the KPI is displayed inline or not.
48
+ *
49
+ * @default false
50
+ */
51
+ inline?: boolean;
52
+ /**
53
+ * Whether the value is loading or not.
54
+ * When set to true, a skeleton will be displayed.
55
+ *
56
+ * @default false
57
+ */
58
+ loading?: boolean;
59
+ }
60
+ /**
61
+ * - A KPI component to display a value and its description.
62
+ * - It can also display a donut chart to show the value and its total.
63
+ * - The donut chart is displayed when the showChart prop is set to true.
64
+ *
65
+ * @param {boolean} showChart - Boolean to control the visibility of the chart.
66
+ * @param {number} count - Value of the Kpi.
67
+ * @param {number} totalCount - Total value of the Kpi.
68
+ * @param {string} description - Description of the Kpi.
69
+ * @param {string[]} colors - Colors of the Kpi.
70
+ * @param {boolean} loading - Whether the value is loading or not.
71
+ * @param {boolean} inline - Boolean to control whether the KPI is displayed inline or not.
72
+ * @returns {JSX.Element} Kpi component
73
+ */
74
+ export declare const Kpi: ({ className, dataTestId, showChart, count, description, totalCount, countColor, totalCountColor, suffix, inline, loading, }: KpiProps) => JSX.Element;
@@ -1,11 +1,9 @@
1
- import { ComponentMeta, Story } from "@storybook/react";
2
- import { KpiProps } from "./Kpi";
3
- import "./Kpi.css";
4
- declare const _default: ComponentMeta<({ className, dataTestId, showChart, count, description, totalCount, countColor, totalCountColor, suffix, inline, loading, }: KpiProps) => JSX.Element>;
5
- export default _default;
6
- export declare const Default: Story<KpiProps>;
7
- export declare const HiddenVariantSingleValue: () => JSX.Element;
8
- export declare const HiddenVariantInline: () => JSX.Element;
9
- export declare const HiddenVariantChart: () => JSX.Element;
10
- export declare const Usage: () => JSX.Element;
11
- export declare const Variants: () => JSX.Element;
1
+ import { Story } from "@storybook/react";
2
+ import { KpiProps } from "./Kpi";
3
+ import "./Kpi.css";
4
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, KpiProps>;
5
+ export default _default;
6
+ export declare const Default: Story<KpiProps>;
7
+ export declare const VariantSingleValue: () => JSX.Element;
8
+ export declare const VariantInline: () => JSX.Element;
9
+ export declare const VariantChart: () => JSX.Element;
@@ -1 +1 @@
1
- export * from "./Kpi";
1
+ export * from "./Kpi";
@@ -1,17 +1,17 @@
1
- /// <reference types="react" />
2
- export interface ILegendItem {
3
- label?: string;
4
- selected?: boolean;
5
- disabled?: boolean;
6
- onClick?: () => void;
7
- color: string;
8
- className?: string;
9
- dataTestId?: string;
10
- }
11
- /**
12
- * The LegendItem component is used to show form legends.
13
- *
14
- * @param {ILegendItem} props - The props for the LegendItem component
15
- * @returns {JSX.Element} LegendItem component
16
- */
17
- export declare const LegendItem: ({ className, label, disabled, selected, onClick, color, dataTestId }: ILegendItem) => JSX.Element;
1
+ /// <reference types="react" />
2
+ export interface ILegendItem {
3
+ label?: string;
4
+ selected?: boolean;
5
+ disabled?: boolean;
6
+ onClick?: () => void;
7
+ color: string;
8
+ className?: string;
9
+ dataTestId?: string;
10
+ }
11
+ /**
12
+ * The LegendItem component is used to show form legends.
13
+ *
14
+ * @param {ILegendItem} props - The props for the LegendItem component
15
+ * @returns {JSX.Element} LegendItem component
16
+ */
17
+ export declare const LegendItem: ({ className, label, disabled, selected, onClick, color, dataTestId }: ILegendItem) => JSX.Element;
@@ -1,6 +1,5 @@
1
- import { ComponentMeta, Story } from "@storybook/react";
2
- import { ILegendItem } from "./LegendItem";
3
- declare const _default: ComponentMeta<({ className, label, disabled, selected, onClick, color, dataTestId }: ILegendItem) => JSX.Element>;
4
- export default _default;
5
- export declare const Default: Story<ILegendItem>;
6
- export declare const Usage: () => JSX.Element;
1
+ import { Story } from "@storybook/react";
2
+ import { ILegendItem } from "./LegendItem";
3
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, ILegendItem>;
4
+ export default _default;
5
+ export declare const Default: Story<ILegendItem>;
@@ -1 +1 @@
1
- export * from "./LegendItem";
1
+ export * from "./LegendItem";
@@ -1,55 +1,55 @@
1
- /// <reference types="react" />
2
- import { CommonProps } from "@trackunit/react-components";
3
- type Size = "compact" | "full";
4
- export interface ChartData<T extends object = object> {
5
- /**
6
- * Unique ID for this entry. Not visible for the user
7
- */
8
- id: string;
9
- /**
10
- * The text to show for to the user
11
- */
12
- name: string;
13
- /**
14
- * Number of elements with wrapped under this item
15
- */
16
- count?: number;
17
- /**
18
- * The color to use in the chart and legends for this item
19
- */
20
- color: string;
21
- /**
22
- * If selected, it'll be highlighted
23
- */
24
- selected?: boolean;
25
- /**
26
- * Supply the original object that this chart data item was constructed from. It'll be available on callbacks
27
- */
28
- original?: T;
29
- }
30
- export interface PieChartProps<T extends object> extends CommonProps {
31
- /**
32
- * Array of data points to show
33
- */
34
- data: ChartData<T>[] | undefined;
35
- /**
36
- * onClick handler which includes the data object clicked on
37
- */
38
- onClick?: (data: ChartData<T>) => void;
39
- /**
40
- * Show chart as loading
41
- */
42
- loading?: boolean;
43
- /**
44
- * When compact, the chart is smaller and legends are hidden.
45
- */
46
- size?: Size;
47
- }
48
- /**
49
- * Create a PieChart with legends based on our current Chart component
50
- *
51
- * @param {PieChartProps} props - The props for the Chart component
52
- * @returns {JSX.Element} Chart component
53
- */
54
- export declare const PieChart: <T extends object>({ data, size, loading, onClick, className, dataTestId, }: PieChartProps<T>) => JSX.Element;
55
- export {};
1
+ /// <reference types="react" />
2
+ import { CommonProps } from "@trackunit/react-components";
3
+ type Size = "compact" | "full";
4
+ export interface ChartData<T extends object = object> {
5
+ /**
6
+ * Unique ID for this entry. Not visible for the user
7
+ */
8
+ id: string;
9
+ /**
10
+ * The text to show for to the user
11
+ */
12
+ name: string;
13
+ /**
14
+ * Number of elements with wrapped under this item
15
+ */
16
+ count?: number;
17
+ /**
18
+ * The color to use in the chart and legends for this item
19
+ */
20
+ color: string;
21
+ /**
22
+ * If selected, it'll be highlighted
23
+ */
24
+ selected?: boolean;
25
+ /**
26
+ * Supply the original object that this chart data item was constructed from. It'll be available on callbacks
27
+ */
28
+ original?: T;
29
+ }
30
+ export interface PieChartProps<T extends object> extends CommonProps {
31
+ /**
32
+ * Array of data points to show
33
+ */
34
+ data: ChartData<T>[] | undefined;
35
+ /**
36
+ * onClick handler which includes the data object clicked on
37
+ */
38
+ onClick?: (data: ChartData<T>) => void;
39
+ /**
40
+ * Show chart as loading
41
+ */
42
+ loading?: boolean;
43
+ /**
44
+ * When compact, the chart is smaller and legends are hidden.
45
+ */
46
+ size?: Size;
47
+ }
48
+ /**
49
+ * Create a PieChart with legends based on our current Chart component
50
+ *
51
+ * @param {PieChartProps} props - The props for the Chart component
52
+ * @returns {JSX.Element} Chart component
53
+ */
54
+ export declare const PieChart: <T extends object>({ data, size, loading, onClick, className, dataTestId, }: PieChartProps<T>) => JSX.Element;
55
+ export {};
@@ -1,10 +1,7 @@
1
- import { ComponentMeta, Story } from "@storybook/react";
2
- import { PieChartProps } from "./PieChart";
3
- declare const _default: ComponentMeta<(<T extends object>({ data, size, loading, onClick, className, dataTestId, }: PieChartProps<T>) => JSX.Element)>;
4
- export default _default;
5
- export declare const Default: Story<PieChartProps<object>>;
6
- export declare const HiddenCompactVariant: () => JSX.Element;
7
- export declare const HiddenFullVariant: () => JSX.Element;
8
- export declare const Usage: () => JSX.Element;
9
- export declare const Variants: () => JSX.Element;
10
- export declare const Examples: () => JSX.Element;
1
+ import { Story } from "@storybook/react";
2
+ import { PieChartProps } from "./PieChart";
3
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, PieChartProps<object>>;
4
+ export default _default;
5
+ export declare const Default: Story<PieChartProps<object>>;
6
+ export declare const CompactVariant: () => JSX.Element;
7
+ export declare const FullVariant: () => JSX.Element;