Comments (10)
I'll look into this issue in the nearest couple of days. I the meantime, you can use:
d3.select("#graph").graphviz().renderDot(data).on("end", function() {console.log("Ended")});
See this example.
Regarding the "zoom to fit" function, you might want to use the .attributer()
method instead of a callback. See #7
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.
from d3-graphviz.
Thank you! I'm now using a .renderDot
callback successfully in v1.1.0
from d3-graphviz.
Thanks for the quick reply. I should have mentioned this in my initial report: .on("end")...
doesn't work for me, either. Makes me think I'm doing something wrong, but the DOT renders just fine.
from d3-graphviz.
Re: "zoom to fit"
I can see that the D3 V4 dynamic (mouse-driven) panning and zooming updates the transform
attribute of the SVG g
element that was generated by d3-graphviz:
<div id="graph">
<svg width="2445pt" height="1538pt" viewBox="0.00 0.00 2445.00 1538.36" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="translate(43.842239806463624,1357.7823048955277) scale(0.8705505632961241)">
This makes me think that any "zoom to fit" function should update that transform
attribute of the g
element, too, to "play nice" with the dynamic D3 panning and zooming. (Although I'm scratching my head over how to calculate an appropriate value to fit the g
to the viewport. I'll be reading some SVG documentation tonight.)
However, the attributer
example you pointed me to (thanks!) targets the svg
element (parent of that g
element).
Your thoughts?
from d3-graphviz.
Maybe I misunderstood. I meant an initial zoom to fit the generated graph, from which the user can zoom in or out, but now I realize that you probably meant a user-initiated function that fits the graph regardless of its original size and current zoom level.
I think however, that they can be combined. I'll look into it late tonight CET (I'm coding for money during the day).
from d3-graphviz.
On my phone so I can’t test it, but the callback/ event seems to fire only when a transition is used. As a workaround, try using a dummy transition with a duration of 0.
And yes, the invalid asm.js is unrelated. It’s a known viz.js issue: mdaines/viz-js#96
from d3-graphviz.
Tested this workaround ok:
d3.select("#graph").graphviz()
.transition("dummy")
.renderDot('digraph {a -> b}', function () {
console.log('Callback');
})
.on("end", function () {
console.log('"end" event');
});
from d3-graphviz.
I've pushed a fix for this bug in 1277bd2. Do you need a new release or do you install locally?
Also, can I ask you to post a question on Stack Overflow using the tags d3.js and graphviz if you still need help with the "zoom to fit" function? It's a better place to answer questions. I've started to work on it, but now I must call it a day.
from d3-graphviz.
I'm sincerely grateful for your help.
A new release would be great. Right now, I'm being "lazy", and just doing this:
<script src="https://unpkg.com/[email protected]/build/d3-graphviz.min.js"></script>
I'm concentrating on tweaking the program that generates the DOT file.
Yes, if I can't work it out myself in the next day or so, I'll post a question on Stack Overflow about the "zoom to fit" function.
I meant an initial zoom to fit the generated graph ... I think however, that they can be combined.
Yes, I had in mind a single function that could be called at initial "render time", and then called later whenever the user clicks a "Fit" button.
from d3-graphviz.
Released in v1.1.0
from d3-graphviz.
Related Issues (20)
- can not run in react project HOT 3
- Cannot find wasm files HOT 3
- how can i get the current scale? HOT 1
- Failed to resolve entry for package "d3-graphviz" HOT 11
- Git Release missing HOT 1
- not render with this renderDot HOT 5
- Can u produce a v5 sample? HOT 1
- graphvizlib.wasm missing in 5.0 HOT 1
- Multiple graphs within same SVG HOT 2
- Modify node shape from javascript HOT 1
- Have you considered writing an accompanying drag-and-drop node feature? HOT 3
- When is it appropriate to upgrade from v4 to v5? HOT 1
- Can not draw an edge in the graph HOT 2
- Can't render special dot string and get uncaught error in Console HOT 7
- The graph is not being displayed
- Enable d3-graphviz API to set graph attributes in the DOT source HOT 2
- Transition type error in typescript HOT 2
- Upgrade examples to library version 5.x HOT 2
- webpack4 throw cannot resolve "@hpcc-js/wasm/graphviz"
- Render transitive reduction filter directed graph HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-graphviz.