Skip to content

Commit

Permalink
✨ (line+slope) hide outlines for background series
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Dec 12, 2024
1 parent 8eb3328 commit 9691515
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 28 deletions.
49 changes: 22 additions & 27 deletions packages/@ourworldindata/grapher/src/lineCharts/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class Lines extends React.Component<LinesProps> {
const strokeOpacity =
hover.background && !focus.background ? GRAPHER_OPACITY_MUTE : 1

const showOutline = !focus.background || hover.active
const outlineColor =
this.props.backgroundColor ?? GRAPHER_BACKGROUND_DEFAULT
const outlineWidth = strokeWidth + this.lineOutlineWidth * 2
Expand All @@ -199,36 +200,30 @@ class Lines extends React.Component<LinesProps> {
/>
)

if (this.props.multiColor) {
return (
<>
{outline}
<MultiColorPolyline
id={makeIdForHumanConsumption(
"multicolor-line",
series.seriesName
)}
points={series.placedPoints}
strokeLinejoin="round"
strokeWidth={strokeWidth}
strokeDasharray={strokeDasharray}
strokeOpacity={strokeOpacity}
/>
</>
)
}
const line = this.props.multiColor ? (
<MultiColorPolyline
id={makeIdForHumanConsumption("line", series.seriesName)}
points={series.placedPoints}
strokeLinejoin="round"
strokeWidth={strokeWidth}
strokeDasharray={strokeDasharray}
strokeOpacity={strokeOpacity}
/>
) : (
<LinePath
id={makeIdForHumanConsumption("line", series.seriesName)}
placedPoints={series.placedPoints}
stroke={color}
strokeWidth={strokeWidth}
strokeOpacity={strokeOpacity}
strokeDasharray={strokeDasharray}
/>
)

return (
<>
{outline}
<LinePath
id={makeIdForHumanConsumption("line", series.seriesName)}
placedPoints={series.placedPoints}
stroke={color}
strokeWidth={strokeWidth}
strokeOpacity={strokeOpacity}
strokeDasharray={strokeDasharray}
/>
{showOutline && outline}
{line}
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ function Slope({
}: SlopeProps) {
const { displayName, startPoint, endPoint, hover, focus } = series

const showOutline = !hover.background
const showOutline = !focus.background || hover.active
const opacity =
hover.background && !focus.background ? GRAPHER_OPACITY_MUTE : 1
const color =
Expand Down

0 comments on commit 9691515

Please sign in to comment.