Skip to content

Commit

Permalink
✨ make unfocused lines a little thinner
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Dec 13, 2024
1 parent 8192fca commit b63e1c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 7 additions & 4 deletions packages/@ourworldindata/grapher/src/lineCharts/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ class Lines extends React.Component<LinesProps> {
: NON_FOCUSED_LINE_COLOR

const strokeDasharray = series.isProjection ? "2,3" : undefined
const strokeWidth = hover.background ? 1 : this.strokeWidth
const strokeWidth =
hover.background || focus.background
? this.strokeWidth - 0.33 * this.strokeWidth
: this.strokeWidth
const strokeOpacity =
hover.background && !focus.background ? GRAPHER_OPACITY_MUTE : 1

Expand All @@ -196,7 +199,7 @@ class Lines extends React.Component<LinesProps> {
id={makeIdForHumanConsumption("outline", series.seriesName)}
placedPoints={series.placedPoints}
stroke={outlineColor}
strokeWidth={outlineWidth}
strokeWidth={outlineWidth.toFixed(1)}
/>
)

Expand All @@ -206,7 +209,7 @@ class Lines extends React.Component<LinesProps> {
id={makeIdForHumanConsumption("line", series.seriesName)}
points={series.placedPoints}
strokeLinejoin="round"
strokeWidth={strokeWidth}
strokeWidth={strokeWidth.toFixed(1)}
strokeDasharray={strokeDasharray}
strokeOpacity={strokeOpacity}
/>
Expand All @@ -215,7 +218,7 @@ class Lines extends React.Component<LinesProps> {
id={makeIdForHumanConsumption("line", series.seriesName)}
placedPoints={series.placedPoints}
stroke={color}
strokeWidth={strokeWidth}
strokeWidth={strokeWidth.toFixed(1)}
strokeOpacity={strokeOpacity}
strokeDasharray={strokeDasharray}
/>
Expand Down
10 changes: 7 additions & 3 deletions packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,10 @@ function Slope({
!focus.background || hover.active
? series.color
: NON_FOCUSED_LINE_COLOR
const lineWidth =
hover.background || focus.background
? strokeWidth - 0.33 * strokeWidth
: strokeWidth

return (
<g
Expand All @@ -1344,15 +1348,15 @@ function Slope({
endPoint={endPoint}
radius={dotRadius}
color={outlineStroke}
lineWidth={strokeWidth + 2 * outlineWidth}
lineWidth={lineWidth + 2 * outlineWidth}
/>
)}
<LineWithDots
startPoint={startPoint}
endPoint={endPoint}
radius={dotRadius}
color={color}
lineWidth={strokeWidth}
lineWidth={lineWidth}
opacity={opacity}
/>
</g>
Expand Down Expand Up @@ -1392,7 +1396,7 @@ function LineWithDots({
d={`${startDotPath} ${endDotPath} ${linePath}`}
fill={color}
stroke={color}
strokeWidth={lineWidth}
strokeWidth={lineWidth.toFixed(1)}
opacity={opacity}
/>
)
Expand Down

0 comments on commit b63e1c0

Please sign in to comment.