@ant-design/graphs
Case
✨ Features
📦 Installation
$ npm install @ant-design/graphs
🔨 Usage
import React from 'react';
import { DecompositionTreeGraph } from '@ant-design/graphs';
const DemoDecompositionTreeGraph = () => {
const data = {
id: 'A0',
value: {
title: '订单金额',
items: [
{
text: '3031万',
},
],
},
children: [
{
id: 'A1',
value: {
title: '华南',
items: [
{
text: '1152万',
},
{
text: '占比',
value: '30%',
},
],
},
children: [
{
id: 'A11',
value: {
title: '广东',
items: [
{
text: '1152万',
},
{
text: '占比',
value: '30%',
},
],
},
},
{
id: 'A12',
value: {
title: '广西',
items: [
{
text: '1152万',
},
{
text: '占比',
value: '30%',
},
],
},
},
{
id: 'A13',
value: {
title: '海南',
items: [
{
text: '1152万',
},
{
text: '占比',
value: '30%',
},
],
},
},
],
},
{
id: 'A2',
value: {
title: '华北',
items: [
{
text: '595万',
},
{
text: '占比',
value: '30%',
icon: 'https://gw.alipayobjects.com/zos/antfincdn/iFh9X011qd/7797962c-04b6-4d67-9143-e9d05f9778bf.png',
},
],
},
},
],
};
const config = {
data,
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-node'],
nodeCfg: {
title: {
style: (cfg) => {
return {
fill: cfg?.value?.title === '青年' ? 'yellow' : '#fff',
};
},
},
items: {
containerStyle: {
fill: '#fff',
},
style: (cfg, group, type) => {
const styles = {
value: {
fill: '#52c41a',
},
text: {
fill: '#aaa',
},
icon: {
width: 10,
height: 10,
},
};
return styles[type];
},
},
nodeStateStyles: {
hover: {
stroke: '#1890ff',
lineWidth: 2,
},
},
style: {
radius: [2, 2, 2, 2],
},
},
markerCfg: (cfg) => {
const { children } = cfg;
return {
show: children?.length,
};
},
};
return <DecompositionTreeGraph {...config} />;
};
export default DemoDecompositionTreeGraph;
📜 Document & API
See chart API for details. Common props:
export interface CommonConfig extends GraphContainerConfig {
data: Datum;
autoFit?: boolean;
fitCenter?: boolean;
width?: number;
height?: number;
pixelRatio?: number;
layout?: any;
edgeCfg?: EdgeCfg;
nodeCfg?: NodeCfg;
markerCfg?: IMarkerCfg;
minimapCfg?: MiniMapConfig;
toolbarCfg?: ToolbarCfg;
tooltipCfg?: TooltipCfg;
behaviors?: string[];
animate?: boolean;
customLayout?: boolean;
onReady?: (graph: IGraph) => void;
}
🤝 How to Contribute
Your contributions are always welcome! Please Do have a look at the issues first.
📧 Contact us
DingTalk group number: 44788198
.
License
MIT