Skip to content

Commit 4a45931

Browse files
committed
Autovelger andel av besøkende
1 parent d66b3eb commit 4a45931

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/components/chartbuilder/Summarize.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,20 @@ const Summarize = ({
361361
label="Legg til beregning"
362362
onChange={(e) => {
363363
if (e.target.value) {
364+
// Add the metric
364365
addMetric(e.target.value);
366+
367+
// If it's a percentage metric, set default column to 'visitors' (Besøkende)
368+
if (e.target.value === 'percentage' || e.target.value === 'andel') {
369+
// Get the index of the newly added metric (it will be the last one)
370+
const newIndex = metrics.length; // This will be the index after addMetric completes
371+
372+
// Set timeout to let the addMetric finish processing
373+
setTimeout(() => {
374+
updateMetric(newIndex, { column: 'session_id' });
375+
}, 0);
376+
}
377+
365378
(e.target as HTMLSelectElement).value = '';
366379
}
367380
}}

0 commit comments

Comments
 (0)