diff --git a/src/components/chart-elements/AreaChart/AreaChart.tsx b/src/components/chart-elements/AreaChart/AreaChart.tsx index 5390f95cb..33c3919fa 100644 --- a/src/components/chart-elements/AreaChart/AreaChart.tsx +++ b/src/components/chart-elements/AreaChart/AreaChart.tsx @@ -292,6 +292,7 @@ const AreaChart = React.forwardRef((props, ref) /> ) : null} {categories.map((category) => { + const gradientId = (categoryColors.get(category) ?? BaseColors.Gray).replace("#", ""); return ( {showGradient ? ( @@ -302,7 +303,7 @@ const AreaChart = React.forwardRef((props, ref) colorPalette.text, ).textColor } - id={categoryColors.get(category)} + id={gradientId} x1="0" y1="0" x2="0" @@ -325,7 +326,7 @@ const AreaChart = React.forwardRef((props, ref) colorPalette.text, ).textColor } - id={categoryColors.get(category)} + id={gradientId} x1="0" y1="0" x2="0" @@ -342,68 +343,22 @@ const AreaChart = React.forwardRef((props, ref) ); })} - {categories.map((category) => ( - { - const { cx, cy, stroke, strokeLinecap, strokeLinejoin, strokeWidth, dataKey } = - props; - return ( - onDotClick(props, event)} - /> - ); - }} - dot={(props: any) => { - const { - stroke, - strokeLinecap, - strokeLinejoin, - strokeWidth, - cx, - cy, - dataKey, - index, - } = props; - - if ( - (hasOnlyOneValueForThisKey(data, category) && - !(activeDot || (activeLegend && activeLegend !== category))) || - (activeDot?.index === index && activeDot?.dataKey === category) - ) { + {categories.map((category) => { + const gradientId = (categoryColors.get(category) ?? BaseColors.Gray).replace("#", ""); + return ( + { + const { cx, cy, stroke, strokeLinecap, strokeLinejoin, strokeWidth, dataKey } = + props; return ( ((props, ref) colorPalette.text, ).fillColor, )} + cx={cx} + cy={cy} + r={5} + fill="" + stroke={stroke} + strokeLinecap={strokeLinecap} + strokeLinejoin={strokeLinejoin} + strokeWidth={strokeWidth} + onClick={(dotProps: any, event) => onDotClick(props, event)} /> ); - } - return ; - }} - key={category} - name={category} - type={curveType} - dataKey={category} - stroke="" - fill={`url(#${categoryColors.get(category)})`} - strokeWidth={2} - strokeLinejoin="round" - strokeLinecap="round" - isAnimationActive={showAnimation} - animationDuration={animationDuration} - stackId={stack ? "a" : undefined} - connectNulls={connectNulls} - /> - ))} + }} + dot={(props: any) => { + const { + stroke, + strokeLinecap, + strokeLinejoin, + strokeWidth, + cx, + cy, + dataKey, + index, + } = props; + + if ( + (hasOnlyOneValueForThisKey(data, category) && + !(activeDot || (activeLegend && activeLegend !== category))) || + (activeDot?.index === index && activeDot?.dataKey === category) + ) { + return ( + + ); + } + return ; + }} + key={category} + name={category} + type={curveType} + dataKey={category} + stroke="" + fill={`url(#${gradientId})`} + strokeWidth={2} + strokeLinejoin="round" + strokeLinecap="round" + isAnimationActive={showAnimation} + animationDuration={animationDuration} + stackId={stack ? "a" : undefined} + connectNulls={connectNulls} + /> + ); + })} {onValueChange ? categories.map((category) => (