Commit d6ff776
authored
Some performance improvement and introducing multi line xaxis ticks, for line, bar and area charts, (#145)
* performance improvement for barChart scroll button extracted
* performance improvement for line and are area chart
* perf(charts): Optimize chart rendering by memoizing Y-axis
This commit improves the rendering performance of the AreaChart, BarChart, and LineChart components by memoizing the Y-axis.
The Y-axis for these charts is now wrapped in a `useMemo` hook to prevent unnecessary re-renders when unrelated props change. This results in a smoother experience, particularly for charts that are interactive or update frequently.
Additionally, the `chartSyncID` has been removed as it is no longer required with the new implementation.
* function changes
* better colition detection and xtick
* bar xtik colition detection
* xAxis multi
* feat(charts): Add useMaxLabelHeight hook for dynamic label height calculation
This commit introduces a new hook, useMaxLabelHeight, which calculates the maximum height of labels in a chart based on the provided data and category key. The hook utilizes memoization for performance optimization and ensures accurate height measurement by creating temporary DOM elements. Additionally, it cleans up by removing unused code from useTransformKey.
* feat(charts): Add XAxisTicks type for chart tick variants
This commit introduces a new type, XAxisTickVariant, which defines the possible variants for X-axis ticks in charts. The type is exported from a new file, enhancing the type definitions available for chart components.
* feat(charts): Export useMaxLabelHeight hook in charts hooks index
This commit updates the charts hooks index file to export the useMaxLabelHeight hook, allowing for dynamic label height calculations to be utilized in other components.
* fix(ThemeProvider): Update default theme reference to use themes.light
This commit modifies the ThemeProvider component to reference themes.light instead of lightTheme for the default theme. This change ensures consistency with the updated theme structure.
* feat(charts): Enhance AreaChart and LineChart with dynamic label height and X-axis tick improvements
This commit introduces the useMaxLabelHeight hook in both AreaChart and LineChart components to dynamically calculate the maximum height of X-axis labels based on their content. The X-axis tick rendering has been updated to utilize this height for better spacing. Additionally, the XAxisTick component has been refactored to support different tick variants, improving the overall flexibility and appearance of the charts. Unused code related to X-axis position handling has been removed for cleaner implementation.
* refactor(charts): Update chart height calculations and improve X-axis tick rendering
This commit modifies the AreaChart and LineChart components to include the maximum label height in their height calculations, ensuring better spacing for dynamic content. The XAxisTick component has been updated to accept a customizable width for improved layout flexibility. Additionally, a new utility function, getCanvasContext, has been introduced to streamline font style application for canvas rendering, enhancing overall chart rendering accuracy.
* refactor(charts): Improve BarChart utility functions and label width handling
This commit refactors the BarChart utility functions by introducing the getCanvasContext utility for better font style management in X-axis tick rendering. It also updates the padding values for chart content and adjusts the label width handling in the useMaxLabelHeight hook to enhance layout consistency and visual spacing.
* refactor(charts): Update chart components for multiLine tick variant and width handling
This commit refactors the AreaChart, BarChart, and LineChart components to support a new "multiLine" tick variant for X-axis labels. It introduces the widthOfGroup calculation to improve label height management and adjusts the useMaxLabelHeight hook accordingly. The XAxisTick component is updated to accommodate the new variant and width properties, enhancing layout flexibility and visual consistency across charts.
* refactor(charts): Enhance BarChart story data structure for improved readability
This commit refactors the data structure in the BarChart stories to enhance readability by formatting the data entries with consistent indentation and spacing. This change improves the clarity of the data variations used in the stories, making it easier for developers to understand and modify the chart data.
* refactor(charts): Simplify XAxisTick usage in chart components
This commit refactors the AreaChart, BarChart, and LineChart components to streamline the usage of the XAxisTick component by removing the unnecessary chartVariant prop. The tick rendering is simplified for better readability and maintainability, enhancing the overall code structure across the chart components.
* refactor(charts): Remove unused getCanvasContext utility from XAxisTick component
This commit removes the unused getCanvasContext utility from the XAxisTick component, streamlining the code and improving maintainability. The change contributes to a cleaner implementation by eliminating unnecessary references, enhancing overall code clarity.
* refactor(charts): Update XAxisTick component to support customizable label height
This commit enhances the XAxisTick component by adding a new labelHeight prop, allowing for more flexible height management of X-axis ticks across AreaChart, BarChart, and LineChart components. The tick rendering in these charts has been updated to utilize this new prop, improving layout consistency and visual appearance.
* refactor(charts): Standardize X-axis padding in AreaChart and LineChart components
This commit introduces a new constant, X_AXIS_PADDING, to standardize the left and right padding for the X-axis in both AreaChart and LineChart components. This change enhances code maintainability and ensures consistent layout across chart components.
* rename yaxis chart to yaxis
* hide shell stories
* fix type1 parent 542b4a3 commit d6ff776
26 files changed
Lines changed: 662 additions & 503 deletions
File tree
- js/packages/react-ui/src/components
- Charts
- AreaChart
- BarChart
- stories
- utils
- LineChart
- hooks
- types
- utils
- AreaAndLine
- CopilotShell/stories
- CrayonChat/stories
- Shell/stories
- ThemeProvider
Lines changed: 77 additions & 91 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | | - | |
7 | 5 | | |
8 | 6 | | |
9 | | - | |
| 7 | + | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | | - | |
| 24 | + | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| |||
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
| |||
125 | 133 | | |
126 | 134 | | |
127 | 135 | | |
128 | | - | |
129 | | - | |
| 136 | + | |
| 137 | + | |
130 | 138 | | |
131 | 139 | | |
132 | 140 | | |
133 | 141 | | |
134 | 142 | | |
135 | 143 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
| |||
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
228 | | - | |
229 | | - | |
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| |||
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
249 | 295 | | |
250 | 296 | | |
251 | 297 | | |
| |||
260 | 306 | | |
261 | 307 | | |
262 | 308 | | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
| 309 | + | |
| 310 | + | |
303 | 311 | | |
304 | 312 | | |
305 | 313 | | |
| |||
317 | 325 | | |
318 | 326 | | |
319 | 327 | | |
320 | | - | |
321 | 328 | | |
322 | 329 | | |
323 | 330 | | |
| |||
328 | 335 | | |
329 | 336 | | |
330 | 337 | | |
| 338 | + | |
331 | 339 | | |
332 | 340 | | |
333 | | - | |
334 | | - | |
335 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
336 | 344 | | |
337 | 345 | | |
338 | 346 | | |
339 | 347 | | |
340 | | - | |
341 | | - | |
| 348 | + | |
| 349 | + | |
342 | 350 | | |
343 | 351 | | |
344 | 352 | | |
| |||
387 | 395 | | |
388 | 396 | | |
389 | 397 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
421 | 407 | | |
422 | 408 | | |
423 | 409 | | |
| |||
Lines changed: 0 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
0 commit comments