Skip to content

Multiple Ratio Value #34

@gangtao

Description

@gangtao

similar as multiple value, show the ration like cpu usage or memory use case

two format

one is liquid
Image

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

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

chart.liquid().data(0.3).style({
  outlineBorder: 4,
  outlineDistance: 8,
  waveLength: 128,
});

chart.render();

the other is ring

Image
mport { Chart } from '@antv/g2';

const progress = 0.7;

const chart = new Chart({
  container: 'container',
  width: 100,
  height: 100,
});

chart.coordinate({ type: 'theta', innerRadius: 0.7 });

chart
  .interval()
  .data([1, progress])
  .encode('y', (d) => d)
  .encode('color', (d, idx) => idx)
  .scale('y', { domain: [0, 1] })
  .scale('color', { range: ['#000000', '#a0ff03'] })
  .animate('enter', { type: 'waveIn' })
  .axis(false)
  .legend(false);

chart.text().style({
  text: `${progress * 100}%`,
  x: '50%',
  y: '50%',
  textAlign: 'center',
  fontSize: 16,
  fontStyle: 'bold',
});

chart.interaction('tooltip', false);

chart.render();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions