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

Cluster diagram with straight edges & edgeType not working? #533

Closed
xhxh96 opened this issue Sep 22, 2020 · 2 comments
Closed

Cluster diagram with straight edges & edgeType not working? #533

xhxh96 opened this issue Sep 22, 2020 · 2 comments

Comments

@xhxh96
Copy link

xhxh96 commented Sep 22, 2020

I'm trying to render a hierarchical clustering diagram that looks something like this (minus the similarity axis and dashed-line) with NetworkFrame.
hierachical clustering diagram

However, I haven't been able to figure out how I can configure the edges to produce a diagram that's like the above. This is what was generated with NetworkFrame with cluster as its networkType:
image

I understood from this post that this can be done in d3 by changing the attribute of <path>. I tried changing edgeType but it didn't work -- I used the example in the doc and the edges simply didn't show up.

@xhxh96 xhxh96 changed the title Cluster diagram with straight edges Cluster diagram with straight edges & edgeType not working? Sep 23, 2020
@hydrosquall
Copy link
Member

hydrosquall commented Oct 17, 2020

Hi @xhxh96 ,

I think what you're looking for is the setting the edgeType property to a function that returns JSX, instead of passing in a custom path string directly: https://semiotic.nteract.io/api/networkframe#edgetype--string--object--function-

Inside your function, you get a reference to EdgeData, which should have all the information you need to create the custom edge

export interface EdgeType {
source?: NodeType
target?: NodeType
d?: string
x?: number
y?: number
sankeyWidth?: number
direction?: string
width?: number
points?: Array<{ x: number; y: number }>
}

For example:

{
     //.. your other network graph configuration data
     edgeType: (edgeData) => {
        // Suggest console.log(d) here to check what data you have access to 
        const myCustomPath = yourCustomRightAngledEdgesFunction(edgeData);
        return  <path d={myCustomPath} />
    }  
 }
}

Hope this helps!

@emeeks
Copy link
Member

emeeks commented Jan 4, 2021

@hydrosquall is right, that's how you'd implement custom behavior, in your case you'd want to use one of the step interpolators like stepBefore.

@emeeks emeeks closed this as completed Jan 4, 2021
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