@@ -292,6 +292,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
292
292
/>
293
293
) : null }
294
294
{ categories . map ( ( category ) => {
295
+ const gradientId = ( categoryColors . get ( category ) ?? BaseColors . Gray ) . replace ( "#" , "" ) ;
295
296
return (
296
297
< defs key = { category } >
297
298
{ showGradient ? (
@@ -302,7 +303,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
302
303
colorPalette . text ,
303
304
) . textColor
304
305
}
305
- id = { categoryColors . get ( category ) }
306
+ id = { gradientId }
306
307
x1 = "0"
307
308
y1 = "0"
308
309
x2 = "0"
@@ -325,7 +326,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
325
326
colorPalette . text ,
326
327
) . textColor
327
328
}
328
- id = { categoryColors . get ( category ) }
329
+ id = { gradientId }
329
330
x1 = "0"
330
331
y1 = "0"
331
332
x2 = "0"
@@ -342,68 +343,22 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
342
343
</ defs >
343
344
) ;
344
345
} ) }
345
- { categories . map ( ( category ) => (
346
- < Area
347
- className = {
348
- getColorClassNames (
349
- categoryColors . get ( category ) ?? BaseColors . Gray ,
350
- colorPalette . text ,
351
- ) . strokeColor
352
- }
353
- strokeOpacity = { activeDot || ( activeLegend && activeLegend !== category ) ? 0.3 : 1 }
354
- activeDot = { ( props : any ) => {
355
- const { cx, cy, stroke, strokeLinecap, strokeLinejoin, strokeWidth, dataKey } =
356
- props ;
357
- return (
358
- < Dot
359
- className = { tremorTwMerge (
360
- "stroke-tremor-background dark:stroke-dark-tremor-background" ,
361
- onValueChange ? "cursor-pointer" : "" ,
362
- getColorClassNames (
363
- categoryColors . get ( dataKey ) ?? BaseColors . Gray ,
364
- colorPalette . text ,
365
- ) . fillColor ,
366
- ) }
367
- cx = { cx }
368
- cy = { cy }
369
- r = { 5 }
370
- fill = ""
371
- stroke = { stroke }
372
- strokeLinecap = { strokeLinecap }
373
- strokeLinejoin = { strokeLinejoin }
374
- strokeWidth = { strokeWidth }
375
- onClick = { ( dotProps : any , event ) => onDotClick ( props , event ) }
376
- />
377
- ) ;
378
- } }
379
- dot = { ( props : any ) => {
380
- const {
381
- stroke,
382
- strokeLinecap,
383
- strokeLinejoin,
384
- strokeWidth,
385
- cx,
386
- cy,
387
- dataKey,
388
- index,
389
- } = props ;
390
-
391
- if (
392
- ( hasOnlyOneValueForThisKey ( data , category ) &&
393
- ! ( activeDot || ( activeLegend && activeLegend !== category ) ) ) ||
394
- ( activeDot ?. index === index && activeDot ?. dataKey === category )
395
- ) {
346
+ { categories . map ( ( category ) => {
347
+ const gradientId = ( categoryColors . get ( category ) ?? BaseColors . Gray ) . replace ( "#" , "" ) ;
348
+ return (
349
+ < Area
350
+ className = {
351
+ getColorClassNames (
352
+ categoryColors . get ( category ) ?? BaseColors . Gray ,
353
+ colorPalette . text ,
354
+ ) . strokeColor
355
+ }
356
+ strokeOpacity = { activeDot || ( activeLegend && activeLegend !== category ) ? 0.3 : 1 }
357
+ activeDot = { ( props : any ) => {
358
+ const { cx, cy, stroke, strokeLinecap, strokeLinejoin, strokeWidth, dataKey } =
359
+ props ;
396
360
return (
397
361
< Dot
398
- key = { index }
399
- cx = { cx }
400
- cy = { cy }
401
- r = { 5 }
402
- stroke = { stroke }
403
- fill = ""
404
- strokeLinecap = { strokeLinecap }
405
- strokeLinejoin = { strokeLinejoin }
406
- strokeWidth = { strokeWidth }
407
362
className = { tremorTwMerge (
408
363
"stroke-tremor-background dark:stroke-dark-tremor-background" ,
409
364
onValueChange ? "cursor-pointer" : "" ,
@@ -412,26 +367,75 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
412
367
colorPalette . text ,
413
368
) . fillColor ,
414
369
) }
370
+ cx = { cx }
371
+ cy = { cy }
372
+ r = { 5 }
373
+ fill = ""
374
+ stroke = { stroke }
375
+ strokeLinecap = { strokeLinecap }
376
+ strokeLinejoin = { strokeLinejoin }
377
+ strokeWidth = { strokeWidth }
378
+ onClick = { ( dotProps : any , event ) => onDotClick ( props , event ) }
415
379
/>
416
380
) ;
417
- }
418
- return < Fragment key = { index } > </ Fragment > ;
419
- } }
420
- key = { category }
421
- name = { category }
422
- type = { curveType }
423
- dataKey = { category }
424
- stroke = ""
425
- fill = { `url(#${ categoryColors . get ( category ) } )` }
426
- strokeWidth = { 2 }
427
- strokeLinejoin = "round"
428
- strokeLinecap = "round"
429
- isAnimationActive = { showAnimation }
430
- animationDuration = { animationDuration }
431
- stackId = { stack ? "a" : undefined }
432
- connectNulls = { connectNulls }
433
- />
434
- ) ) }
381
+ } }
382
+ dot = { ( props : any ) => {
383
+ const {
384
+ stroke,
385
+ strokeLinecap,
386
+ strokeLinejoin,
387
+ strokeWidth,
388
+ cx,
389
+ cy,
390
+ dataKey,
391
+ index,
392
+ } = props ;
393
+
394
+ if (
395
+ ( hasOnlyOneValueForThisKey ( data , category ) &&
396
+ ! ( activeDot || ( activeLegend && activeLegend !== category ) ) ) ||
397
+ ( activeDot ?. index === index && activeDot ?. dataKey === category )
398
+ ) {
399
+ return (
400
+ < Dot
401
+ key = { index }
402
+ cx = { cx }
403
+ cy = { cy }
404
+ r = { 5 }
405
+ stroke = { stroke }
406
+ fill = ""
407
+ strokeLinecap = { strokeLinecap }
408
+ strokeLinejoin = { strokeLinejoin }
409
+ strokeWidth = { strokeWidth }
410
+ className = { tremorTwMerge (
411
+ "stroke-tremor-background dark:stroke-dark-tremor-background" ,
412
+ onValueChange ? "cursor-pointer" : "" ,
413
+ getColorClassNames (
414
+ categoryColors . get ( dataKey ) ?? BaseColors . Gray ,
415
+ colorPalette . text ,
416
+ ) . fillColor ,
417
+ ) }
418
+ />
419
+ ) ;
420
+ }
421
+ return < Fragment key = { index } > </ Fragment > ;
422
+ } }
423
+ key = { category }
424
+ name = { category }
425
+ type = { curveType }
426
+ dataKey = { category }
427
+ stroke = ""
428
+ fill = { `url(#${ gradientId } )` }
429
+ strokeWidth = { 2 }
430
+ strokeLinejoin = "round"
431
+ strokeLinecap = "round"
432
+ isAnimationActive = { showAnimation }
433
+ animationDuration = { animationDuration }
434
+ stackId = { stack ? "a" : undefined }
435
+ connectNulls = { connectNulls }
436
+ />
437
+ ) ;
438
+ } ) }
435
439
{ onValueChange
436
440
? categories . map ( ( category ) => (
437
441
< Line
0 commit comments