antvis/G2

New API to config axes and legend #4174

pearmini posted onGitHub

配置坐标轴和图例

之前配置坐标轴和图例是通过对应 scale 的 guide 配置去配置的。这里做一点优化和调整。

存在问题

  • 不是很容易让人理解,对于开发者来说还是 axis 和 legend 的这样的概念更容易理解。
  • 映射和渲染的配置放在一起,不太容易去声明非一对一的关系。比如一个位置比例尺对应多条坐标轴,或者多个比例尺用一个图例来展示。

API 设计

const options = {
  axis: {
    x: {},
    y: {},
  },
  legend: {
    color: {},
    size: {},
  },
};
// 一个比例尺对应多个组件
// x 通道对应的比例尺对应多条坐标轴
const options = {
  axis: {
    x: [{}, {}],
  },
};
// 一个组件对应多个比例尺
// color 和 size 通道默认用一个图例来展示
const options = {
  legend: {
    color: {},
  },
};

这个应该算是完成了?尝试下添加一个案例(放在 component 分类下),来验证混合图例(color + size)

posted by visiky over 2 years ago

Fund this Issue

$0.00
Funded

Pull requests