File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
src/components/chartbuilder Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -361,7 +361,20 @@ const Summarize = ({
361
361
label = "Legg til beregning"
362
362
onChange = { ( e ) => {
363
363
if ( e . target . value ) {
364
+ // Add the metric
364
365
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
+
365
378
( e . target as HTMLSelectElement ) . value = '' ;
366
379
}
367
380
} }
You can’t perform that action at this time.
0 commit comments