antvis / G2Plot

:dango: An interactive and responsive charting library based on G2.
https://g2plot.antv.antgroup.com
MIT License
2.56k stars 607 forks source link

🥰 [FEATURE] 支持折线图的坐标轴逆序 #3700

Open webproblem opened 1 year ago

webproblem commented 1 year ago

#3252

这个 issues 中提过这个问题,但是给的答案只是用于柱状图,在折线图中不会生效,希望能支持折线图的坐标轴逆序。

webproblem commented 1 year ago

已经有解决方案了,折线图的坐标轴逆序可以用面积图来模拟

import { Area } from '@antv/g2plot';

fetch('https://gw.alipayobjects.com/os/bmw-prod/360c3eae-0c73-46f0-a982-4746a6095010.json')
  .then((res) => res.json())
  .then((data) => {
    const area = new Area('container', {
      data,
      xField: 'timePeriod',
      yField: 'value',
      xAxis: {
        position: 'top',
      },
      smooth: true,
      coordinate: [{ type: 'reflectY' }],
      areaStyle: {
        fill: ''
      },
    });
    area.render();
  });