analysis/group/bar-aggregated-with-label

Example page

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

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

chart.options({
  type: 'interval',
  data: {
    type: 'fetch',
    value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/diamond.json',
  },
  transform: [
    {
      type: 'groupX',
      y: 'max',
    },
  ],
  encode: { x: 'clarity', y: 'price' },
  axis: { y: { labelFormatter: '~s' } },
  labels: [{ text: (d, i, data, { channel }) => channel.y[i] }],
  style: {
    fill: (d, i, data, { channel }) =>
      channel.y[i] < 11700 ? '#E49361' : '#4787F7',
  },
  tooltip: { items: [{ channel: 'y', valueFormatter: '~s' }] },
});

chart.render();