Skip to content

柱状图设置柱宽时, 居中失效 #5192

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

You must be logged in to vote

.style("width", 10) -> .encode("size", 10)

/**
 * A recreation of this demo: https://vega.github.io/vega-lite/examples/bar_grouped_repeated.html
 */
import { Chart } from '@antv/g2';

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

chart.data({
  type: 'fetch',
  value: 'https://assets.antv.antgroup.com/g2/movies.json',
});

chart
  .interval()
  .transform({ type: 'groupX', y: 'sum' })
  .axis('y', { labelFormatter: '~s' })
  .axis('x', { labelTransform: 'rotate(90)' })
  .encode('x', 'Major Genre')
  .encode('y', 'Worldwide Gross')
  .encode('series', () => 'Worldwide Gross')
  .encode('color', () => 'Worldwide Gross')
  

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@KuduroJS
Comment options

@pearmini
Comment options

Comment options

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

Answer selected by KuduroJS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5191 on June 14, 2023 06:42.