Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sirmmo committed Oct 21, 2024
1 parent ed24b54 commit 389e11f
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 118 deletions.
5 changes: 3 additions & 2 deletions src/app/components/Map/LegendBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface LegendBarProps {
data: any;
unit: string;
label: string;
precision?: number;
}

const lightOrDark = color => {
Expand Down Expand Up @@ -46,7 +47,7 @@ const lightOrDark = color => {
};

export const LegendBar = (props: LegendBarProps) => {
const { className, isMobile, unit, label } = props;
const { className, isMobile, unit, label, precision = 2 } = props;
const data = props.data || { color_entries: [] };
const colors = data.color_entries?.sort((a, b) => b.value - a.value);

Expand Down Expand Up @@ -94,7 +95,7 @@ export const LegendBar = (props: LegendBarProps) => {
color: fg,
}}
>
{itm.value.toFixed(1).replaceAll('.', ',')} {unit}
{itm.value.toFixed(precision).replaceAll('.', ',')} {unit}
</div>
);
})}
Expand Down
1 change: 1 addition & 0 deletions src/app/components/Map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const Map = (props: MapProps) => {
? layerConf.unit_italian
: layerConf.unit_english
}
precision={layerConf.data_precision}
/>
</CustomControlMap>
<MousePositionComponent
Expand Down
38 changes: 19 additions & 19 deletions src/app/components/MapMenuBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export interface MapMenuBar {

const MAP_MODES = {
future: 'Proiezioni',
past: 'Dati Storici',
advanced: 'Vista avanzata',
simple: 'Vista semplificata',
past: 'Storica',
advanced: 'avanzata',
simple: 'semplificata',
};

// eslint-disable-next-line @typescript-eslint/no-redeclare
Expand Down Expand Up @@ -183,22 +183,22 @@ export function MapMenuBar(props: MapMenuBar) {
...mapParameters('aggregation_period', 'aggregation_period'),
disableable: true && current_map.climatological_value !== '',
criteria: x => {
return x.other_parameters?.aggregation_period;
return x?.aggregation_period;
},
},
{
key: 'measure',
groupName: t('app.map.menu.valueTypes'),
...mapParameters('measure', 'measure'),
disableable: true,
criteria: x => x.other_parameters?.measure,
criteria: x => x?.measure,
},
{
key: 'time_window',
groupName: t('app.map.menu.timeWindows'),
...mapParameters('time_window', 'time_window'),
disableable: true,
criteria: x => x.other_parameters?.time_window,
criteria: x => x?.time_window,
},
],
},
Expand All @@ -212,7 +212,7 @@ export function MapMenuBar(props: MapMenuBar) {
groupName: '',
...mapParameters('year_period', 'year_period'),
disableable: true,
criteria: x => x.other_parameters?.year_period,
criteria: x => x?.year_period,
},
],
},
Expand Down Expand Up @@ -246,31 +246,31 @@ export function MapMenuBar(props: MapMenuBar) {

// const handleChange = (menuIdx: number, groupSelection: IGrpItm[]) => {
const handleChange = (key: string, value: string) => {
const steps = ['climatological_variable', 'aggregation_period'];
const steps = ['climatological_variable', 'aggregation_period', 'measure'];
console.log('handleChange', key, value);
console.log(combinations);
const idx = steps.indexOf(key);
let ckey = '{climatological_variable}';
if (idx >= 0) {
if (idx === 1) ckey = ckey + '::{aggregation_period}';
if (idx === 1) {
if (idx > 0) ckey = ckey + '::{metric}';
if (idx > 0) {
ckey = ckey.replace(
'{climatological_variable}',
current_map.climatological_variable,
);
ckey = ckey.replace('{aggregation_period}', value);
ckey = ckey.replace('{metric}', value);
} else {
ckey = ckey.replace('{climatological_variable}', value);
}
if (Object.keys(combinations).indexOf(ckey) >= 0) {
if (current_map.measure in combinations[ckey]) {
console.log(
'activating Combo',
ckey,
combinations[ckey][current_map.measure],
);
setActiveCombinations(combinations[ckey][current_map.measure]);
}
//if (current_map[key] in combinations[ckey]) {
console.log(
'activating Combo',
ckey,
combinations[ckey][current_map[key]],
);
setActiveCombinations(combinations[ckey]);
//}
} else if (
Object.keys(combinations).indexOf(
current_map.climatological_variable,
Expand Down
Loading

0 comments on commit 389e11f

Please sign in to comment.