Skip to content

Commit

Permalink
feat(legend): add ability to hide legend (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwambach authored Aug 26, 2021
1 parent 6d7f15d commit da3d186
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
47 changes: 28 additions & 19 deletions src/scripts/components/main/data-viewer/data-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,34 @@ const DataViewer: FunctionComponent<Props> = ({
<div className={styles.dataViewer}>
{[mainLayerDetails, compareLayerDetails]
.filter((layer): layer is Layer => Boolean(layer))
.map(({id, maxValue, minValue, units, basemap, legendValues}, index) =>
id === 'land_cover.lccs_class' ? (
<HoverLegend
key={id}
values={legendValues as LegendValueColor[]}
isCompare={index > 0}
/>
) : (
<LayerLegend
key={id}
id={id}
values={
(legendValues as string[]) || [maxValue || 0, minValue || 0]
}
unit={units}
basemap={basemap}
isCompare={index > 0}
/>
)
.map(
(
{id, maxValue, minValue, units, basemap, legendValues, hideLegend},
index
) => {
if (hideLegend) {
return null;
}

return id === 'land_cover.lccs_class' ? (
<HoverLegend
key={id}
values={legendValues as LegendValueColor[]}
isCompare={index > 0}
/>
) : (
<LayerLegend
key={id}
id={id}
values={
(legendValues as string[]) || [maxValue || 0, minValue || 0]
}
unit={units}
basemap={basemap}
isCompare={index > 0}
/>
);
}
)}

{getDataWidget({
Expand Down
1 change: 1 addition & 0 deletions src/scripts/types/layer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export interface Layer {
units: string;
legendValues: string[] | LegendValueColor[];
legendBackgroundColor: string;
hideLegend?: boolean;
}

0 comments on commit da3d186

Please sign in to comment.