Giter Site home page Giter Site logo

Registering click handlers about d3-parsets HOT 6 CLOSED

itay avatar itay commented on August 23, 2024
Registering click handlers

from d3-parsets.

Comments (6)

jasondavies avatar jasondavies commented on August 23, 2024

How about selecting elements after creating the chart, and adding the handlers there. Does that not work for you?

from d3-parsets.

itay avatar itay commented on August 23, 2024

What should be the argument to the select? i.e. what nodes/classes should we select on and then bind?

I guess my higher level thought is that since parsets wraps the entire rendering, then it should provide these methods, in order to not break them in the future (e.g. if you changed the internal implementation). However, if you have something else in mind, that might be better.

from d3-parsets.

jasondavies avatar jasondavies commented on August 23, 2024

I guess the classes and elements generated by the chart are also part of the API, so “post-selection” is a reasonable way to customise the output further. A similar approach is taken by D3’s components, such as d3.svg.brush and d3.svg.axis; you can customise elements or add event handlers after generating the initial elements.

For d3-parsets, which elements you should select depends on your usage scenario; there should be suitable classes on most elements that you can find by inspecting your chart in a browser, or examining the code. If you think they could be improved, do let me know!

from d3-parsets.

itay avatar itay commented on August 23, 2024

Sounds good to me - I'll reopen this if you ever change the inner DOM structure :)

Thanks, awesome work.

from d3-parsets.

jasondavies avatar jasondavies commented on August 23, 2024

By the way, I just noticed that not all of my event listeners were namespaced, so I’ve just pushed a fix.

from d3-parsets.

itay avatar itay commented on August 23, 2024

By the way, for those curious about how to do this, here is our code that gets the event and then generates a new one with a different structure (graph is our root svg):

        graph.selectAll("g.ribbon-mouse path")
            .on("click", function(e) {
                that.trigger('click', {
                    source: e.source.node.name,
                    sourceDimension: e.source.node.dimension.name,
                    target: e.target.node.name,
                    targetDimension: e.target.node.dimension.name,
                    dimension: e.dimension,
                    value: e.count
                });
            });

from d3-parsets.

Related Issues (12)

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.