Skip to content

transpose

Transpose is a coordinate system transformation that transforms (x, y) to (y, x), commonly used for converting between bar charts and column charts.

Getting Started

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

const chart = new Chart({});

chart.options({
  type: 'interval',
  coordinate: { transform: [{ type: 'transpose' }] },
  data: {
    type: 'fetch',
    value:
      'https://gw.alipayobjects.com/os/bmw-prod/fb9db6b7-23a5-4c23-bbef-c54a55fee580.csv',
    format: 'csv',
  },
  transform: [
    {
      type: 'sortX',
      reverse: true,
    },
  ],
  encode: { x: 'letter', y: 'frequency', color: 'steelblue' },
  axis: { y: { labelFormatter: '.0%' } },
  labels: [
    {
      text: 'frequency',
      formatter: '.1%',
      style: {
        textAnchor: (d) => (+d.frequency > 0.008 ? 'right' : 'start'),
        fill: (d) => (+d.frequency > 0.008 ? '#fff' : '#000'),
        dx: (d) => (+d.frequency > 0.008 ? -5 : 5),
      },
    },
  ],
});

chart.render();
© Copyright 2026 Ant Group Co., Ltd..备案号:京ICP备15032932号-38
Site search
Documentation and examplesType to start searching

Search documentation, APIs, and examples

↑↓Select↵OpenEscClose