Giter Club home page Giter Club logo

Comments (7)

jorgenunezsiri avatar jorgenunezsiri commented on May 13, 2024 1

Hello @nicgirault, sorry for the late reply. The issue is that having the structure svg > div > svg or div > div > svg is not valid for adding zooming to the main container. So, I was able to add zooming by removing the div container, and changing the main container to svg. Solving it is as easy as going to these lines and changing them to:

const container = select(this.conf.container)

This small change will allow users to have SVG containers in their applications, by giving an id to an svg element instead of a div. Then, you should get the expected zooming by adding the following to the SVG:

svg.call(d3.zoom().on("zoom", function() {
  svg.attr("transform", d3.event.transform)
}));

There is more information about having an SVG container in the other discussion here.

from circosjs.

jorgenunezsiri avatar jorgenunezsiri commented on May 13, 2024 1

@matthewchan15 Sorry, I did not understand you before. You should be specifying the zoom call in your application, after creating the svg parent container (the same container that you use to create the Circos instance). Make sure you attach the zoom call to that parent container. Then, that svg is going to include an inner svg (coming from circos.js). The zoom should be working because the structure will be svg > svg, instead of svg > div > svg.

from circosjs.

mtwichan avatar mtwichan commented on May 13, 2024 1

@jnunez17 The issue was that I wrongly assumed that d3-zoom was included in the package,json. Once I installed it, everything worked wonderfully 👍

from circosjs.

nicgirault avatar nicgirault commented on May 13, 2024

Hi @jnunez17 sorry for the late answer. I don't know at all how zoom is working so I won't be able to help you without digging into the subject. I let the issue open so that I will work on it next time I maintain this project. If you found a solution, I would be really glad if you can share it so that I could add it to the documentation of this project.

from circosjs.

mtwichan avatar mtwichan commented on May 13, 2024

@jnunez17 Do you mind posting a code snippet on how you implemented this? I've been trying to make it work with react but I keep getting this error:

Uncaught TypeError: Cannot read property 'button' of null

Thank you!

from circosjs.

jorgenunezsiri avatar jorgenunezsiri commented on May 13, 2024

@matthewchan15 That does not seem to be an issue with the zoom itself, but with something you are missing for getting it to work, possibly how you are importing the d3 modules. One thing you can try is importing the whole d3 library at the top of your script (import * as d3 from 'd3';), and if that fixes your issue then perhaps you are missing a specific d3 module (in case you were importing them separately).

For the zoom, it should work just by removing the extra div container from the library and then calling the zoom event transform on the outer svg. I'm explaining the issue and the steps with more detail in my previous comment.

from circosjs.

mtwichan avatar mtwichan commented on May 13, 2024

@jnunez17 Ah yes I tried import * as d3 from 'd3';, as well as this method import {select} from 'd3-selection' (example). I am using the d3 package provided in this library with package.json -> https://github.com/nicgirault/circosJS/blob/master/package.json.

I think there may be a misunderstanding on my part. Did you specify this block of code in circos.js (this is what I'm trying to do) or when you were creating your instance such as in the first comment you posted?

svg.call(d3.zoom().on("zoom", function() {
  svg.attr("transform", d3.event.transform)
}));

from circosjs.

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.