Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(geo): highlight choropleth #5095

Merged
merged 1 commit into from
May 25, 2023
Merged

fix(geo): highlight choropleth #5095

merged 1 commit into from
May 25, 2023

Conversation

pearmini
Copy link
Member

Choropleth

修复 Choropleth 的高亮问题,本质上是之前没有传递 State。

开始使用

map-highlight

export async function unemploymentChoropleth(): Promise<G2Spec> {
  const us = await fetch('data/us-10m.json').then((res) => res.json());
  const unemployment = await tsv('data/unemployment.tsv', autoType);
  const counties = feature(us, us.objects.counties).features;
  return {
    type: 'geoPath',
    coordinate: { type: 'albersUsa' },
    data: {
      value: counties,
      transform: [
        {
          type: 'join',
          join: unemployment,
          on: ['id', 'id'],
          select: ['rate'],
        },
      ],
    },
    scale: {
      color: {
        unknown: '#fff',
      },
    },
    state: {
      active: { fill: 'red' },
    },
    encode: {
      color: 'rate',
    },
    legend: { color: { layout: { justifyContent: 'center' } } },
    interaction: { elementHighlight: true },
  };
}

@pearmini pearmini requested a review from hustcc May 25, 2023 09:14
@hustcc hustcc merged commit 7a4d06d into v5 May 25, 2023
@hustcc hustcc deleted the fix/map-highlight branch May 25, 2023 12:06
@pearmini pearmini mentioned this pull request Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants