Skip to content

【v5】interaction 下面的动作配置文档不全 #5365

Answered by pearmini
Deathsteps asked this question in Q&A
Discussion options

You must be logged in to vote

文档有点问题,这个是属于 element 的状态,需要如下配置:

import { Chart } from '@antv/g2';

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

chart
  .interval()
  .data({
    type: 'fetch',
    value:
      'https://gw.alipayobjects.com/os/bmw-prod/fb9db6b7-23a5-4c23-bbef-c54a55fee580.csv',
  })
  .transform([{ type: 'sortX', by: 'y', reverse: true, slice: 5 }])
  .encode('x', 'letter')
  .encode('y', 'frequency')
  .axis('y', { labelFormatter: '.0%' })
  .state('active', {backgroundFill:'red'}) // 这里
  .interaction('elementHighlight', { background: true });

chart.render();

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@hustcc
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by pearmini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants