yWorks / yfiles-jupyter-graphs-for-neo4j

The open-source adapter for working with neo4j graphs and cypher queries in jupyter notebooks leveraging the yFiles Graphs for Jupyter plugin.
https://www.yworks.com/jupyter
MIT License
25 stars 3 forks source link

Customize style for relationship #7

Open mystvearn opened 1 month ago

mystvearn commented 1 month ago

Thank you for this amazing widget.

Is there a way to customize the style for edge (relationship)? For example changing from solid to dotted line or bold the display text.

fskpf commented 1 month ago

Currently, edges can only be changed wrt. color and thickness_factor, e.g.

g.add_relationship_configuration('ACTED_IN', thickness_factor=5, color='#AC94F4')

where both mappings could be lambdas as well.

Text styling supports the following properties: fontSize, color, backgroundColor, position, maximumWidth, maximumHeight, wrapping and textAlignment (for more details on the different properties see this notebook).

This works for both, nodes and edges, e.g.

g.add_node_configuration('Movie', text= lambda node : {
        'text': datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 
        'backgroundColor': '#5C268B', 
        'fontSize': 20, 
        'color': '#FF6EC7', 
        'position': 'north', 
        'maximumWidth': 130, 
        'wrapping': 'word', 
        'textAlignment': 'center'
    })  

Unfortunately, the two options you are looking for are currently not supported. However, we may add them in the future, therefore keeping this open as feature request.

mystvearn commented 1 month ago

@fskpf Thanks for the intuitive response. How about setting default layout? The hierarchic works perfectly in my case but I can't find a way to set it by default.

fskpf commented 1 month ago

This is a missing feature for the yfiles-jupyter-graphs-for-neo4j despite the available functionality in the core yfiles-jupyter-graphs widget (see this notebook).

That said, you can work around this and set the layout on the (private) core field like so:

g.show_cypher("MATCH (s)-[r]->(t) RETURN s,r,t LIMIT 20")
g._widget.hierarchic_layout()

The above-mentioned notebook contains the different available layout calls.

The important part here is that you must set the layout directly after the show_cypher call in the same cell.