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

地图高亮失效 #4921

Closed
pearmini opened this issue Apr 26, 2023 · 1 comment
Closed

地图高亮失效 #4921

pearmini opened this issue Apr 26, 2023 · 1 comment
Assignees
Labels

Comments

@pearmini
Copy link
Member

  • 版本 5.0.4
  • 问题:1. chart 没有 state api 2. state 配置没有生效 3.没有恢复高亮
/**
 * A recreation of this demo: https://vega.github.io/vega-lite/examples/geo_choropleth.html
 */
import { feature } from 'topojson';

Promise.all([
  fetch('https://assets.antv.antgroup.com/g2/us-10m.json').then((res) =>
    res.json(),
  ),
  fetch('https://assets.antv.antgroup.com/g2/unemployment2.json').then((res) =>
    res.json(),
  ),
]).then((values) => {
  const [us, unemployment] = values;
  const counties = feature(us, us.objects.counties).features;

  const chart = new Chart({
    container: 'container',
    theme: 'classic',
    autoFit: true,
  });

  chart
    .geoPath()
    .coordinate({ type: 'albersUsa' })
    .data({
      value: counties,
      transform: [
        {
          type: 'join',
          join: unemployment,
          on: ['id', 'id'],
          select: ['rate'],
        },
      ],
    })
    .scale('color', {
      type: 'sequential',
      palette: 'ylGnBu',
      unknown: '#fff',
    })
    .encode('color', 'rate')
    .state('active', { fill: 'orange' })
    .state('inactive', { opacity: 0.5 });

  chart.interaction('elementHighlight', true);

  chart.render();
});
@pearmini pearmini added the V5 label Apr 26, 2023
@pearmini pearmini self-assigned this Apr 26, 2023
@pearmini pearmini added the Bug label Apr 26, 2023
@pearmini
Copy link
Member Author

fixed by: #5095

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant