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

Question: Default Styles (or theme)? #6

Open
scottctr opened this issue Dec 29, 2019 · 3 comments
Open

Question: Default Styles (or theme)? #6

scottctr opened this issue Dec 29, 2019 · 3 comments
Milestone

Comments

@scottctr
Copy link

Great library -- thanks for sharing it!

Have you given any thought to allowing for default styles or themes so that users don't have to redefine the same styles for each node and edge?

I'm asking because I'm considering integrating your library in with my state management library. Ideally, my users would be able to define a set of styles for states (nodes), transitions (edges), and conditional transitions (specialized nodes and edges) before calling an export method and end up with something like this diagram.

Let me know your thoughts and I might be able to help implement this functionality.

@vfrz
Copy link
Owner

vfrz commented Dec 30, 2019

Thanks for your message.
So, basically, you'd like to set a default node/edge stlye on graph object? And then it's applied to every child without specified style?

@scottctr
Copy link
Author

Yes, I don't have a well thought out design, but here are some things to consider:

  • Breakout styles from DotNode, DotEdge, and DotSubGraph
    -- DotNodeStyle: Color, FontColor, FillColor, Shape, Style, Height
    -- DotEdgeStyle: Color, FontColor, ArrowHead, ArrowTail
    -- DotSubGraphStyle: Color, Style
  • DotNode, DotEdge, and DotSubGraph could have a very minimal default style, but would have an optional constructor param to override the default scale
  • DotGraph could implement the builder pattern to
    -- set default styles for nodes, edges, and subgraphs
    -- add nodes, edges, and subgraphs
    -- see psuedo code below
var myGraph = new DotGraph("myGraph", directed: true)
	.SetDefaultNodeStyle(new DotNodeStyle(Color.Red, Color.White, Color.Blue, DotNodeShape.Box, DotNodeStyle.Solid))
	.SetDefaultEdgeStyle(new DotEdgeStyle(Color.Orange, Color.White, DotEdgeArrowType.Normal, DotEdgeArrowType.Normal))
	.SetDefaultSubGraphStyle(new DotSubGraphStyle(Color.Gray, DotSubGraphStyleAttribute.Solid))
	// Add a node using default style above
	.AddNode("NodeA")
	// Add a node using a non-default style
	.AddNode("NodeB", new DotNodeStyle(...))
	// Add an edge using default style above
	.AddEdge("NodeA", "NodeB") // Should find above node elements by name; create new nodes if not found
	// add an edge using non-default style
	.AddEdge("NodeB", "NodeA", new DotEdgeStyle(...))
	//...same pattern for subgraphs

I hope this helps spur some ideas, but feel free to continue the discussion and put me to work once we have a design you're happy with.

@vfrz
Copy link
Owner

vfrz commented Jan 16, 2020

I like the idea of making styles separate object/class.
I will start some POC and make a draft PR to see how it goes.
Sorry for my late answer.

@vfrz vfrz mentioned this issue Jan 16, 2020
@vfrz vfrz added this to the 3.1 milestone Aug 8, 2023
@vfrz vfrz mentioned this issue Aug 8, 2023
4 tasks
Repository owner deleted a comment from officialarmannqureshi Feb 26, 2024
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