@shohojdhara/atomix 0.2.4 → 0.2.6
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/README.md +19 -0
- package/dist/atomix.css +1300 -1418
- package/dist/atomix.min.css +3 -3
- package/dist/index.d.ts +1259 -874
- package/dist/index.esm.js +16256 -26366
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +15691 -22295
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/themes/applemix.css +15036 -0
- package/dist/themes/applemix.min.css +72 -0
- package/dist/themes/boomdevs.css +1300 -1419
- package/dist/themes/boomdevs.min.css +3 -3
- package/dist/themes/esrar.css +1301 -1419
- package/dist/themes/esrar.min.css +3 -3
- package/dist/themes/flashtrade.css +15187 -0
- package/dist/themes/flashtrade.min.css +86 -0
- package/dist/themes/mashroom.css +1299 -1417
- package/dist/themes/mashroom.min.css +5 -5
- package/dist/themes/shaj-default.css +1300 -1418
- package/dist/themes/shaj-default.min.css +3 -3
- package/package.json +6 -17
- package/src/components/Accordion/Accordion.stories.tsx +4 -26
- package/src/components/Accordion/Accordion.tsx +21 -12
- package/src/components/AtomixGlass/AtomixGlass.test.tsx +106 -72
- package/src/components/AtomixGlass/AtomixGlass.tsx +485 -1215
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +399 -0
- package/src/components/AtomixGlass/GlassFilter.tsx +156 -0
- package/src/components/AtomixGlass/README.md +124 -2
- package/src/components/AtomixGlass/atomixGLass.old.tsx +1266 -0
- package/src/components/AtomixGlass/glass-utils.ts +263 -0
- package/src/components/AtomixGlass/shader-utils.ts +404 -236
- package/src/components/AtomixGlass/{AtomixGlass.stories.tsx → stories/AtomixGlass.stories.tsx} +55 -35
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +57 -89
- package/src/components/AtomixGlass/stories/Modes.stories.tsx +149 -149
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +95 -32
- package/src/components/AtomixGlass/stories/ShaderVariants.stories.tsx +0 -2
- package/src/components/AtomixGlass/stories/shared-components.tsx +9 -18
- package/src/components/AtomixGlass/utils.ts +3 -3
- package/src/components/Avatar/Avatar.tsx +3 -0
- package/src/components/Avatar/AvatarGroup.tsx +2 -1
- package/src/components/Badge/Badge.stories.tsx +74 -54
- package/src/components/Badge/Badge.tsx +8 -12
- package/src/components/Breadcrumb/Breadcrumb.tsx +23 -4
- package/src/components/Button/Button.tsx +3 -5
- package/src/components/Callout/Callout.stories.tsx +86 -35
- package/src/components/Callout/Callout.tsx +4 -0
- package/src/components/Card/Card.stories.tsx +89 -85
- package/src/components/Card/Card.tsx +15 -4
- package/src/components/Card/ElevationCard.tsx +2 -0
- package/src/components/Chart/AnimatedChart.tsx +179 -156
- package/src/components/Chart/AreaChart.tsx +123 -12
- package/src/components/Chart/BarChart.tsx +91 -100
- package/src/components/Chart/BaseChart.tsx +80 -0
- package/src/components/Chart/BubbleChart.tsx +114 -290
- package/src/components/Chart/CandlestickChart.tsx +282 -622
- package/src/components/Chart/Chart.stories.tsx +576 -179
- package/src/components/Chart/Chart.tsx +374 -75
- package/src/components/Chart/ChartRenderer.tsx +371 -220
- package/src/components/Chart/ChartToolbar.tsx +372 -61
- package/src/components/Chart/ChartTooltip.tsx +33 -18
- package/src/components/Chart/DonutChart.tsx +172 -254
- package/src/components/Chart/FunnelChart.tsx +169 -240
- package/src/components/Chart/GaugeChart.tsx +224 -392
- package/src/components/Chart/HeatmapChart.tsx +302 -440
- package/src/components/Chart/LineChart.tsx +148 -103
- package/src/components/Chart/MultiAxisChart.tsx +267 -395
- package/src/components/Chart/PieChart.tsx +114 -64
- package/src/components/Chart/RadarChart.tsx +202 -218
- package/src/components/Chart/ScatterChart.tsx +111 -97
- package/src/components/Chart/TreemapChart.tsx +147 -222
- package/src/components/Chart/WaterfallChart.tsx +253 -291
- package/src/components/Chart/index.ts +11 -9
- package/src/components/Chart/types.ts +85 -9
- package/src/components/Chart/utils.ts +66 -0
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +121 -11
- package/src/components/ColorModeToggle/ColorModeToggle.tsx +149 -45
- package/src/components/ColorModeToggle/index.ts +1 -1
- package/src/components/Countdown/Countdown.tsx +4 -0
- package/src/components/DataTable/DataTable.tsx +2 -1
- package/src/components/DatePicker/DatePicker.stories.tsx +0 -11
- package/src/components/DatePicker/DatePicker.tsx +3 -9
- package/src/components/DatePicker/types.ts +5 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +32 -25
- package/src/components/Dropdown/Dropdown.tsx +26 -28
- package/src/components/EdgePanel/EdgePanel.stories.tsx +13 -15
- package/src/components/EdgePanel/EdgePanel.tsx +20 -5
- package/src/components/Footer/Footer.stories.tsx +187 -60
- package/src/components/Footer/Footer.test.tsx +134 -0
- package/src/components/Footer/Footer.tsx +133 -34
- package/src/components/Footer/FooterLink.tsx +1 -1
- package/src/components/Footer/FooterSection.tsx +53 -36
- package/src/components/Footer/FooterSocialLink.tsx +32 -29
- package/src/components/Footer/README.md +82 -3
- package/src/components/Footer/index.ts +1 -1
- package/src/components/Form/Checkbox.stories.tsx +13 -5
- package/src/components/Form/Checkbox.tsx +3 -6
- package/src/components/Form/Form.stories.tsx +10 -3
- package/src/components/Form/Form.tsx +2 -0
- package/src/components/Form/FormGroup.tsx +2 -1
- package/src/components/Form/Input.stories.tsx +12 -11
- package/src/components/Form/Input.tsx +97 -95
- package/src/components/Form/Radio.stories.tsx +22 -7
- package/src/components/Form/Radio.tsx +3 -6
- package/src/components/Form/Select.stories.tsx +21 -6
- package/src/components/Form/Select.tsx +3 -5
- package/src/components/Form/Textarea.stories.tsx +13 -11
- package/src/components/Form/Textarea.tsx +88 -86
- package/src/components/Hero/Hero.stories.tsx +2 -3
- package/src/components/Hero/Hero.tsx +5 -6
- package/src/components/Icon/Icon.tsx +12 -1
- package/src/components/List/List.tsx +2 -1
- package/src/components/List/ListGroup.tsx +2 -1
- package/src/components/Messages/Messages.tsx +3 -2
- package/src/components/Modal/Modal.stories.tsx +48 -34
- package/src/components/Modal/Modal.tsx +19 -23
- package/src/components/Navigation/Menu/MegaMenu.tsx +2 -2
- package/src/components/Navigation/Menu/Menu.tsx +2 -2
- package/src/components/Navigation/Nav/Nav.tsx +6 -1
- package/src/components/Navigation/Nav/NavDropdown.tsx +10 -1
- package/src/components/Navigation/Navbar/Navbar.tsx +4 -1
- package/src/components/Navigation/SideMenu/SideMenu.tsx +3 -2
- package/src/components/Pagination/Pagination.stories.tsx +13 -6
- package/src/components/Pagination/Pagination.tsx +7 -6
- package/src/components/PhotoViewer/PhotoViewer.tsx +2 -1
- package/src/components/Popover/Popover.stories.tsx +32 -24
- package/src/components/Popover/Popover.tsx +4 -1
- package/src/components/ProductReview/ProductReview.tsx +8 -2
- package/src/components/Progress/Progress.tsx +2 -1
- package/src/components/Rating/Rating.stories.tsx +11 -6
- package/src/components/Rating/Rating.tsx +3 -5
- package/src/components/River/River.tsx +5 -5
- package/src/components/SectionIntro/SectionIntro.tsx +8 -2
- package/src/components/Slider/Slider.stories.tsx +4 -4
- package/src/components/Slider/Slider.tsx +4 -3
- package/src/components/Spinner/Spinner.tsx +2 -1
- package/src/components/Steps/Steps.stories.tsx +5 -4
- package/src/components/Steps/Steps.tsx +8 -5
- package/src/components/Tab/Tab.stories.tsx +4 -3
- package/src/components/Tab/Tab.tsx +8 -6
- package/src/components/Testimonial/Testimonial.tsx +8 -2
- package/src/components/Todo/Todo.tsx +2 -1
- package/src/components/Toggle/Toggle.stories.tsx +5 -4
- package/src/components/Toggle/Toggle.tsx +8 -5
- package/src/components/Tooltip/Tooltip.stories.tsx +40 -30
- package/src/components/Tooltip/Tooltip.tsx +9 -2
- package/src/components/Upload/Upload.stories.tsx +252 -0
- package/src/components/Upload/Upload.tsx +92 -53
- package/src/components/VideoPlayer/VideoPlayer.tsx +3 -1
- package/src/components/index.ts +0 -4
- package/src/layouts/Grid/Grid.stories.tsx +10 -23
- package/src/layouts/Grid/Grid.tsx +20 -1
- package/src/layouts/Grid/GridCol.tsx +76 -48
- package/src/lib/composables/useAtomixGlass.ts +861 -44
- package/src/lib/composables/useBarChart.ts +13 -6
- package/src/lib/composables/useChart.ts +17 -13
- package/src/lib/composables/useChartExport.ts +19 -78
- package/src/lib/composables/useChartToolbar.ts +0 -1
- package/src/lib/composables/useEdgePanel.ts +111 -103
- package/src/lib/composables/useFooter.ts +3 -3
- package/src/lib/composables/useGlassContainer.ts +16 -7
- package/src/lib/composables/useLineChart.ts +8 -1
- package/src/lib/composables/useRiver.ts +5 -0
- package/src/lib/composables/useSlider.ts +62 -24
- package/src/lib/composables/useVideoPlayer.ts +60 -63
- package/src/lib/constants/components.ts +146 -32
- package/src/lib/types/components.ts +258 -10
- package/src/lib/utils/displacement-generator.ts +55 -49
- package/src/lib/utils/icons.ts +1 -1
- package/src/lib/utils/index.ts +16 -10
- package/src/styles/01-settings/_settings.accordion.scss +19 -19
- package/src/styles/01-settings/_settings.animations.scss +5 -5
- package/src/styles/01-settings/_settings.avatar-group.scss +1 -1
- package/src/styles/01-settings/_settings.avatar.scss +17 -17
- package/src/styles/01-settings/_settings.background.scss +1 -4
- package/src/styles/01-settings/_settings.badge.scss +1 -1
- package/src/styles/01-settings/_settings.breadcrumb.scss +1 -1
- package/src/styles/01-settings/_settings.card.scss +1 -1
- package/src/styles/01-settings/_settings.chart.scss +65 -2
- package/src/styles/01-settings/_settings.dropdown.scss +1 -1
- package/src/styles/01-settings/_settings.footer.scss +35 -42
- package/src/styles/01-settings/_settings.input.scss +1 -1
- package/src/styles/01-settings/_settings.list.scss +1 -1
- package/src/styles/01-settings/_settings.rating.scss +1 -1
- package/src/styles/01-settings/_settings.tabs.scss +1 -1
- package/src/styles/01-settings/_settings.upload.scss +6 -5
- package/src/styles/02-tools/_tools.animations.scss +4 -5
- package/src/styles/02-tools/_tools.background.scss +1 -13
- package/src/styles/02-tools/_tools.glass.scss +0 -1
- package/src/styles/02-tools/_tools.utility-api.scss +42 -34
- package/src/styles/03-generic/_generic.root.scss +1 -4
- package/src/styles/04-elements/_elements.body.scss +0 -1
- package/src/styles/06-components/_components.atomix-glass.scss +217 -39
- package/src/styles/06-components/_components.badge.scss +6 -8
- package/src/styles/06-components/_components.button.scss +8 -3
- package/src/styles/06-components/_components.card.scss +2 -14
- package/src/styles/06-components/_components.chart.scss +969 -1449
- package/src/styles/06-components/_components.color-mode-toggle.scss +43 -6
- package/src/styles/06-components/_components.dropdown.scss +19 -7
- package/src/styles/06-components/_components.edge-panel.scss +4 -2
- package/src/styles/06-components/_components.footer.scss +166 -85
- package/src/styles/06-components/_components.input.scss +8 -9
- package/src/styles/06-components/_components.list.scss +1 -0
- package/src/styles/06-components/_components.modal.scss +5 -3
- package/src/styles/06-components/_components.skeleton.scss +8 -6
- package/src/styles/06-components/_components.upload.scss +219 -4
- package/src/styles/06-components/old.chart.styles.scss +1 -30
- package/src/styles/99-utilities/_utilities.opacity.scss +1 -1
- package/src/styles/99-utilities/_utilities.scss +1 -1
- package/src/components/Chart/AdvancedChart.tsx +0 -624
- package/src/components/Chart/LineChartNew.tsx +0 -167
- package/src/components/Chart/RealTimeChart.tsx +0 -436
- package/src/components/DatePicker/DatePicker copy.tsx +0 -551
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { forwardRef, memo, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import BaseChart from './BaseChart';
|
|
2
3
|
import { ChartProps } from '../../lib/types/components';
|
|
3
|
-
import
|
|
4
|
+
import { ChartRenderContentParams } from './types';
|
|
4
5
|
|
|
5
6
|
interface TreemapDataPoint {
|
|
6
7
|
id: string;
|
|
@@ -51,27 +52,21 @@ interface TreemapChartProps extends Omit<ChartProps, 'type' | 'datasets'> {
|
|
|
51
52
|
*/
|
|
52
53
|
palette?: string[];
|
|
53
54
|
/**
|
|
54
|
-
*
|
|
55
|
+
* Whether to use gradients
|
|
55
56
|
*/
|
|
56
|
-
|
|
57
|
+
useGradients?: boolean;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
|
-
/**
|
|
60
|
-
* Whether to show labels
|
|
61
|
-
*/
|
|
62
|
-
showLabels?: boolean;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Whether to show values
|
|
66
|
-
*/
|
|
67
|
-
showValues?: boolean;
|
|
68
|
-
|
|
69
60
|
/**
|
|
70
61
|
* Label configuration
|
|
71
62
|
*/
|
|
72
63
|
labelConfig?: {
|
|
73
64
|
/**
|
|
74
|
-
*
|
|
65
|
+
* Whether to show labels
|
|
66
|
+
*/
|
|
67
|
+
showLabels?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Minimum size for showing labels
|
|
75
70
|
*/
|
|
76
71
|
minSize?: number;
|
|
77
72
|
/**
|
|
@@ -81,50 +76,26 @@ interface TreemapChartProps extends Omit<ChartProps, 'type' | 'datasets'> {
|
|
|
81
76
|
/**
|
|
82
77
|
* Text color
|
|
83
78
|
*/
|
|
84
|
-
|
|
79
|
+
textColor?: string;
|
|
85
80
|
};
|
|
86
81
|
|
|
87
82
|
/**
|
|
88
|
-
*
|
|
83
|
+
* Interaction configuration
|
|
89
84
|
*/
|
|
90
|
-
|
|
85
|
+
interactionConfig?: {
|
|
91
86
|
/**
|
|
92
|
-
*
|
|
87
|
+
* Whether to enable tooltips
|
|
93
88
|
*/
|
|
94
|
-
|
|
89
|
+
enableTooltips?: boolean;
|
|
95
90
|
/**
|
|
96
|
-
*
|
|
91
|
+
* Whether to enable zoom
|
|
97
92
|
*/
|
|
98
|
-
|
|
93
|
+
enableZoom?: boolean;
|
|
99
94
|
/**
|
|
100
|
-
*
|
|
95
|
+
* Whether to enable selection
|
|
101
96
|
*/
|
|
102
|
-
|
|
97
|
+
enableSelection?: boolean;
|
|
103
98
|
};
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Animation configuration
|
|
107
|
-
*/
|
|
108
|
-
animationConfig?: {
|
|
109
|
-
/**
|
|
110
|
-
* Enable animations
|
|
111
|
-
*/
|
|
112
|
-
enabled?: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Animation duration
|
|
115
|
-
*/
|
|
116
|
-
duration?: number;
|
|
117
|
-
/**
|
|
118
|
-
* Animation easing
|
|
119
|
-
*/
|
|
120
|
-
easing?: string;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Interaction handlers
|
|
125
|
-
*/
|
|
126
|
-
onNodeClick?: (node: TreemapNode) => void;
|
|
127
|
-
onNodeHover?: (node: TreemapNode | null) => void;
|
|
128
99
|
}
|
|
129
100
|
|
|
130
101
|
const TreemapChart = memo(
|
|
@@ -134,25 +105,13 @@ const TreemapChart = memo(
|
|
|
134
105
|
data = [],
|
|
135
106
|
algorithm = 'squarified',
|
|
136
107
|
colorConfig = { scheme: 'category' },
|
|
137
|
-
showLabels = true,
|
|
138
|
-
showValues = false,
|
|
139
108
|
labelConfig = {
|
|
109
|
+
showLabels: true,
|
|
140
110
|
minSize: 1000,
|
|
141
111
|
fontSize: 12,
|
|
142
|
-
|
|
112
|
+
textColor: 'white',
|
|
143
113
|
},
|
|
144
|
-
|
|
145
|
-
width: 1,
|
|
146
|
-
color: 'white',
|
|
147
|
-
radius: 2,
|
|
148
|
-
},
|
|
149
|
-
animationConfig = {
|
|
150
|
-
enabled: true,
|
|
151
|
-
duration: 750,
|
|
152
|
-
easing: 'ease-out',
|
|
153
|
-
},
|
|
154
|
-
onNodeClick,
|
|
155
|
-
onNodeHover,
|
|
114
|
+
onDataPointClick,
|
|
156
115
|
config = {},
|
|
157
116
|
...props
|
|
158
117
|
},
|
|
@@ -162,7 +121,6 @@ const TreemapChart = memo(
|
|
|
162
121
|
const [selectedNode, setSelectedNode] = useState<TreemapNode | null>(null);
|
|
163
122
|
const [tooltipPosition, setTooltipPosition] = useState({ x: 0, y: 0 });
|
|
164
123
|
|
|
165
|
-
// Build hierarchical tree structure
|
|
166
124
|
const treeData = useMemo(() => {
|
|
167
125
|
console.log('TreemapChart data:', data);
|
|
168
126
|
if (!data.length) {
|
|
@@ -219,19 +177,19 @@ const TreemapChart = memo(
|
|
|
219
177
|
(node: TreemapDataPoint, depth: number, index: number) => {
|
|
220
178
|
if (node.color) return node.color;
|
|
221
179
|
|
|
222
|
-
const { scheme, palette
|
|
180
|
+
const { scheme, palette } = colorConfig;
|
|
223
181
|
|
|
224
182
|
const defaultPalette = [
|
|
225
|
-
'
|
|
226
|
-
'
|
|
227
|
-
'
|
|
228
|
-
'
|
|
229
|
-
'
|
|
230
|
-
'
|
|
231
|
-
'
|
|
232
|
-
'
|
|
233
|
-
'
|
|
234
|
-
'
|
|
183
|
+
'var(--atomix-primary)',
|
|
184
|
+
'var(--atomix-error)',
|
|
185
|
+
'var(--atomix-success)',
|
|
186
|
+
'var(--atomix-warning)',
|
|
187
|
+
'var(--atomix-primary-5)',
|
|
188
|
+
'var(--atomix-info)',
|
|
189
|
+
'var(--atomix-success-5)',
|
|
190
|
+
'var(--atomix-warning-7)',
|
|
191
|
+
'var(--atomix-primary-3)',
|
|
192
|
+
'var(--atomix-primary-7)',
|
|
235
193
|
];
|
|
236
194
|
|
|
237
195
|
const colors = palette || defaultPalette;
|
|
@@ -240,14 +198,19 @@ const TreemapChart = memo(
|
|
|
240
198
|
case 'category':
|
|
241
199
|
return colors[index % colors.length];
|
|
242
200
|
case 'depth':
|
|
243
|
-
const depthColors = [
|
|
201
|
+
const depthColors = [
|
|
202
|
+
'var(--atomix-blue-9)',
|
|
203
|
+
'var(--atomix-blue-6)',
|
|
204
|
+
'var(--atomix-blue-5)',
|
|
205
|
+
'var(--atomix-blue-4)',
|
|
206
|
+
'var(--atomix-blue-2)',
|
|
207
|
+
];
|
|
244
208
|
return depthColors[Math.min(depth, depthColors.length - 1)];
|
|
245
209
|
case 'value':
|
|
246
|
-
if (
|
|
210
|
+
if (data.length > 0) {
|
|
247
211
|
const maxValue = Math.max(...data.map(d => d.value));
|
|
248
212
|
const minValue = Math.min(...data.map(d => d.value));
|
|
249
213
|
const ratio = (node.value - minValue) / (maxValue - minValue);
|
|
250
|
-
// Simple interpolation between two colors
|
|
251
214
|
return `hsl(${220 + ratio * 100}, 70%, ${30 + ratio * 40}%)`;
|
|
252
215
|
}
|
|
253
216
|
return colors[0];
|
|
@@ -255,7 +218,7 @@ const TreemapChart = memo(
|
|
|
255
218
|
return colors[index % colors.length];
|
|
256
219
|
}
|
|
257
220
|
},
|
|
258
|
-
[colorConfig, data
|
|
221
|
+
[colorConfig, data]
|
|
259
222
|
);
|
|
260
223
|
|
|
261
224
|
// Squarified treemap algorithm
|
|
@@ -393,177 +356,139 @@ const TreemapChart = memo(
|
|
|
393
356
|
[]
|
|
394
357
|
);
|
|
395
358
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
359
|
+
const renderContent = ({
|
|
360
|
+
scales,
|
|
361
|
+
colors,
|
|
362
|
+
datasets: renderedDatasets,
|
|
363
|
+
handlers,
|
|
364
|
+
hoveredPoint,
|
|
365
|
+
}: ChartRenderContentParams) => {
|
|
366
|
+
if (!data.length) return null;
|
|
367
|
+
|
|
368
|
+
// Calculate available space with padding
|
|
369
|
+
const padding = 20;
|
|
370
|
+
const availableWidth = scales.width - padding * 2;
|
|
371
|
+
const availableHeight = scales.height - padding * 2;
|
|
372
|
+
const startX = padding;
|
|
373
|
+
const startY = padding;
|
|
374
|
+
|
|
375
|
+
// Get leaf nodes for treemap layout
|
|
401
376
|
const leafNodes = data.filter(item => !item.children || item.children.length === 0);
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
let currentX = 0;
|
|
405
|
-
let currentY = 0;
|
|
406
|
-
const nodeWidth = 800 / Math.ceil(Math.sqrt(leafNodes.length));
|
|
407
|
-
const nodeHeight = 600 / Math.ceil(Math.sqrt(leafNodes.length));
|
|
408
|
-
|
|
409
|
-
return leafNodes.map((item, index) => {
|
|
410
|
-
const node: TreemapNode = {
|
|
411
|
-
id: item.id,
|
|
412
|
-
label: item.label,
|
|
413
|
-
value: item.value,
|
|
414
|
-
color: generateColor(item, 0, index) || 'transparent',
|
|
415
|
-
x: currentX,
|
|
416
|
-
y: currentY,
|
|
417
|
-
width: nodeWidth,
|
|
418
|
-
height: nodeHeight,
|
|
419
|
-
depth: 0,
|
|
420
|
-
children: [],
|
|
421
|
-
originalData: item,
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
currentX += nodeWidth;
|
|
425
|
-
if (currentX >= 800) {
|
|
426
|
-
currentX = 0;
|
|
427
|
-
currentY += nodeHeight;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
return node;
|
|
431
|
-
});
|
|
432
|
-
}, [data, generateColor]);
|
|
433
|
-
|
|
434
|
-
// Handle node interactions
|
|
435
|
-
const handleNodeClick = useCallback(
|
|
436
|
-
(node: TreemapNode) => {
|
|
437
|
-
setSelectedNode(node);
|
|
438
|
-
onNodeClick?.(node);
|
|
439
|
-
},
|
|
440
|
-
[onNodeClick]
|
|
441
|
-
);
|
|
377
|
+
if (!leafNodes.length) return null;
|
|
442
378
|
|
|
443
|
-
|
|
444
|
-
(node: TreemapNode | null, event?: React.MouseEvent) => {
|
|
445
|
-
setHoveredNode(node);
|
|
446
|
-
onNodeHover?.(node);
|
|
447
|
-
|
|
448
|
-
if (event && node) {
|
|
449
|
-
const rect = event.currentTarget.getBoundingClientRect();
|
|
450
|
-
setTooltipPosition({
|
|
451
|
-
x: event.clientX,
|
|
452
|
-
y: event.clientY,
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
},
|
|
456
|
-
[onNodeHover]
|
|
457
|
-
);
|
|
379
|
+
const totalValue = leafNodes.reduce((sum, node) => sum + node.value, 0);
|
|
458
380
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
381
|
+
// Create treemap nodes with proper dimensions
|
|
382
|
+
const treemapNodes: TreemapNode[] = leafNodes.map((item, index) => ({
|
|
383
|
+
id: item.id,
|
|
384
|
+
label: item.label,
|
|
385
|
+
value: item.value,
|
|
386
|
+
color: generateColor(item, 0, index) || 'transparent',
|
|
387
|
+
x: 0, // Will be calculated by squarify
|
|
388
|
+
y: 0, // Will be calculated by squarify
|
|
389
|
+
width: 0, // Will be calculated by squarify
|
|
390
|
+
height: 0, // Will be calculated by squarify
|
|
391
|
+
depth: 0,
|
|
392
|
+
children: [],
|
|
393
|
+
originalData: item,
|
|
394
|
+
}));
|
|
395
|
+
|
|
396
|
+
// Apply squarified algorithm to layout nodes proportionally by value
|
|
397
|
+
if (algorithm === 'squarified' && totalValue > 0) {
|
|
398
|
+
squarify(treemapNodes, startX, startY, availableWidth, availableHeight);
|
|
399
|
+
} else {
|
|
400
|
+
// Fallback: simple grid layout (equal sizes)
|
|
401
|
+
const cols = Math.ceil(Math.sqrt(leafNodes.length));
|
|
402
|
+
const rows = Math.ceil(leafNodes.length / cols);
|
|
403
|
+
const nodeWidth = availableWidth / cols;
|
|
404
|
+
const nodeHeight = availableHeight / rows;
|
|
405
|
+
|
|
406
|
+
treemapNodes.forEach((node, index) => {
|
|
407
|
+
const col = index % cols;
|
|
408
|
+
const row = Math.floor(index / cols);
|
|
409
|
+
node.x = startX + col * nodeWidth;
|
|
410
|
+
node.y = startY + row * nodeHeight;
|
|
411
|
+
node.width = nodeWidth;
|
|
412
|
+
node.height = nodeHeight;
|
|
413
|
+
});
|
|
414
|
+
}
|
|
462
415
|
|
|
463
416
|
return (
|
|
464
|
-
|
|
417
|
+
<>
|
|
465
418
|
{treemapNodes.map(node => {
|
|
466
419
|
const isHovered = hoveredNode === node;
|
|
467
420
|
const isSelected = selectedNode === node;
|
|
468
421
|
const area = node.width * node.height;
|
|
469
|
-
const showLabel = showLabels && area >= (labelConfig.minSize || 1000);
|
|
422
|
+
const showLabel = labelConfig.showLabels && area >= (labelConfig.minSize || 1000);
|
|
470
423
|
|
|
471
424
|
return (
|
|
472
425
|
<g key={node.id}>
|
|
473
|
-
{/* Node rectangle */}
|
|
474
426
|
<rect
|
|
475
427
|
x={node.x}
|
|
476
428
|
y={node.y}
|
|
477
429
|
width={node.width}
|
|
478
430
|
height={node.height}
|
|
479
431
|
fill={node.color}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
432
|
+
className={`c-chart__treemap-node ${isHovered ? 'c-chart__treemap-node--hovered' : ''} ${isSelected ? 'c-chart__treemap-node--selected' : ''}`}
|
|
433
|
+
onClick={() => {
|
|
434
|
+
setSelectedNode(node);
|
|
435
|
+
handlers.onDataPointClick?.(node.originalData, 0, 0);
|
|
436
|
+
}}
|
|
437
|
+
onMouseEnter={e => {
|
|
438
|
+
setHoveredNode(node);
|
|
439
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
440
|
+
handlers.onPointHover(
|
|
441
|
+
0,
|
|
442
|
+
0,
|
|
443
|
+
node.x,
|
|
444
|
+
node.y,
|
|
445
|
+
rect.left + rect.width / 2,
|
|
446
|
+
rect.top + rect.height / 2
|
|
447
|
+
);
|
|
448
|
+
}}
|
|
449
|
+
onMouseLeave={() => {
|
|
450
|
+
setHoveredNode(null);
|
|
451
|
+
handlers.onPointLeave();
|
|
452
|
+
}}
|
|
485
453
|
/>
|
|
486
|
-
|
|
487
|
-
{/* Node label */}
|
|
488
454
|
{showLabel && (
|
|
489
|
-
<
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
{showValues && (
|
|
501
|
-
<text
|
|
502
|
-
x={node.x + node.width / 2}
|
|
503
|
-
y={node.y + node.height / 2 + 12}
|
|
504
|
-
textAnchor="middle"
|
|
505
|
-
dominantBaseline="middle"
|
|
506
|
-
className="c-chart__treemap-value"
|
|
507
|
-
>
|
|
508
|
-
{node.value.toLocaleString()}
|
|
509
|
-
</text>
|
|
510
|
-
)}
|
|
511
|
-
</g>
|
|
455
|
+
<text
|
|
456
|
+
x={node.x + node.width / 2}
|
|
457
|
+
y={node.y + node.height / 2}
|
|
458
|
+
textAnchor="middle"
|
|
459
|
+
dominantBaseline="middle"
|
|
460
|
+
className="c-chart__treemap-label"
|
|
461
|
+
style={{ fontSize: labelConfig.fontSize, fill: labelConfig.textColor }}
|
|
462
|
+
>
|
|
463
|
+
{node.label}
|
|
464
|
+
</text>
|
|
512
465
|
)}
|
|
513
466
|
</g>
|
|
514
467
|
);
|
|
515
468
|
})}
|
|
516
|
-
|
|
469
|
+
</>
|
|
517
470
|
);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
handleNodeHover,
|
|
528
|
-
handleNodeClick,
|
|
529
|
-
]);
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
// Convert data to datasets format for BaseChart
|
|
474
|
+
const datasets = [
|
|
475
|
+
{
|
|
476
|
+
label: 'Treemap Data',
|
|
477
|
+
data: data,
|
|
478
|
+
},
|
|
479
|
+
];
|
|
530
480
|
|
|
531
481
|
return (
|
|
532
|
-
<
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
{hoveredNode && (
|
|
543
|
-
<div
|
|
544
|
-
className="c-chart__tooltip"
|
|
545
|
-
style={{
|
|
546
|
-
position: 'fixed',
|
|
547
|
-
left: tooltipPosition.x + 10,
|
|
548
|
-
top: tooltipPosition.y - 10,
|
|
549
|
-
transform: 'translateY(-100%)',
|
|
550
|
-
background: 'var(--atomix-gray-9)',
|
|
551
|
-
color: 'white',
|
|
552
|
-
padding: '8px 12px',
|
|
553
|
-
borderRadius: '6px',
|
|
554
|
-
fontSize: '12px',
|
|
555
|
-
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.2)',
|
|
556
|
-
zIndex: 1000,
|
|
557
|
-
pointerEvents: 'none',
|
|
558
|
-
}}
|
|
559
|
-
>
|
|
560
|
-
<div>
|
|
561
|
-
<strong>{hoveredNode?.label}</strong>
|
|
562
|
-
</div>
|
|
563
|
-
<div>Value: {hoveredNode?.value.toLocaleString()}</div>
|
|
564
|
-
</div>
|
|
565
|
-
)}
|
|
566
|
-
</Chart>
|
|
482
|
+
<BaseChart
|
|
483
|
+
ref={ref}
|
|
484
|
+
type="treemap"
|
|
485
|
+
datasets={datasets}
|
|
486
|
+
config={config}
|
|
487
|
+
renderContent={renderContent}
|
|
488
|
+
onDataPointClick={onDataPointClick}
|
|
489
|
+
interactive={true}
|
|
490
|
+
{...props}
|
|
491
|
+
/>
|
|
567
492
|
);
|
|
568
493
|
}
|
|
569
494
|
)
|