Skip to content

Commit

Permalink
🚧 add foreground to interaction states
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Dec 11, 2024
1 parent b5de544 commit 830fd44
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
4 changes: 1 addition & 3 deletions packages/@ourworldindata/grapher/src/chart/ChartUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,8 @@ export function byInteractionState(series: {
switch (series.hover) {
case InteractionState.background:
return 1
case InteractionState.none:
case InteractionState.foreground:
return 2
case InteractionState.active:
return 3
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ export class InteractionArray {
* isn't currently interacted with.
*/
state(seriesName: SeriesName): InteractionState {
if (this.isEmpty) return InteractionState.none
return this.isInForeground(seriesName)
? InteractionState.active
? InteractionState.foreground
: InteractionState.background
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ export class StackedAreaChart extends AbstractStackedChart {

private hoverStateForSeries(
series: StackedSeries<number>
): InteractionState | undefined {
if (!this.focusedSeriesName) return undefined
): InteractionState {
if (!this.focusedSeriesName) return InteractionState.foreground
return this.focusedSeriesName === series.seriesName
? InteractionState.active
? InteractionState.foreground
: InteractionState.background
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ export enum DimensionProperty {
}

export enum InteractionState {
none = "none", // series is in its default state since the chart is not interacted with
active = "active", // series is actively hovered/focused
foreground = "foreground", // series is either actively hovered/focused or the chart is not currently being interacted with
background = "background", // another series is actively hovered/focused
}

Expand Down

0 comments on commit 830fd44

Please sign in to comment.