@mbao01/common 0.0.44 → 0.0.46
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/types/components/Chart/Chart.d.ts +2 -0
- package/dist/types/components/Chart/ChartContext.d.ts +2 -0
- package/dist/types/components/Chart/components/ChartLegend.d.ts +4 -0
- package/dist/types/components/Chart/components/ChartStyle.d.ts +2 -0
- package/dist/types/components/Chart/components/ChartTooltip.d.ts +4 -0
- package/dist/types/components/Chart/components/index.d.ts +3 -0
- package/dist/types/components/Chart/constants.d.ts +22 -0
- package/dist/types/components/Chart/helpers.d.ts +11 -0
- package/dist/types/components/Chart/hooks/index.d.ts +1 -0
- package/dist/types/components/Chart/hooks/useChart/index.d.ts +1 -0
- package/dist/types/components/Chart/hooks/useChart/useChart.d.ts +1 -0
- package/dist/types/components/Chart/index.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/activeShapeArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/animationArgs.d.ts +12 -0
- package/dist/types/components/Chart/stories/args/areaArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/areaChartArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/barArgs.d.ts +5 -0
- package/dist/types/components/Chart/stories/args/barChartArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/cartesianChartArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/cartesianSharedArgs.d.ts +11 -0
- package/dist/types/components/Chart/stories/args/chartArgs.d.ts +6 -0
- package/dist/types/components/Chart/stories/args/dotArgs.d.ts +10 -0
- package/dist/types/components/Chart/stories/args/events.d.ts +804 -0
- package/dist/types/components/Chart/stories/args/labelListArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/legendArgs.d.ts +3 -0
- package/dist/types/components/Chart/stories/args/lineArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/lineChartArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/pieArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/pieChartArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/polarChartArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/polarSharedArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/radarArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/radarChartArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/radialBarArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/radialBarChartArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/rectangleArgs.d.ts +9 -0
- package/dist/types/components/Chart/stories/args/referenceSharedArgs.d.ts +4 -0
- package/dist/types/components/Chart/stories/args/sectorArgs.d.ts +7 -0
- package/dist/types/components/Chart/stories/args/sharedAxisArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/stylesArgs.d.ts +6 -0
- package/dist/types/components/Chart/stories/args/textArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/tooltipArgs.d.ts +4 -0
- package/dist/types/components/Chart/stories/args/types.d.ts +13 -0
- package/dist/types/components/Chart/stories/args/xAxisArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/yAxisArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/examples/AreaChart.d.ts +16 -0
- package/dist/types/components/Chart/stories/examples/BarChart.d.ts +20 -0
- package/dist/types/components/Chart/stories/examples/LineChart.d.ts +16 -0
- package/dist/types/components/Chart/stories/examples/PieChart.d.ts +19 -0
- package/dist/types/components/Chart/stories/examples/RadarChart.d.ts +24 -0
- package/dist/types/components/Chart/stories/examples/RadialChart.d.ts +17 -0
- package/dist/types/components/Chart/stories/examples/Tooltip.d.ts +15 -0
- package/dist/types/components/Chart/stories/helpers/index.d.ts +9 -0
- package/dist/types/components/Chart/types.d.ts +37 -0
- package/dist/types/components/DragAndDrop/Draggable/Draggable.d.ts +29 -0
- package/dist/types/components/DragAndDrop/Draggable/Draggable.example.d.ts +24 -0
- package/dist/types/components/DragAndDrop/Draggable/constants.d.ts +9 -0
- package/dist/types/components/DragAndDrop/Draggable/index.d.ts +1 -0
- package/dist/types/components/DragAndDrop/Draggable/types.d.ts +41 -0
- package/dist/types/components/DragAndDrop/Droppable/Droppable.d.ts +2 -0
- package/dist/types/components/DragAndDrop/Droppable/Droppable.example.d.ts +10 -0
- package/dist/types/components/DragAndDrop/Droppable/constants.d.ts +5 -0
- package/dist/types/components/DragAndDrop/Droppable/index.d.ts +1 -0
- package/dist/types/components/DragAndDrop/Droppable/types.d.ts +4 -0
- package/dist/types/components/DragAndDrop/Sortable/Sortable.d.ts +2 -0
- package/dist/types/components/DragAndDrop/Sortable/Sortable.example.d.ts +6 -0
- package/dist/types/components/DragAndDrop/Sortable/constants.d.ts +4 -0
- package/dist/types/components/DragAndDrop/Sortable/index.d.ts +1 -0
- package/dist/types/components/DragAndDrop/Sortable/types.d.ts +7 -0
- package/dist/types/components/DragAndDrop/index.d.ts +3 -0
- package/dist/types/components/Widget/InternalWidgetsContext.d.ts +2 -0
- package/dist/types/components/Widget/Widget.d.ts +2 -0
- package/dist/types/components/Widget/Widgets.example.d.ts +1 -0
- package/dist/types/components/Widget/WidgetsContext.d.ts +2 -0
- package/dist/types/components/Widget/hooks/index.d.ts +2 -0
- package/dist/types/components/Widget/hooks/useWidget/index.d.ts +1 -0
- package/dist/types/components/Widget/hooks/useWidget/useWidget.d.ts +7 -0
- package/dist/types/components/Widget/hooks/useWidgets/index.d.ts +1 -0
- package/dist/types/components/Widget/hooks/useWidgets/useWidgets.d.ts +1 -0
- package/dist/types/components/Widget/index.d.ts +3 -0
- package/dist/types/components/Widget/modifiers/index.d.ts +1 -0
- package/dist/types/components/Widget/modifiers/restrictToElement.d.ts +2 -0
- package/dist/types/components/Widget/types.d.ts +28 -0
- package/package.json +9 -3
- package/src/components/Chart/Chart.tsx +26 -0
- package/src/components/Chart/ChartContext.tsx +4 -0
- package/src/components/Chart/components/ChartLegend.tsx +52 -0
- package/src/components/Chart/components/ChartStyle.tsx +32 -0
- package/src/components/Chart/components/ChartTooltip.tsx +126 -0
- package/src/components/Chart/components/index.ts +3 -0
- package/src/components/Chart/constants.ts +78 -0
- package/src/components/Chart/helpers.ts +27 -0
- package/src/components/Chart/hooks/index.ts +1 -0
- package/src/components/Chart/hooks/useChart/index.ts +1 -0
- package/src/components/Chart/hooks/useChart/useChart.ts +12 -0
- package/src/components/Chart/index.ts +2 -0
- package/src/components/Chart/stories/args/activeShapeArgs.ts +34 -0
- package/src/components/Chart/stories/args/animationArgs.ts +67 -0
- package/src/components/Chart/stories/args/areaArgs.ts +16 -0
- package/src/components/Chart/stories/args/areaChartArgs.ts +19 -0
- package/src/components/Chart/stories/args/barArgs.ts +123 -0
- package/src/components/Chart/stories/args/barChartArgs.ts +65 -0
- package/src/components/Chart/stories/args/cartesianChartArgs.ts +42 -0
- package/src/components/Chart/stories/args/cartesianSharedArgs.ts +136 -0
- package/src/components/Chart/stories/args/chartArgs.ts +244 -0
- package/src/components/Chart/stories/args/dotArgs.ts +46 -0
- package/src/components/Chart/stories/args/events.ts +343 -0
- package/src/components/Chart/stories/args/index.ts +178 -0
- package/src/components/Chart/stories/args/labelListArgs.ts +124 -0
- package/src/components/Chart/stories/args/legendArgs.ts +205 -0
- package/src/components/Chart/stories/args/lineArgs.ts +87 -0
- package/src/components/Chart/stories/args/lineChartArgs.ts +17 -0
- package/src/components/Chart/stories/args/pieArgs.ts +18 -0
- package/src/components/Chart/stories/args/pieChartArgs.ts +7 -0
- package/src/components/Chart/stories/args/polarChartArgs.ts +86 -0
- package/src/components/Chart/stories/args/polarSharedArgs.ts +42 -0
- package/src/components/Chart/stories/args/radarArgs.ts +26 -0
- package/src/components/Chart/stories/args/radarChartArgs.ts +26 -0
- package/src/components/Chart/stories/args/radialBarArgs.ts +36 -0
- package/src/components/Chart/stories/args/radialBarChartArgs.ts +16 -0
- package/src/components/Chart/stories/args/rectangleArgs.ts +35 -0
- package/src/components/Chart/stories/args/referenceSharedArgs.ts +75 -0
- package/src/components/Chart/stories/args/sectorArgs.ts +106 -0
- package/src/components/Chart/stories/args/sharedAxisArgs.ts +332 -0
- package/src/components/Chart/stories/args/stylesArgs.ts +258 -0
- package/src/components/Chart/stories/args/textArgs.ts +97 -0
- package/src/components/Chart/stories/args/tooltipArgs.ts +41 -0
- package/src/components/Chart/stories/args/types.ts +23 -0
- package/src/components/Chart/stories/args/xAxisArgs.ts +109 -0
- package/src/components/Chart/stories/args/yAxisArgs.ts +73 -0
- package/src/components/Chart/stories/examples/AreaChart.tsx +156 -0
- package/src/components/Chart/stories/examples/BarChart.tsx +425 -0
- package/src/components/Chart/stories/examples/LineChart.tsx +144 -0
- package/src/components/Chart/stories/examples/PieChart.tsx +238 -0
- package/src/components/Chart/stories/examples/RadarChart.tsx +261 -0
- package/src/components/Chart/stories/examples/RadialChart.tsx +239 -0
- package/src/components/Chart/stories/examples/Tooltip.tsx +68 -0
- package/src/components/Chart/stories/helpers/index.tsx +75 -0
- package/src/components/Chart/types.ts +39 -0
- package/src/components/DragAndDrop/Draggable/Draggable.example.tsx +147 -0
- package/src/components/DragAndDrop/Draggable/Draggable.tsx +161 -0
- package/src/components/DragAndDrop/Draggable/constants.ts +47 -0
- package/src/components/DragAndDrop/Draggable/index.ts +1 -0
- package/src/components/DragAndDrop/Draggable/types.ts +56 -0
- package/src/components/DragAndDrop/Droppable/Droppable.example.tsx +86 -0
- package/src/components/DragAndDrop/Droppable/Droppable.tsx +38 -0
- package/src/components/DragAndDrop/Droppable/constants.ts +15 -0
- package/src/components/DragAndDrop/Droppable/index.ts +1 -0
- package/src/components/DragAndDrop/Droppable/types.ts +7 -0
- package/src/components/DragAndDrop/Sortable/Sortable.example.tsx +61 -0
- package/src/components/DragAndDrop/Sortable/Sortable.tsx +65 -0
- package/src/components/DragAndDrop/Sortable/constants.ts +12 -0
- package/src/components/DragAndDrop/Sortable/index.ts +1 -0
- package/src/components/DragAndDrop/Sortable/types.ts +11 -0
- package/src/components/DragAndDrop/index.ts +3 -0
- package/src/components/Widget/InternalWidgetsContext.tsx +4 -0
- package/src/components/Widget/Widget.tsx +17 -0
- package/src/components/Widget/Widgets.example.tsx +118 -0
- package/src/components/Widget/WidgetsContext.tsx +97 -0
- package/src/components/Widget/hooks/index.ts +2 -0
- package/src/components/Widget/hooks/useWidget/index.ts +1 -0
- package/src/components/Widget/hooks/useWidget/useWidget.ts +21 -0
- package/src/components/Widget/hooks/useWidgets/index.ts +1 -0
- package/src/components/Widget/hooks/useWidgets/useWidgets.ts +12 -0
- package/src/components/Widget/index.ts +3 -0
- package/src/components/Widget/modifiers/index.ts +1 -0
- package/src/components/Widget/modifiers/restrictToElement.ts +8 -0
- package/src/components/Widget/types.ts +30 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type ArgTypes } from "@storybook/react";
|
|
2
|
+
|
|
3
|
+
export const textArgs: ArgTypes = {
|
|
4
|
+
content: {
|
|
5
|
+
description: "The content of text.",
|
|
6
|
+
},
|
|
7
|
+
lineHeight: {
|
|
8
|
+
description: "The height of each line of text in pixels.",
|
|
9
|
+
table: {
|
|
10
|
+
type: {
|
|
11
|
+
summary: "string",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
control: "text",
|
|
15
|
+
},
|
|
16
|
+
breakAll: {
|
|
17
|
+
description: "Break words if the text exceeds the width.",
|
|
18
|
+
table: {
|
|
19
|
+
type: {
|
|
20
|
+
summary: "boolean",
|
|
21
|
+
},
|
|
22
|
+
defaultValue: {
|
|
23
|
+
summary: "true",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
control: "boolean",
|
|
27
|
+
},
|
|
28
|
+
maxLines: {
|
|
29
|
+
description: "The max number of lines for text wrapping.",
|
|
30
|
+
table: {
|
|
31
|
+
type: {
|
|
32
|
+
summary: "number",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
control: "number",
|
|
36
|
+
},
|
|
37
|
+
scaleToFit: {
|
|
38
|
+
description: "Scale the text to fit the width or not.",
|
|
39
|
+
table: {
|
|
40
|
+
type: {
|
|
41
|
+
summary: "boolean",
|
|
42
|
+
},
|
|
43
|
+
defaultValue: {
|
|
44
|
+
summary: "false",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
control: "boolean",
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
angle: {
|
|
51
|
+
description: "The rotate angle of Text. (Optional)",
|
|
52
|
+
table: {
|
|
53
|
+
type: {
|
|
54
|
+
summary: "number",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
control: "number",
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
width: {
|
|
61
|
+
description:
|
|
62
|
+
"The width of Text. When the width is specified to be a number," +
|
|
63
|
+
" the text will warp auto by calculating the width of text. (Optional)",
|
|
64
|
+
table: {
|
|
65
|
+
type: {
|
|
66
|
+
summary: "number",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
control: "number",
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
textAnchor: {
|
|
73
|
+
table: {
|
|
74
|
+
type: {
|
|
75
|
+
summary: "'start' | 'middle' | 'end' | 'inherit'",
|
|
76
|
+
},
|
|
77
|
+
defaultValue: {
|
|
78
|
+
summary: "'start'",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
control: "radio",
|
|
82
|
+
options: ["start", "middle", "end", "inherit"],
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
verticalAnchor: {
|
|
86
|
+
table: {
|
|
87
|
+
type: {
|
|
88
|
+
summary: "'start' | 'middle' | 'end'",
|
|
89
|
+
},
|
|
90
|
+
defaultValue: {
|
|
91
|
+
summary: "'end'",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
control: "radio",
|
|
95
|
+
options: ["start", "middle", "end"],
|
|
96
|
+
},
|
|
97
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ArgTypes } from "@storybook/react";
|
|
2
|
+
|
|
3
|
+
export const tooltipType: ArgTypes[0] = {
|
|
4
|
+
description: `If set to be 'none', no series data is shown in tooltip.`,
|
|
5
|
+
table: {
|
|
6
|
+
category: "Tooltip",
|
|
7
|
+
type: {
|
|
8
|
+
summary: "'responsive' | 'none'",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
control: "select",
|
|
12
|
+
options: ["responsive", "none"],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const activeDot: ArgTypes[0] = {
|
|
16
|
+
description: `The active dot is shown when a user enters a line chart and this chart has tooltip.
|
|
17
|
+
If set to false, no active dot will be drawn. If set to true, active dot will be drawn with the
|
|
18
|
+
props calculated internally. If passed an object, active dot will be drawn, and the internally
|
|
19
|
+
calculated props will be merged with the key value pairs of the passed object. If passed a ReactElement,
|
|
20
|
+
the option can be the custom active dot element. If passed a function, the function will be called to
|
|
21
|
+
render a customized active dot.`,
|
|
22
|
+
table: {
|
|
23
|
+
type: {
|
|
24
|
+
summary: "Boolean | Object | ReactElement | Function",
|
|
25
|
+
detail: `'<Line dataKey="value" activeDot={false} />\n' +
|
|
26
|
+
'<Line dataKey="value" activeDot={{ stroke: 'red', strokeWidth: 2 }} />\n' +
|
|
27
|
+
'<Line dataKey="value" activeDot={<CustomizedDot />} />\n' +
|
|
28
|
+
'<Line dataKey="value" activeDot={renderDot} />'`,
|
|
29
|
+
},
|
|
30
|
+
defaultValue: {
|
|
31
|
+
summary: "true",
|
|
32
|
+
},
|
|
33
|
+
category: "Tooltip",
|
|
34
|
+
},
|
|
35
|
+
control: "boolean",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const tooltipArgs: ArgTypes = {
|
|
39
|
+
activeDot,
|
|
40
|
+
tooltipType,
|
|
41
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SVGProps } from "react";
|
|
2
|
+
|
|
3
|
+
type SVGKeys = Exclude<
|
|
4
|
+
keyof SVGProps<SVGElement>,
|
|
5
|
+
"type" | "fill" | "fillOpacity" | "stroke" | "strokeWidth" | "className"
|
|
6
|
+
>;
|
|
7
|
+
export type OmitSVGElement<T> = Omit<T, SVGKeys>;
|
|
8
|
+
|
|
9
|
+
export type Flatten<T> = NonNullable<
|
|
10
|
+
{
|
|
11
|
+
[K in keyof T]: T[K] extends never
|
|
12
|
+
? never
|
|
13
|
+
: {
|
|
14
|
+
[P in keyof T[K]]: T[K][P] extends never
|
|
15
|
+
? {
|
|
16
|
+
[Q in `${Exclude<K, symbol>} ${Exclude<P, symbol>}`]: never;
|
|
17
|
+
} // Stop here, don't flatten further
|
|
18
|
+
: {
|
|
19
|
+
[Q in `${Exclude<K, symbol>} ${Exclude<P, symbol>}`]: T[K][P];
|
|
20
|
+
}; // Flatten key-value pair
|
|
21
|
+
}[keyof T[K]]; // Flatten first level key-value pair
|
|
22
|
+
}[keyof T]
|
|
23
|
+
>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type ArgTypes } from "@storybook/react";
|
|
2
|
+
import { sharedAxisArgs } from "./sharedAxisArgs";
|
|
3
|
+
|
|
4
|
+
export const xAxisArgs: ArgTypes = {
|
|
5
|
+
...sharedAxisArgs,
|
|
6
|
+
hide: {
|
|
7
|
+
description: "If set true, the axis do not display in the chart.",
|
|
8
|
+
table: {
|
|
9
|
+
type: {
|
|
10
|
+
summary: "boolean",
|
|
11
|
+
},
|
|
12
|
+
defaultValue: {
|
|
13
|
+
summary: "false",
|
|
14
|
+
},
|
|
15
|
+
category: "General",
|
|
16
|
+
},
|
|
17
|
+
control: "boolean",
|
|
18
|
+
},
|
|
19
|
+
includeHidden: {
|
|
20
|
+
description: "Consider hidden graphical elements when computing domain.",
|
|
21
|
+
table: {
|
|
22
|
+
type: {
|
|
23
|
+
summary: "boolean",
|
|
24
|
+
},
|
|
25
|
+
defaultValue: {
|
|
26
|
+
summary: "false",
|
|
27
|
+
},
|
|
28
|
+
category: "Domain",
|
|
29
|
+
},
|
|
30
|
+
control: "boolean",
|
|
31
|
+
},
|
|
32
|
+
dataKey: {
|
|
33
|
+
description: "The key of data displayed in the axis.",
|
|
34
|
+
table: {
|
|
35
|
+
type: {
|
|
36
|
+
summary: "string | number | Function",
|
|
37
|
+
},
|
|
38
|
+
category: "General",
|
|
39
|
+
},
|
|
40
|
+
control: "text",
|
|
41
|
+
},
|
|
42
|
+
xAxisId: {
|
|
43
|
+
description: "The unique id of x-axis.",
|
|
44
|
+
table: {
|
|
45
|
+
type: {
|
|
46
|
+
summary: "string | number",
|
|
47
|
+
},
|
|
48
|
+
defaultValue: {
|
|
49
|
+
summary: "'0'",
|
|
50
|
+
},
|
|
51
|
+
category: "General",
|
|
52
|
+
},
|
|
53
|
+
control: "text",
|
|
54
|
+
},
|
|
55
|
+
height: {
|
|
56
|
+
description: "The height of axis element in pixels.",
|
|
57
|
+
table: {
|
|
58
|
+
type: {
|
|
59
|
+
summary: "number",
|
|
60
|
+
},
|
|
61
|
+
defaultValue: {
|
|
62
|
+
summary: "30",
|
|
63
|
+
},
|
|
64
|
+
category: "Layout",
|
|
65
|
+
},
|
|
66
|
+
control: "number",
|
|
67
|
+
},
|
|
68
|
+
orientation: {
|
|
69
|
+
description: "The orientation of axis",
|
|
70
|
+
table: {
|
|
71
|
+
type: {
|
|
72
|
+
summary: "'bottom' , 'top'",
|
|
73
|
+
},
|
|
74
|
+
defaultValue: {
|
|
75
|
+
summary: "'bottom'",
|
|
76
|
+
},
|
|
77
|
+
category: "Layout",
|
|
78
|
+
},
|
|
79
|
+
control: "inline-radio",
|
|
80
|
+
options: ["top", "bottom"],
|
|
81
|
+
},
|
|
82
|
+
type: {
|
|
83
|
+
description: "The type of axis.",
|
|
84
|
+
table: {
|
|
85
|
+
type: {
|
|
86
|
+
summary: "'number' | 'category'",
|
|
87
|
+
},
|
|
88
|
+
defaultValue: {
|
|
89
|
+
summary: "'category'",
|
|
90
|
+
},
|
|
91
|
+
category: "General",
|
|
92
|
+
},
|
|
93
|
+
control: "inline-radio",
|
|
94
|
+
options: ["number", "category"],
|
|
95
|
+
},
|
|
96
|
+
padding: {
|
|
97
|
+
description: "Specify the padding of x-axis.",
|
|
98
|
+
table: {
|
|
99
|
+
type: {
|
|
100
|
+
summary: 'Object | "gap" | "no-gap"',
|
|
101
|
+
},
|
|
102
|
+
defaultValue: {
|
|
103
|
+
summary: "{ left: 0, right: 0 }",
|
|
104
|
+
},
|
|
105
|
+
category: "Ticks",
|
|
106
|
+
},
|
|
107
|
+
control: "object",
|
|
108
|
+
},
|
|
109
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type ArgTypes } from "@storybook/react";
|
|
2
|
+
import { sharedAxisArgs } from "./sharedAxisArgs";
|
|
3
|
+
|
|
4
|
+
export const yAxisArgs: ArgTypes = {
|
|
5
|
+
...sharedAxisArgs,
|
|
6
|
+
yAxisId: {
|
|
7
|
+
description: "The unique id of y-axis.",
|
|
8
|
+
table: {
|
|
9
|
+
type: {
|
|
10
|
+
summary: "string | number",
|
|
11
|
+
},
|
|
12
|
+
defaultValue: {
|
|
13
|
+
summary: "'0'",
|
|
14
|
+
},
|
|
15
|
+
category: "General",
|
|
16
|
+
},
|
|
17
|
+
control: "text",
|
|
18
|
+
},
|
|
19
|
+
width: {
|
|
20
|
+
description: "The width of axis element in pixels.",
|
|
21
|
+
table: {
|
|
22
|
+
type: {
|
|
23
|
+
summary: "number",
|
|
24
|
+
},
|
|
25
|
+
defaultValue: {
|
|
26
|
+
summary: "60",
|
|
27
|
+
},
|
|
28
|
+
category: "Layout",
|
|
29
|
+
},
|
|
30
|
+
control: "number",
|
|
31
|
+
},
|
|
32
|
+
orientation: {
|
|
33
|
+
description: "The orientation of axis",
|
|
34
|
+
table: {
|
|
35
|
+
type: {
|
|
36
|
+
summary: "'left' , 'right'",
|
|
37
|
+
},
|
|
38
|
+
defaultValue: {
|
|
39
|
+
summary: "'left'",
|
|
40
|
+
},
|
|
41
|
+
category: "Layout",
|
|
42
|
+
},
|
|
43
|
+
control: "inline-radio",
|
|
44
|
+
options: ["left", "right"],
|
|
45
|
+
},
|
|
46
|
+
type: {
|
|
47
|
+
description: "The type of axis.",
|
|
48
|
+
table: {
|
|
49
|
+
type: {
|
|
50
|
+
summary: "'number' | 'category'",
|
|
51
|
+
},
|
|
52
|
+
defaultValue: {
|
|
53
|
+
summary: "'number'",
|
|
54
|
+
},
|
|
55
|
+
category: "General",
|
|
56
|
+
},
|
|
57
|
+
control: "inline-radio",
|
|
58
|
+
options: ["number", "category"],
|
|
59
|
+
},
|
|
60
|
+
padding: {
|
|
61
|
+
description: "Specify the padding of x-axis.",
|
|
62
|
+
table: {
|
|
63
|
+
type: {
|
|
64
|
+
summary: "{ top: number, bottom: number }",
|
|
65
|
+
},
|
|
66
|
+
defaultValue: {
|
|
67
|
+
summary: "{ top: 0, bottom: 0 }",
|
|
68
|
+
},
|
|
69
|
+
category: "Ticks",
|
|
70
|
+
},
|
|
71
|
+
control: "object",
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts";
|
|
2
|
+
import { Chart } from "../../Chart";
|
|
3
|
+
import {
|
|
4
|
+
ChartLegend,
|
|
5
|
+
ChartLegendContent,
|
|
6
|
+
ChartTooltip,
|
|
7
|
+
ChartTooltipContent,
|
|
8
|
+
} from "../../components";
|
|
9
|
+
import { type ChartConfig } from "../../types";
|
|
10
|
+
import { type AreaChartProps } from "../args";
|
|
11
|
+
|
|
12
|
+
const chartConfig = {
|
|
13
|
+
desktop: {
|
|
14
|
+
label: "Desktop",
|
|
15
|
+
color: "hsl(var(--chart-1))",
|
|
16
|
+
},
|
|
17
|
+
mobile: {
|
|
18
|
+
label: "Mobile",
|
|
19
|
+
color: "hsl(var(--chart-2))",
|
|
20
|
+
},
|
|
21
|
+
other: {
|
|
22
|
+
label: "Other",
|
|
23
|
+
color: "hsl(var(--chart-5))",
|
|
24
|
+
},
|
|
25
|
+
} satisfies ChartConfig;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* ## Parent
|
|
29
|
+
*
|
|
30
|
+
* The AreaChart can be used within: `<Chart />`
|
|
31
|
+
*
|
|
32
|
+
* ## Children
|
|
33
|
+
*
|
|
34
|
+
* The AreaChart can be used with the following child components: `<XAxis />`, `<YAxis />`, `<ReferenceArea />`, `<ReferenceDot />`, `<ReferenceArea />`,
|
|
35
|
+
* `<Brush />`, `<CartesianGrid />`, `<ChartLegend />`, `<ChartTooltip />`, `<Area />`, `<Customized />` or valid svg elements.
|
|
36
|
+
*/
|
|
37
|
+
export const AreaChartExample = (props: Partial<AreaChartProps>) => {
|
|
38
|
+
return (
|
|
39
|
+
<Chart config={chartConfig} className="h-[250px] w-full">
|
|
40
|
+
<AreaChart {...props.areaChart}>
|
|
41
|
+
<CartesianGrid vertical={false} />
|
|
42
|
+
<XAxis {...props.xAxis} />
|
|
43
|
+
<ChartTooltip content={<ChartTooltipContent indicator="line" />} />
|
|
44
|
+
<Area dataKey="desktop" {...props.area} />
|
|
45
|
+
</AreaChart>
|
|
46
|
+
</Chart>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const StackedAreaChartExample = (props: Partial<AreaChartProps>) => {
|
|
51
|
+
return (
|
|
52
|
+
<Chart config={chartConfig} className="h-[250px] w-full">
|
|
53
|
+
<AreaChart {...props.areaChart}>
|
|
54
|
+
<CartesianGrid vertical={false} />
|
|
55
|
+
<XAxis {...props.xAxis} />
|
|
56
|
+
<ChartTooltip cursor={false} content={<ChartTooltipContent indicator="dot" />} />
|
|
57
|
+
<Area
|
|
58
|
+
dataKey="mobile"
|
|
59
|
+
fill="var(--color-mobile)"
|
|
60
|
+
stroke="var(--color-mobile)"
|
|
61
|
+
{...props.area}
|
|
62
|
+
/>
|
|
63
|
+
<Area
|
|
64
|
+
dataKey="desktop"
|
|
65
|
+
fill="var(--color-desktop)"
|
|
66
|
+
stroke="var(--color-desktop)"
|
|
67
|
+
{...props.area}
|
|
68
|
+
/>
|
|
69
|
+
</AreaChart>
|
|
70
|
+
</Chart>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const StackedExpandedAreaChartExample = (props: Partial<AreaChartProps>) => {
|
|
75
|
+
return (
|
|
76
|
+
<Chart config={chartConfig} className="h-[250px] w-full">
|
|
77
|
+
<AreaChart {...props.areaChart}>
|
|
78
|
+
<CartesianGrid vertical={false} />
|
|
79
|
+
<XAxis {...props.xAxis} />
|
|
80
|
+
<ChartTooltip cursor={false} content={<ChartTooltipContent indicator="line" />} />
|
|
81
|
+
<defs>
|
|
82
|
+
<linearGradient id="fillDesktop" x1="0" y1="0" x2="0" y2="1">
|
|
83
|
+
<stop offset="5%" stopColor="var(--color-desktop)" stopOpacity={0.8} />
|
|
84
|
+
<stop offset="95%" stopColor="var(--color-desktop)" stopOpacity={0.1} />
|
|
85
|
+
</linearGradient>
|
|
86
|
+
<linearGradient id="fillMobile" x1="0" y1="0" x2="0" y2="1">
|
|
87
|
+
<stop offset="5%" stopColor="var(--color-mobile)" stopOpacity={0.8} />
|
|
88
|
+
<stop offset="95%" stopColor="var(--color-mobile)" stopOpacity={0.1} />
|
|
89
|
+
</linearGradient>
|
|
90
|
+
</defs>
|
|
91
|
+
<Area
|
|
92
|
+
dataKey="other"
|
|
93
|
+
fill="var(--color-other)"
|
|
94
|
+
fillOpacity={0.1}
|
|
95
|
+
stroke="var(--color-other)"
|
|
96
|
+
{...props.area}
|
|
97
|
+
/>
|
|
98
|
+
<Area
|
|
99
|
+
dataKey="mobile"
|
|
100
|
+
fill="url(#fillMobile)"
|
|
101
|
+
fillOpacity={0.4}
|
|
102
|
+
stroke="var(--color-mobile)"
|
|
103
|
+
{...props.area}
|
|
104
|
+
/>
|
|
105
|
+
<Area
|
|
106
|
+
dataKey="desktop"
|
|
107
|
+
type="natural"
|
|
108
|
+
fill="url(#fillDesktop)"
|
|
109
|
+
fillOpacity={0.4}
|
|
110
|
+
stroke="var(--color-desktop)"
|
|
111
|
+
stackId="a"
|
|
112
|
+
{...props.area}
|
|
113
|
+
/>
|
|
114
|
+
</AreaChart>
|
|
115
|
+
</Chart>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const LabeledAreaChartExample = (props: Partial<AreaChartProps>) => {
|
|
120
|
+
return (
|
|
121
|
+
<Chart config={chartConfig} className="h-[250px] w-full">
|
|
122
|
+
<AreaChart {...props.areaChart}>
|
|
123
|
+
<CartesianGrid vertical={false} />
|
|
124
|
+
<XAxis {...props.xAxis} />
|
|
125
|
+
<YAxis {...props.yAxis} />
|
|
126
|
+
<ChartTooltip content={<ChartTooltipContent indicator="line" />} />
|
|
127
|
+
<Area dataKey="month" {...props.area} />
|
|
128
|
+
</AreaChart>
|
|
129
|
+
</Chart>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const WithLegendAreaChartExample = (props: Partial<AreaChartProps>) => {
|
|
134
|
+
return (
|
|
135
|
+
<Chart config={chartConfig} className="h-[250px] w-full">
|
|
136
|
+
<AreaChart {...props.areaChart}>
|
|
137
|
+
<CartesianGrid vertical={false} />
|
|
138
|
+
<XAxis {...props.xAxis} />
|
|
139
|
+
<ChartTooltip cursor={false} content={<ChartTooltipContent indicator="line" />} />
|
|
140
|
+
<Area
|
|
141
|
+
dataKey="mobile"
|
|
142
|
+
fill="var(--color-mobile)"
|
|
143
|
+
stroke="var(--color-mobile)"
|
|
144
|
+
{...props.area}
|
|
145
|
+
/>
|
|
146
|
+
<Area
|
|
147
|
+
dataKey="desktop"
|
|
148
|
+
fill="var(--color-desktop)"
|
|
149
|
+
stroke="var(--color-desktop)"
|
|
150
|
+
{...props.area}
|
|
151
|
+
/>
|
|
152
|
+
<ChartLegend content={<ChartLegendContent />} />
|
|
153
|
+
</AreaChart>
|
|
154
|
+
</Chart>
|
|
155
|
+
);
|
|
156
|
+
};
|