From cdcee6e29ce3abfccd7d6f2e45f37118c73cc71f Mon Sep 17 00:00:00 2001 From: gluap Date: Sun, 19 Dec 2021 13:28:02 +0100 Subject: [PATCH] Add incrementing ID to gradient svg. So we do not overwrite it when the other button is enabled. --- frontend/src/components/ColorMapLegend.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/ColorMapLegend.tsx b/frontend/src/components/ColorMapLegend.tsx index 62047fb..b5c615a 100644 --- a/frontend/src/components/ColorMapLegend.tsx +++ b/frontend/src/components/ColorMapLegend.tsx @@ -6,19 +6,24 @@ export default function ColorMapLegend({map}: {map: ColorMap}) { const min = map[0][0] const max = map[map.length - 1][0] const normalizeValue = (v) => (v - min) / (max - min) - + if( typeof ColorMapLegend.counter == 'undefined' ) { + ColorMapLegend.counter = 0; + } + ColorMapLegend.counter++; + ColorMapLegend.id="gradient"+ColorMapLegend.counter; + ColorMapLegend.url="url(#"+ColorMapLegend.id+")"; return (
- + {map.map(([value, color]) => ( ))} - + {map.map(([value]) => (