Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Treemap Mark #4237

Closed
pepper-nice opened this issue Nov 3, 2022 · 1 comment
Closed

Add Treemap Mark #4237

pepper-nice opened this issue Nov 3, 2022 · 1 comment
Assignees

Comments

@pepper-nice
Copy link
Contributor

pepper-nice commented Nov 3, 2022

用于绘制矩阵树图的复合 Mark

API 设计

mark.layout

API 说明
tile 布局方式
size 节点宽高比
padding/paddingInner/... 布局节点间隙
ratio 节点大小比率

mark.encode

API 说明
name 节点的名称字段
value 节点占比字段

mark.label

节点 label 样式

案例验证

import { csv } from 'd3-fetch';
import { autoType } from 'd3-dsv';
import { G2Spec } from '../../../src';

export async function flareTreemapDefaults(): Promise<G2Spec> {
  const data = await csv('data/flare.csv', autoType);
  const mockData = data.map((d) => ({
    ...d,
    group: d.name.split('.')[0],
  }));

  return {
    type: 'view',
    width: 900,
    height: 600,
    padding: 10,
    children: [
      {
        type: 'treemap',
        data: {
          value: mockData,
        },
        layout: {
          tile: 'binary',
          size: [1, 1],
          padding: 2,
        },
        encode: {
          name: 'name',
          value: 'value',
        },
        style: {
          fillOpacity: 0.6,
          // ...
        },
      },
    ],
  };
}
@pepper-nice pepper-nice self-assigned this Nov 3, 2022
@pearmini
Copy link
Member

pearmini commented Nov 3, 2022

下面 node 前缀没有必要的,因为里面只有一种 mark。

image

const options = {
  style: {
    fillOpacity: 0.6
  }
}

hustcc pushed a commit that referenced this issue May 16, 2023
* feat(mark): add treemap mark (close: #4237)

* feat: label shape add clipPath

* feat: update snapshots
hustcc pushed a commit that referenced this issue May 16, 2023
* feat(mark): add treemap mark (close: #4237)

* feat: label shape add clipPath

* feat: update snapshots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants