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

🧐[问题] How to customize the sankey chart #614

Closed
pranit-madhavi-v2stech opened this issue May 10, 2021 · 4 comments
Closed

🧐[问题] How to customize the sankey chart #614

pranit-madhavi-v2stech opened this issue May 10, 2021 · 4 comments

Comments

@pranit-madhavi-v2stech
Copy link

🧐 问题描述 [详细地描述问题,让大家都能理解]

I want to customise the Sankey chart with custom node and edge color. for that I'm using nodeStyle and edgeStyle property in configuration. But when I use nodeStyle and edgeStyle as function, it does not give all the keys in data. it only gives name, x and y values.

💻 示例代码 [如果有必要,展示代码,线上示例,或仓库]

chart config
const config: any = { data: data, sourceField: 'source', targetField: 'target', weightField: 'value', nodeStyle: (a: any) => { if (a.name.includes("User")) { return { fill: "#597EF7" } } else if (a.name.includes("Automation")) { return { fill: "#03838B" } } else if (a.name.includes("Action")) { return { fill: "#C41D7F" } }else if (a.name.includes("Rule")) { return { fill: "#722ED1" } } else { return { fill: "#CED5EE" } } }, edgeStyle: (datum:any)=>{ console.log(datum); } // nodeWidthRatio: 0.008, }

data object
{ "source": "Rule 2", "target": "Automation 3", "value": 35, type: "rule" }

🚑 其他信息 [如截图等其他信息可以贴在这里]

console log
log

I want to customize chart as below
Screenshot from 2021-05-10 14-39-25

I want to customize the node and edge based on type. I'll use gradient for edges.
But how to access value, type (source and destination) inside nodeStyle and edgeStyle function to style node and edge?

current implementation
codesandbox: https://codesandbox.io/s/sankey-lxhc3

@lxfu1
Copy link
Member

lxfu1 commented May 10, 2021

antvis/G2Plot#2533 , Recently released.

@pranit-madhavi-v2stech
Copy link
Author

pranit-madhavi-v2stech commented May 10, 2021

antvis/G2Plot#2533 , Recently released.

looks great.
It's not there in current version of G2Plot (2.3.19).
when will be this feature available in Ant Design Charts ?

@lxfu1
Copy link
Member

lxfu1 commented Aug 4, 2021

Delete node_modules and reinstall.

@lxfu1 lxfu1 closed this as completed Aug 4, 2021
@mantra-sanathra
Copy link

How we can pass the raw fields and use the value given by the data object into nodeStyle function? Is there any example available for this? I want to customize the color based on both the source and destination both.

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

3 participants