Add a randomly generated gradientID to so each chart has a unique gradient
This commit is contained in:
1 parent
e3c13d93ec
commit
9cf2be774b
2 files changed
+4
-2
No files matched your search
@@ -85,6 +85,7 @@ const CustomAreaChart = ({
|
|||||||
customTooltip,
|
customTooltip,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const gradientId = `gradient-${Math.random().toString(36).slice(2, 9)}`;
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer
|
<ResponsiveContainer
|
||||||
width="100%"
|
width="100%"
|
||||||
@@ -101,6 +102,7 @@ const CustomAreaChart = ({
|
|||||||
/>
|
/>
|
||||||
{gradient === true &&
|
{gradient === true &&
|
||||||
createGradient({
|
createGradient({
|
||||||
|
id: gradientId,
|
||||||
startColor: gradientStartColor,
|
startColor: gradientStartColor,
|
||||||
endColor: gradientEndColor,
|
endColor: gradientEndColor,
|
||||||
direction: gradientDirection,
|
direction: gradientDirection,
|
||||||
@@ -116,7 +118,7 @@ const CustomAreaChart = ({
|
|||||||
type="monotone"
|
type="monotone"
|
||||||
dataKey={dataKey}
|
dataKey={dataKey}
|
||||||
stroke={strokeColor}
|
stroke={strokeColor}
|
||||||
fill={gradient === true ? "url(#colorUv)" : fillColor}
|
fill={gradient === true ? `url(#${gradientId})` : fillColor}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{customTooltip ? (
|
{customTooltip ? (
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export const createGradient = ({
|
export const createGradient = ({
|
||||||
id = "colorUv",
|
id,
|
||||||
startColor,
|
startColor,
|
||||||
endColor,
|
endColor,
|
||||||
startOpacity = 0.8,
|
startOpacity = 0.8,
|
||||||
|
|||||||
Reference in new issue
Block a user