@wavemaker/react-native-echarts 1.0.0-dev.0

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.
Files changed (145) hide show
  1. package/.npmignore +4 -0
  2. package/LICENSE +21 -0
  3. package/README.md +39 -0
  4. package/area/area-chart.d.ts +12 -0
  5. package/area/area-chart.d.ts.map +1 -0
  6. package/area/area-chart.js +404 -0
  7. package/area/area-chart.props.d.ts +64 -0
  8. package/area/area-chart.props.d.ts.map +1 -0
  9. package/area/area-chart.props.js +0 -0
  10. package/area/index.d.ts +3 -0
  11. package/area/index.d.ts.map +1 -0
  12. package/area/index.js +1 -0
  13. package/axis.d.ts +3 -0
  14. package/axis.d.ts.map +1 -0
  15. package/axis.js +16 -0
  16. package/bar/bar-chart.d.ts +11 -0
  17. package/bar/bar-chart.d.ts.map +1 -0
  18. package/bar/bar-chart.js +6 -0
  19. package/bar/bar-chart.props.d.ts +7 -0
  20. package/bar/bar-chart.props.d.ts.map +1 -0
  21. package/bar/bar-chart.props.js +0 -0
  22. package/bar/index.d.ts +3 -0
  23. package/bar/index.d.ts.map +1 -0
  24. package/bar/index.js +1 -0
  25. package/bubble/bubble-chart.d.ts +13 -0
  26. package/bubble/bubble-chart.d.ts.map +1 -0
  27. package/bubble/bubble-chart.js +305 -0
  28. package/bubble/bubble-chart.props.d.ts +26 -0
  29. package/bubble/bubble-chart.props.d.ts.map +1 -0
  30. package/bubble/bubble-chart.props.js +0 -0
  31. package/bubble/index.d.ts +3 -0
  32. package/bubble/index.d.ts.map +1 -0
  33. package/bubble/index.js +1 -0
  34. package/candlestick/candlestick-chart.d.ts +12 -0
  35. package/candlestick/candlestick-chart.d.ts.map +1 -0
  36. package/candlestick/candlestick-chart.js +292 -0
  37. package/candlestick/candlestick-chart.props.d.ts +51 -0
  38. package/candlestick/candlestick-chart.props.d.ts.map +1 -0
  39. package/candlestick/candlestick-chart.props.js +0 -0
  40. package/candlestick/index.d.ts +3 -0
  41. package/candlestick/index.d.ts.map +1 -0
  42. package/candlestick/index.js +1 -0
  43. package/chart-container.d.ts +6 -0
  44. package/chart-container.d.ts.map +1 -0
  45. package/chart-container.js +63 -0
  46. package/chart-theme.context.d.ts +191 -0
  47. package/chart-theme.context.d.ts.map +1 -0
  48. package/chart-theme.context.js +276 -0
  49. package/column/column-chart.d.ts +13 -0
  50. package/column/column-chart.d.ts.map +1 -0
  51. package/column/column-chart.js +481 -0
  52. package/column/column-chart.props.d.ts +83 -0
  53. package/column/column-chart.props.d.ts.map +1 -0
  54. package/column/column-chart.props.js +0 -0
  55. package/column/index.d.ts +3 -0
  56. package/column/index.d.ts.map +1 -0
  57. package/column/index.js +1 -0
  58. package/gauge/digital/digital.gauge.d.ts +28 -0
  59. package/gauge/digital/digital.gauge.d.ts.map +1 -0
  60. package/gauge/digital/digital.gauge.js +213 -0
  61. package/gauge/gauge.types.d.ts +51 -0
  62. package/gauge/gauge.types.d.ts.map +1 -0
  63. package/gauge/gauge.types.js +0 -0
  64. package/gauge/index.d.ts +6 -0
  65. package/gauge/index.d.ts.map +1 -0
  66. package/gauge/index.js +4 -0
  67. package/gauge/radial/radial.gauge.d.ts +18 -0
  68. package/gauge/radial/radial.gauge.d.ts.map +1 -0
  69. package/gauge/radial/radial.gauge.js +284 -0
  70. package/gauge/simple/simple.gauge.d.ts +28 -0
  71. package/gauge/simple/simple.gauge.d.ts.map +1 -0
  72. package/gauge/simple/simple.gauge.js +102 -0
  73. package/gauge/speedometer/speedometer.gauge.d.ts +35 -0
  74. package/gauge/speedometer/speedometer.gauge.d.ts.map +1 -0
  75. package/gauge/speedometer/speedometer.gauge.js +241 -0
  76. package/geo/geo-chart.d.ts +15 -0
  77. package/geo/geo-chart.d.ts.map +1 -0
  78. package/geo/geo-chart.js +200 -0
  79. package/geo/geo-chart.props.d.ts +96 -0
  80. package/geo/geo-chart.props.d.ts.map +1 -0
  81. package/geo/geo-chart.props.js +0 -0
  82. package/geo/index.d.ts +7 -0
  83. package/geo/index.d.ts.map +1 -0
  84. package/geo/index.js +3 -0
  85. package/geo/us-chart.d.ts +15 -0
  86. package/geo/us-chart.d.ts.map +1 -0
  87. package/geo/us-chart.js +15 -0
  88. package/geo/world-chart.d.ts +15 -0
  89. package/geo/world-chart.d.ts.map +1 -0
  90. package/geo/world-chart.js +10 -0
  91. package/index.d.ts +17 -0
  92. package/index.d.ts.map +1 -0
  93. package/index.js +15 -0
  94. package/line/index.d.ts +3 -0
  95. package/line/index.d.ts.map +1 -0
  96. package/line/index.js +1 -0
  97. package/line/line-chart.d.ts +9 -0
  98. package/line/line-chart.d.ts.map +1 -0
  99. package/line/line-chart.js +8 -0
  100. package/line/line-chart.props.d.ts +12 -0
  101. package/line/line-chart.props.d.ts.map +1 -0
  102. package/line/line-chart.props.js +0 -0
  103. package/package.json +39 -0
  104. package/pie/index.d.ts +4 -0
  105. package/pie/index.d.ts.map +1 -0
  106. package/pie/index.js +2 -0
  107. package/pie/pie-chart.d.ts +13 -0
  108. package/pie/pie-chart.d.ts.map +1 -0
  109. package/pie/pie-chart.js +222 -0
  110. package/pie/pie-chart.props.d.ts +97 -0
  111. package/pie/pie-chart.props.d.ts.map +1 -0
  112. package/pie/pie-chart.props.js +12 -0
  113. package/props/cartesian.d.ts +120 -0
  114. package/props/cartesian.d.ts.map +1 -0
  115. package/props/cartesian.js +0 -0
  116. package/props/common.d.ts +28 -0
  117. package/props/common.d.ts.map +1 -0
  118. package/props/common.js +0 -0
  119. package/radar/index.d.ts +3 -0
  120. package/radar/index.d.ts.map +1 -0
  121. package/radar/index.js +1 -0
  122. package/radar/radar-chart.d.ts +12 -0
  123. package/radar/radar-chart.d.ts.map +1 -0
  124. package/radar/radar-chart.js +197 -0
  125. package/radar/radar-chart.props.d.ts +80 -0
  126. package/radar/radar-chart.props.d.ts.map +1 -0
  127. package/radar/radar-chart.props.js +0 -0
  128. package/radial/index.d.ts +3 -0
  129. package/radial/index.d.ts.map +1 -0
  130. package/radial/index.js +1 -0
  131. package/radial/radial-chart.d.ts +12 -0
  132. package/radial/radial-chart.d.ts.map +1 -0
  133. package/radial/radial-chart.js +235 -0
  134. package/radial/radial-chart.props.d.ts +74 -0
  135. package/radial/radial-chart.props.d.ts.map +1 -0
  136. package/radial/radial-chart.props.js +0 -0
  137. package/scatter/index.d.ts +3 -0
  138. package/scatter/index.d.ts.map +1 -0
  139. package/scatter/index.js +1 -0
  140. package/scatter/scatter-chart.d.ts +13 -0
  141. package/scatter/scatter-chart.d.ts.map +1 -0
  142. package/scatter/scatter-chart.js +310 -0
  143. package/scatter/scatter-chart.props.d.ts +36 -0
  144. package/scatter/scatter-chart.props.d.ts.map +1 -0
  145. package/scatter/scatter-chart.props.js +0 -0
@@ -0,0 +1,51 @@
1
+ import type { CartesianChartProps } from '../props/cartesian';
2
+ /**
3
+ * One candlestick data point: [open, close, low, high].
4
+ */
5
+ export type CandlestickItem = [number, number, number, number];
6
+ /**
7
+ * Candlestick chart data: array of [open, close, low, high] per period.
8
+ */
9
+ export type CandlestickData = CandlestickItem[];
10
+ /**
11
+ * Props for CandlestickChart.
12
+ * common -> cartesian -> candlestick.
13
+ * colors is omitted; use positiveColor and negativeColor for candle colors.
14
+ */
15
+ export interface CandlestickChartProps extends Omit<CartesianChartProps, 'colors'> {
16
+ /**
17
+ * Candlestick data: array of [open, close, low, high] per period.
18
+ */
19
+ data: CandlestickData;
20
+ /**
21
+ * X-axis category labels. If omitted, indices (0, 1, 2, ...) are used.
22
+ */
23
+ xAxisData?: (string | number)[];
24
+ /**
25
+ * Optional volume data (bar series below candlestick). Length should match data.
26
+ */
27
+ volumeData?: number[];
28
+ /**
29
+ * Optional MA5 (5-period moving average) line. Length should match data.
30
+ */
31
+ ma5?: number[];
32
+ /**
33
+ * Optional MA10 (10-period moving average) line. Length should match data.
34
+ */
35
+ ma10?: number[];
36
+ /**
37
+ * Optional MA20 (20-period moving average) line. Length should match data.
38
+ */
39
+ ma20?: number[];
40
+ /**
41
+ * Color for positive (up) candles.
42
+ * @default '#008000'
43
+ */
44
+ positiveColor?: string;
45
+ /**
46
+ * Color for negative (down) candles.
47
+ * @default '#FF2C2C'
48
+ */
49
+ negativeColor?: string;
50
+ }
51
+ //# sourceMappingURL=candlestick-chart.props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"candlestick-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/candlestick/candlestick-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,eAAe,EAAE,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC;IAChF;;OAEG;IACH,IAAI,EAAE,eAAe,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAChC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
File without changes
@@ -0,0 +1,3 @@
1
+ export { CandlestickChart } from './candlestick-chart';
2
+ export type { CandlestickChartProps, CandlestickData, CandlestickItem, } from './candlestick-chart.props';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/candlestick/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,eAAe,GAChB,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1 @@
1
+ export { CandlestickChart } from './candlestick-chart';
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export declare const withResponsiveContainer: <T extends React.ComponentType<any>>(Component: T, ...dataName: string[]) => (props: React.ComponentProps<T> & {
3
+ width?: number | string;
4
+ height?: number | string;
5
+ }) => React.JSX.Element;
6
+ //# sourceMappingURL=chart-container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-container.d.ts","sourceRoot":"","sources":["../../../components/chart/chart-container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAqGrD,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,EAAE,GAAG,UAAU,MAAM,EAAE,MACrG,OAAO,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,sBAmB/F,CAAC"}
@@ -0,0 +1,63 @@
1
+ import React, { useState, useCallback } from 'react';
2
+ import { View, StyleSheet, Text } from 'react-native';
3
+ const ChartContainer = ({ width = '100%', height = 350, data, noDataText = 'No data to render chart.', noDataIcon, noDataTextStyle = {}, noDataContainerStyle = {}, render, style, }) => {
4
+ const [dimensions, setDimensions] = useState(null);
5
+ const handleLayout = useCallback((event) => {
6
+ const { width: layoutWidth, height: layoutHeight } = event.nativeEvent.layout;
7
+ // Calculate actual dimensions based on props
8
+ let actualWidth = layoutWidth;
9
+ let actualHeight = layoutHeight;
10
+ // If width/height are numbers, use them directly
11
+ // If they're percentages, they're already resolved by React Native's layout system
12
+ if (typeof width === 'number') {
13
+ actualWidth = width;
14
+ }
15
+ if (typeof height === 'number') {
16
+ actualHeight = height;
17
+ }
18
+ setDimensions({
19
+ width: actualWidth,
20
+ height: actualHeight,
21
+ });
22
+ }, [width, height]);
23
+ // Parse width and height for container style
24
+ const containerStyle = {
25
+ width: typeof width === 'number' ? width : width,
26
+ height: typeof height === 'number' ? height : height,
27
+ };
28
+ return (<View style={[styles.container, containerStyle, style]} onLayout={handleLayout}>
29
+ {data ? (dimensions ? render(dimensions.width, dimensions.height) : null) : (<View style={[styles.noDataContainer, noDataContainerStyle, style]}>
30
+ <Text style={[styles.noDataText, noDataTextStyle]}>{noDataText}</Text>
31
+ </View>)}
32
+ </View>);
33
+ };
34
+ const styles = StyleSheet.create({
35
+ container: {
36
+ overflow: 'hidden',
37
+ justifyContent: 'center',
38
+ alignItems: 'center',
39
+ },
40
+ noDataContainer: {
41
+ minHeight: 200,
42
+ justifyContent: 'center',
43
+ alignItems: 'center',
44
+ },
45
+ noDataText: {
46
+ fontSize: 16,
47
+ fontWeight: 'bold',
48
+ color: '#222',
49
+ },
50
+ });
51
+ export const withResponsiveContainer = (Component, ...dataName) => {
52
+ return (props) => {
53
+ const render = useCallback((width, height) => {
54
+ return React.createElement(Component, {
55
+ ...props,
56
+ width: width,
57
+ height: height,
58
+ });
59
+ }, [props]);
60
+ const data = dataName.length > 0 ? dataName.find((name) => !!props[name]) || props.data : props.data;
61
+ return (<ChartContainer width={props.width} height={props.height} style={props.style} data={data} render={render} noDataText={props.noDataText}/>);
62
+ };
63
+ };
@@ -0,0 +1,191 @@
1
+ import React from 'react';
2
+ /**
3
+ * Style configuration for chart axes (x, y, or radial).
4
+ * Defines the visual appearance of axis lines, labels, ticks, and split lines.
5
+ */
6
+ type AxisStyle = {
7
+ /** Color of the main axis line */
8
+ lineColor: string;
9
+ /** Width of the main axis line in pixels */
10
+ lineWidth: number;
11
+ /** Color of the axis label text */
12
+ labelColor: string;
13
+ /** Color of the tick marks */
14
+ tickColor: string;
15
+ /** Width of the tick marks in pixels */
16
+ tickWidth: number;
17
+ /** Color of the tick mark labels */
18
+ tickLabelColor: string;
19
+ /** Color of the split lines (grid lines parallel to axis) */
20
+ splitLineColor: string;
21
+ /** Width of the split lines in pixels */
22
+ splitLineWidth: number;
23
+ };
24
+ /**
25
+ * Style configuration for grid lines.
26
+ * Defines the visual appearance of grid lines that help with data reading.
27
+ */
28
+ type GridLineStyle = {
29
+ /** Color of the grid lines */
30
+ lineColor: string;
31
+ /** Width of the grid lines in pixels */
32
+ lineWidth: number;
33
+ };
34
+ /**
35
+ * Style configuration for tooltips.
36
+ * Defines the visual appearance of tooltips that appear when hovering over chart elements.
37
+ */
38
+ type TooltipStyle = {
39
+ /** Background color of the tooltip */
40
+ backgroundColor: string;
41
+ /** Color of the label text in the tooltip */
42
+ labelColor: string;
43
+ /** Color of the value text in the tooltip */
44
+ valueColor: string;
45
+ /** Color of the tooltip border */
46
+ borderColor: string;
47
+ /** Width of the tooltip border in pixels */
48
+ borderWidth: number;
49
+ /** Border radius of the tooltip corners in pixels */
50
+ borderRadius: number;
51
+ /** Internal padding of the tooltip in pixels */
52
+ padding: number;
53
+ };
54
+ /**
55
+ * Style configuration for chart items (bars, lines, pie slices, etc.).
56
+ * Defines the visual appearance of individual data elements in the chart.
57
+ */
58
+ type Series = {
59
+ /** Primary color for the data series */
60
+ color: string;
61
+ /** Width of lines for line/area charts in pixels */
62
+ lineWidth?: number;
63
+ /** Border radius for each corner [top-left, top-right, bottom-right, bottom-left] */
64
+ borderRadius?: number[];
65
+ /** Color of the border around chart items */
66
+ borderColor?: string;
67
+ /** Width of the border around chart items in pixels */
68
+ borderWidth?: number;
69
+ /** Style of the border: 'solid', 'dashed', or 'dotted' */
70
+ borderType?: 'solid' | 'dashed' | 'dotted';
71
+ };
72
+ /**
73
+ * Style configuration for chart legends.
74
+ * Defines the visual appearance of legends that identify data series in charts.
75
+ */
76
+ type LegendStyle = {
77
+ /** Color of the legend text */
78
+ textColor: string;
79
+ /** Font size of the legend text in pixels */
80
+ fontSize: number;
81
+ /** Color of the legend background */
82
+ backgroundColor: string;
83
+ };
84
+ /**
85
+ * Complete chart theme configuration.
86
+ * Contains styling for all chart components: axes (x, y, radial), grid lines, tooltips, and item styles.
87
+ * The series array provides a color palette that cycles through for multiple data series.
88
+ */
89
+ export type ChartTheme = {
90
+ /** Configuration for chart axes (x, y, and radial) */
91
+ axis: {
92
+ /** X-axis styling configuration */
93
+ x: AxisStyle;
94
+ /** Y-axis styling configuration */
95
+ y: AxisStyle;
96
+ /** Radial axis styling configuration (for radar/polar charts) */
97
+ r: AxisStyle;
98
+ };
99
+ /** Configuration for grid lines */
100
+ grid: {
101
+ /** X-axis grid line styling */
102
+ x: GridLineStyle;
103
+ /** Y-axis grid line styling */
104
+ y: GridLineStyle;
105
+ /** Radial grid line styling (for radar/polar charts) */
106
+ r: GridLineStyle;
107
+ };
108
+ legend: LegendStyle;
109
+ /** Configuration for tooltip appearance */
110
+ tooltip: TooltipStyle;
111
+ /** Array of series styles that cycle through for multiple data series */
112
+ series: Series[];
113
+ };
114
+ /**
115
+ * Utility function to extend the default theme with custom overrides.
116
+ * Useful for creating theme variants without using the React context system.
117
+ *
118
+ * @param theme - Partial theme configuration to merge with defaults
119
+ * @returns A complete ChartTheme with defaults merged
120
+ */
121
+ export declare const extendChartTheme: (...themes: Partial<ChartTheme>[]) => ChartTheme;
122
+ /**
123
+ * Default chart theme configuration.
124
+ * Provides sensible defaults for all chart styling elements.
125
+ * Uses a blue color palette for item styles that cycles through different shades.
126
+ */
127
+ export declare const LIGHT_THEME: ChartTheme;
128
+ export declare const DARK_THEME: ChartTheme;
129
+ /**
130
+ * Type definition for the chart theme context value.
131
+ * Contains the current theme that can be accessed by chart components.
132
+ */
133
+ interface ChartThemeContextType {
134
+ /** The current chart theme configuration */
135
+ theme: ChartTheme;
136
+ }
137
+ /**
138
+ * Hook to access and optionally extend the chart theme.
139
+ * Merges the theme from context (if available) with any local theme overrides.
140
+ * The local theme parameter takes precedence over the context theme.
141
+ *
142
+ * @param theme - Optional partial theme to merge with the context theme
143
+ * @returns ChartThemeContextType with the merged theme
144
+ *
145
+ * @example
146
+ * ```tsx
147
+ * const { theme } = useChartTheme({ tooltip: { backgroundColor: '#000' } });
148
+ * ```
149
+ */
150
+ export declare const useChartTheme: (theme?: Partial<ChartTheme>, colors?: string[]) => ChartThemeContextType;
151
+ /**
152
+ * Props for the ChartThemeProvider component.
153
+ */
154
+ interface ThemeProviderProps {
155
+ /** Partial theme configuration to merge with parent theme or defaults */
156
+ theme: Partial<ChartTheme>;
157
+ /** Child components that will have access to the theme */
158
+ children: React.ReactNode;
159
+ }
160
+ /**
161
+ * Provider component that supplies chart theme configuration to child components.
162
+ * Supports nested providers - child providers will merge their theme with the parent theme.
163
+ * The parent theme serves as the base, and the current provider's theme overrides it.
164
+ *
165
+ * @example
166
+ * ```tsx
167
+ * <ChartThemeProvider theme={{ tooltip: { backgroundColor: '#000' } }}>
168
+ * <MyChart />
169
+ * </ChartThemeProvider>
170
+ * ```
171
+ */
172
+ export declare const ChartThemeProvider: React.FC<ThemeProviderProps>;
173
+ /**
174
+ * Higher-order component (HOC) that wraps a component with ChartThemeProvider.
175
+ * Allows passing a theme prop directly to a component, which will be applied
176
+ * to that component and its children.
177
+ *
178
+ * @param Component - The component to wrap with theme provider
179
+ * @returns A new component that accepts an optional theme prop
180
+ *
181
+ * @example
182
+ * ```tsx
183
+ * const ThemedChart = withChartTheme(MyChart);
184
+ * <ThemedChart theme={{ tooltip: { backgroundColor: '#000' } }} />
185
+ * ```
186
+ */
187
+ export declare const withChartTheme: <T extends React.ComponentType<any>>(Component: T) => (props: React.ComponentProps<T> & {
188
+ theme?: Partial<ChartTheme>;
189
+ }) => React.JSX.Element;
190
+ export {};
191
+ //# sourceMappingURL=chart-theme.context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-theme.context.d.ts","sourceRoot":"","sources":["../../../components/chart/ch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AC,EAAE,SAAS,MAAM,EAAE,0BAyB3E,CAAC;AAEF;;GAEG;AACH,UAAU,kBAAkB;IAC1B,yEAAyE;IACzE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3B,0DAA0D;IAC1D,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAa3D,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,MACrE,OAAO,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;CAAE,sBAOzE,CAAC"}
@@ -0,0 +1,276 @@
1
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
2
+ /**
3
+ * Merges two chart themes together, with theme2 taking precedence over theme1.
4
+ * Performs a deep merge for nested objects (like axis.x, axis.y, etc.) and
5
+ * allows partial theme overrides. Arrays (like itemStyles) are replaced entirely.
6
+ *
7
+ * @param theme1 - Base theme to merge from
8
+ * @param theme2 - Partial theme that will override/extend theme1
9
+ * @returns A new merged ChartTheme object
10
+ */
11
+ const mergeThemes = (theme1, theme2) => {
12
+ const result = { ...theme1 };
13
+ for (const key in theme2) {
14
+ if (theme2.hasOwnProperty(key)) {
15
+ const value2 = theme2[key];
16
+ const value1 = result[key];
17
+ if (value2 !== undefined) {
18
+ if (typeof value2 === 'object' && !Array.isArray(value2) && value2 !== null &&
19
+ typeof value1 === 'object' && !Array.isArray(value1) && value1 !== null) {
20
+ // Recursively merge nested objects
21
+ result[key] = mergeThemes(value1, value2);
22
+ }
23
+ else {
24
+ // Override with value from theme2
25
+ result[key] = value2;
26
+ }
27
+ }
28
+ }
29
+ }
30
+ return result;
31
+ };
32
+ /**
33
+ * Utility function to extend the default theme with custom overrides.
34
+ * Useful for creating theme variants without using the React context system.
35
+ *
36
+ * @param theme - Partial theme configuration to merge with defaults
37
+ * @returns A complete ChartTheme with defaults merged
38
+ */
39
+ export const extendChartTheme = (...themes) => {
40
+ return themes.filter(theme => theme !== undefined).reduce((acc, theme) => {
41
+ return acc ? mergeThemes(acc, theme) : theme;
42
+ }, LIGHT_THEME);
43
+ };
44
+ /**
45
+ * Default chart theme configuration.
46
+ * Provides sensible defaults for all chart styling elements.
47
+ * Uses a blue color palette for item styles that cycles through different shades.
48
+ */
49
+ export const LIGHT_THEME = {
50
+ axis: {
51
+ x: {
52
+ lineColor: '#AAAAAA',
53
+ lineWidth: 1,
54
+ labelColor: '#666666',
55
+ tickLabelColor: '#666666',
56
+ tickColor: '#DDDDDD',
57
+ tickWidth: 1,
58
+ splitLineColor: '#DDDDDD',
59
+ splitLineWidth: 1
60
+ },
61
+ y: {
62
+ lineColor: '#AAAAAA',
63
+ lineWidth: 1,
64
+ labelColor: '#666666',
65
+ tickLabelColor: '#666666',
66
+ tickColor: '#DDDDDD',
67
+ tickWidth: 1,
68
+ splitLineColor: '#DDDDDD',
69
+ splitLineWidth: 1
70
+ },
71
+ r: {
72
+ lineColor: '#DDDDDD',
73
+ lineWidth: 1,
74
+ labelColor: '#666666',
75
+ tickLabelColor: '#666666',
76
+ tickColor: '#DDDDDD',
77
+ tickWidth: 1,
78
+ splitLineColor: '#DDDDDD',
79
+ splitLineWidth: 1
80
+ }
81
+ },
82
+ grid: {
83
+ x: {
84
+ lineColor: '#AAAAAA',
85
+ lineWidth: 1
86
+ },
87
+ y: {
88
+ lineColor: '#AAAAAA',
89
+ lineWidth: 1
90
+ },
91
+ r: {
92
+ lineColor: '#EEEEEE',
93
+ lineWidth: 1,
94
+ }
95
+ },
96
+ tooltip: {
97
+ backgroundColor: '#FFFFFF',
98
+ labelColor: '#AAAAAA',
99
+ valueColor: '#000000',
100
+ borderColor: '#DDDDDD',
101
+ borderWidth: 1,
102
+ borderRadius: 5,
103
+ padding: 2,
104
+ },
105
+ series: [
106
+ {
107
+ color: '#8c62f2',
108
+ borderRadius: [4, 4, 4, 4],
109
+ lineWidth: 2,
110
+ },
111
+ {
112
+ color: '#4ad0e0',
113
+ borderRadius: [4, 4, 4, 4],
114
+ lineWidth: 2,
115
+ },
116
+ {
117
+ color: '#ffc635',
118
+ borderRadius: [4, 4, 4, 4],
119
+ lineWidth: 2,
120
+ },
121
+ {
122
+ color: '#ff5722',
123
+ borderRadius: [4, 4, 4, 4],
124
+ lineWidth: 2,
125
+ },
126
+ {
127
+ color: '#f44336',
128
+ borderRadius: [4, 4, 4, 4],
129
+ lineWidth: 2,
130
+ },
131
+ ],
132
+ legend: {
133
+ textColor: '#666666',
134
+ fontSize: 12,
135
+ backgroundColor: '#00000000',
136
+ },
137
+ };
138
+ export const DARK_THEME = extendChartTheme(LIGHT_THEME, {
139
+ axis: {
140
+ x: {
141
+ lineColor: '#FFFFFF',
142
+ labelColor: '#FFFFFF',
143
+ tickLabelColor: '#FFFFFF',
144
+ tickColor: '#FFFFFF',
145
+ splitLineColor: '#DDDDDD',
146
+ },
147
+ y: {
148
+ lineColor: '#FFFFFF',
149
+ labelColor: '#FFFFFF',
150
+ tickLabelColor: '#FFFFFF',
151
+ tickColor: '#FFFFFF',
152
+ splitLineColor: '#DDDDDD',
153
+ },
154
+ r: {
155
+ lineColor: '#FFFFFF',
156
+ labelColor: '#FFFFFF',
157
+ tickLabelColor: '#FFFFFF',
158
+ tickColor: '#FFFFFF',
159
+ splitLineColor: '#DDDDDD',
160
+ },
161
+ },
162
+ grid: {
163
+ x: {
164
+ lineColor: '#FFFFFF',
165
+ },
166
+ y: {
167
+ lineColor: '#FFFFFF',
168
+ },
169
+ r: {
170
+ lineColor: '#FFFFFF',
171
+ },
172
+ },
173
+ legend: {
174
+ textColor: '#FFFFFF',
175
+ backgroundColor: '#00000000',
176
+ },
177
+ tooltip: {
178
+ backgroundColor: '#151718',
179
+ labelColor: '#FFFFFF',
180
+ valueColor: '#FFFFFF',
181
+ borderColor: '#FFFFFF',
182
+ borderWidth: 1,
183
+ borderRadius: 5,
184
+ padding: 2,
185
+ },
186
+ });
187
+ /**
188
+ * React context for chart theming.
189
+ * Allows chart components to access the current theme configuration.
190
+ * Undefined when used outside of a ChartThemeProvider.
191
+ */
192
+ const ChartThemeContext = createContext(undefined);
193
+ /**
194
+ * Hook to access and optionally extend the chart theme.
195
+ * Merges the theme from context (if available) with any local theme overrides.
196
+ * The local theme parameter takes precedence over the context theme.
197
+ *
198
+ * @param theme - Optional partial theme to merge with the context theme
199
+ * @returns ChartThemeContextType with the merged theme
200
+ *
201
+ * @example
202
+ * ```tsx
203
+ * const { theme } = useChartTheme({ tooltip: { backgroundColor: '#000' } });
204
+ * ```
205
+ */
206
+ export const useChartTheme = (theme, colors) => {
207
+ const context = useContext(ChartThemeContext);
208
+ const prepareMergedThemeContext = useCallback(() => {
209
+ const mergedTheme = mergeThemes(context?.theme || LIGHT_THEME, theme || {});
210
+ return {
211
+ theme: mergedTheme
212
+ };
213
+ }, [context?.theme, theme]);
214
+ const [mergedThemeContext, setMergedThemeContext] = useState(prepareMergedThemeContext);
215
+ useEffect(() => {
216
+ setMergedThemeContext(prepareMergedThemeContext);
217
+ }, [theme, context?.theme]);
218
+ useEffect(() => {
219
+ if (colors) {
220
+ setMergedThemeContext({
221
+ theme: mergeThemes(mergedThemeContext.theme, { series: mergedThemeContext.theme.series
222
+ .map((item, index) => ({
223
+ ...item,
224
+ color: colors[index] || item.color
225
+ }))
226
+ })
227
+ });
228
+ }
229
+ }, [colors]);
230
+ return mergedThemeContext;
231
+ };
232
+ /**
233
+ * Provider component that supplies chart theme configuration to child components.
234
+ * Supports nested providers - child providers will merge their theme with the parent theme.
235
+ * The parent theme serves as the base, and the current provider's theme overrides it.
236
+ *
237
+ * @example
238
+ * ```tsx
239
+ * <ChartThemeProvider theme={{ tooltip: { backgroundColor: '#000' } }}>
240
+ * <MyChart />
241
+ * </ChartThemeProvider>
242
+ * ```
243
+ */
244
+ export const ChartThemeProvider = (props) => {
245
+ const context = useContext(ChartThemeContext);
246
+ const parentTheme = context?.theme || LIGHT_THEME;
247
+ const contextValue = useMemo(() => {
248
+ return {
249
+ theme: mergeThemes(parentTheme, props.theme || {})
250
+ };
251
+ }, [parentTheme, props.theme]);
252
+ return (<ChartThemeContext.Provider value={contextValue}>
253
+ {props.children}
254
+ </ChartThemeContext.Provider>);
255
+ };
256
+ /**
257
+ * Higher-order component (HOC) that wraps a component with ChartThemeProvider.
258
+ * Allows passing a theme prop directly to a component, which will be applied
259
+ * to that component and its children.
260
+ *
261
+ * @param Component - The component to wrap with theme provider
262
+ * @returns A new component that accepts an optional theme prop
263
+ *
264
+ * @example
265
+ * ```tsx
266
+ * const ThemedChart = withChartTheme(MyChart);
267
+ * <ThemedChart theme={{ tooltip: { backgroundColor: '#000' } }} />
268
+ * ```
269
+ */
270
+ export const withChartTheme = (Component) => {
271
+ return (props) => {
272
+ return (<ChartThemeProvider theme={props.theme}>
273
+ <Component {...props}/>
274
+ </ChartThemeProvider>);
275
+ };
276
+ };
@@ -0,0 +1,13 @@
1
+ import type { ColumnChartProps } from './column-chart.props';
2
+ import React from 'react';
3
+ /** common -> cartesian -> column */
4
+ export type { ColumnChartProps } from './column-chart.props';
5
+ export declare const ColumnChart: ((props: ColumnChartProps & {
6
+ theme?: Partial<import("..").ChartTheme>;
7
+ } & {
8
+ width?: number | string;
9
+ height?: number | string;
10
+ }) => React.JSX.Element) & {
11
+ displayName: string;
12
+ };
13
+ //# sourceMappingURL=column-chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/column/column-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAS7D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAI1D,oCAAoC;AACpC,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AA6jB7D,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}