Skip to content

Commit

Permalink
Gray out non-avg lines in salient
Browse files Browse the repository at this point in the history
  • Loading branch information
AbrarNad committed Oct 29, 2024
1 parent 2b97f25 commit 5e98238
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/public/viz-guardrails/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export function LineChart({
const [hover, setHover] = useState<string[] | null>(null);

const shouldBeColor = ((country: string) => {
if (parameters.condition === 'salient') {
if (!selection?.includes(country)) {
return true;
}
return false;
}

if (!selection?.includes(country)) {
return false;
}
Expand Down Expand Up @@ -127,8 +134,7 @@ export function LineChart({
const cats = Array.from(new Set(data.map((d) => d[parameters.cat_var])));

if (parameters.condition === 'salient') {
const paletteWithoutOrange = OwidDistinctLinesPalette.filter((color) => color !== 'orange');
return d3.scaleOrdinal(paletteWithoutOrange).domain(cats);
return d3.scaleOrdinal(['orange']).domain(cats);
}

return d3.scaleOrdinal(OwidDistinctLinesPalette).domain(cats);
Expand Down Expand Up @@ -359,8 +365,7 @@ export function LineChart({
<Text
px={2}
size={10}
// eslint-disable-next-line no-nested-ternary
color={shouldBeColor(x.country) ? colorScale(x.country) : parameters.condition === 'salient' ? 'orange' : 'silver'}
color={shouldBeColor(x.country) ? colorScale(x.country) : 'silver'}
onMouseOver={(e) => {
const t = e.target as HTMLElement;
if (!selection?.includes(t.innerText)) {
Expand Down

0 comments on commit 5e98238

Please sign in to comment.