Skip to content

Commit

Permalink
refactor(geometry): add GEOMETRY_STYLES constant
Browse files Browse the repository at this point in the history
  • Loading branch information
emmacunningham committed Feb 8, 2019
1 parent c062b2e commit 409097e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/lib/series/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,23 @@ export function getGeometryStyle(
geometryId: GeometryId,
highlightedLegendItem: LegendItem | null,
): GeometryStyle {
let opacity = 1;
if (highlightedLegendItem != null) {
const isPartOfHighlightedSeries = belongsToDataSeries(geometryId, highlightedLegendItem.value);

if (!isPartOfHighlightedSeries) {
opacity = 0.25;
}
return isPartOfHighlightedSeries ? GEOMETRY_STYLES.highlighted : GEOMETRY_STYLES.unhighlighted;
}

return { opacity };
return GEOMETRY_STYLES.default;
}

const GEOMETRY_STYLES: { [key: string]: GeometryStyle } = {
default: {
opacity: 1,
},
highlighted: {
opacity: 1,
},
unhighlighted: {
opacity: 0.25,
},
};

0 comments on commit 409097e

Please sign in to comment.