antvis/G2

view.labelTransform δΈη”Ÿζ•ˆ #4633

pearmini posted onGitHub

  • η‰ˆζœ¬οΌš5.0.0-beta.9
import { G2Spec } from '../../../src';
import { weather } from '../../data/weather';

export function weatherLineMultiAxes(): G2Spec {
  return {
    type: 'view',
    data: weather,
    labelTransform: [{ type: 'overlapDodgeY' }],
    children: [
      {
        type: 'line',
        encode: {
          x: 'Month',
          y: 'Temperature',
          color: '#EE6666',
          shape: 'smooth',
        },
        scale: {
          y: { independent: true, domainMax: 30 },
        },
        labels: [{ text: 'Temperature' }],
        axis: {
          y: {
            titleFill: '#EE6666',
            title: 'Temperature (Β°C)',
            grid: null,
          },
        },
      },
      {
        type: 'line',
        encode: {
          x: 'Month',
          y: 'Precipitation',
          color: '#91CC75',
        },
        scale: {
          y: { independent: true },
        },
        style: {
          lineWidth: 2,
          lineDash: [2, 2],
        },
        labels: [{ text: 'Precipitation' }],
        axis: {
          y: {
            position: 'right',
            titleFill: '#91CC75',
            title: 'Precipitation (ml)',
            grid: null,
          },
        },
      },
    ],
  };
}

Fund this Issue

$0.00
Funded

Pull requests