Giter Club home page Giter Club logo

Comments (10)

magjac avatar magjac commented on May 18, 2024 1

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.

GrahamHannington avatar GrahamHannington commented on May 18, 2024 1

Thank you! I'm now using a .renderDot callback successfully in v1.1.0

from d3-graphviz.

GrahamHannington avatar GrahamHannington commented on May 18, 2024

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.

GrahamHannington avatar GrahamHannington commented on May 18, 2024

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.

magjac avatar magjac commented on May 18, 2024

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.

magjac avatar magjac commented on May 18, 2024

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.

magjac avatar magjac commented on May 18, 2024

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.

magjac avatar magjac commented on May 18, 2024

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.

GrahamHannington avatar GrahamHannington commented on May 18, 2024

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.

magjac avatar magjac commented on May 18, 2024

Released in v1.1.0

from d3-graphviz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.