-
Notifications
You must be signed in to change notification settings - Fork 102
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
Pan/Scale to center graph? #7
Comments
Yes, have a look at https://github.com/magjac/d3-graphviz/blob/master/examples/demo-grow-entering-edges.html#L10. You might want to set x = y = 0; scale = 1.0 or optimize them out completely. Thanks for submitting this issue. If you are using this library, don't forget to "Watch" it to stay tuned for updates or even "Star" it if you like it. You can also use Stack Overflow tags d3.js & graphviz to ask for help. Although I make an effort to assist everyone that asks, I am not always available to provide help promptly or directly. |
That looks like it should work, I'll just need to calculate the scale based off the size of the graph vs container. Really appreciate the support, this is a great library and will watch for updates |
With apologies for this necropost (please feel free to direct me to post on this topic elsewhere), I've started looking into a "scale to fit" function, and have this early observation: in my browser's "developer tools" (I'm using latest Chrome on Windows 10), if I edit the d3-graphviz-generated In my case, the container is an HTML
For my purposes, this is a good default/initial view of the graph. Next, I'm going to look at how to remove those |
I'm now using a
I'd gratefully accept tips on improving this code. For example:
I deliberately ended up not using SVG
|
I'm afraid this might be a little over my head. I'll have a look at it during the weekend, but I do recommend you to use Stack Overflow to ask for help. Especially in this case, which does not seem to be d3-graphviz specific. In any case, a complete example would make it much easier to understand what you want to achieve and find a solution. See instructions below. Thanks for submitting this issue. If you are using this library, don't forget to "Watch" it to stay tuned for updates or even "Star" it if you like it. You can also use Stack Overflow tags d3.js & graphviz to ask for help. Although I make an effort to assist everyone that asks, I am not always available to provide help promptly or directly. When asking for help, please include a link to a live example that demonstrates the issue, preferably on JSFiddle. It is often impossible to debug from code snippets alone. Isolate the issue and reduce your code as much as possible before asking for help. The less code you post, the easier it is for someone to debug, and the more likely you are to get a helpful response. |
I'm reasonably happy with the behavior I get, now that I'm deleting the Regarding the |
@GrahamHannington No need to be sorry. I don't mind you posting here. It's just that I'm quite a Javascript noob myself and even more so an HTML, CSS and SVG noob, so I think you'd be better off asking at SO where there are plenty of non-noobs. That said, I am going to look at your post when I more time than I have right now. |
Regarding my question in an earlier comment:
I increasingly suspect that the answer is "yes". Why? Because I've moved on to experimenting with transitioning between DOT files (if that's acceptable terminology). I see the smooth animation between graphs (from the original DOT to the new DOT), but that animation occurs at the scale dictated by Is there an |
I've tried all of the I'd appreciate advice here. I can see myself having to go back to the drawing board and rethink how I'm zooming to fit. But I really like how removing those |
You must use the .attributer() method to also update the data as described in the documentation. More precisely this line is needed. During transitions, all attributes of every element in the graph is updated from the data. Explicitly modified attributes will be overwritten. |
@GrahamHannington I've look at your detailed questions above and you're clearly more knowledgeable than me regarding HTML and CSS. I don't think I can contribute with any insights without extensive research and learning. I will however help you with the "zoom to fit" function if you provide a complete example on Stack Overflow. Please use both the d3.js and graphviz tags. I look at that combination every day. |
@badams @GrahamHannington: In v2.2.0 I've added support for resizing the SVG and fit and scale the graph within it without the need to use the attributer. Feel free to contact me on Slack if there's something you want to discuss. |
Is there any way to center the graph on the canvas and scale it to fit (if its too large), I imagine this would be done with the attributer somehow
The text was updated successfully, but these errors were encountered: