Comments (9)
Is there a way to turn off zooming?
from vivagraphjs.
@arikan there is no build-in way to do this yet. The way I'm doing it in Amazon visualization is very cumbersome. I had to create a separate group layer g
in the svg graphics root, and add all labels there. The I had to listen to rescaled events from the graphics class (Viva.Graph.Utils.events(graphics).on('rescaled' function(){...}
) and use getTransformToElement()
/getBBox()
methods to update tooltip position.
I admit SVG support is purely designed part of the library. I putting myself a todo to make it better. Sorry about this.
from vivagraphjs.
@henry74 there is no way to do this, if you are using renderer. I'm trying to understand your use case better. Do you need other interactive features of the renderer (e.g. panning, unified support of multiple graphics objects, graph change monitoring)? Or do you want to produce layout once and use it as a static structure?
from vivagraphjs.
I found a simple work around. My use case was to just prevent zooming of the graph since it detracted from the user experience.
I just captured the mousewheel event for the parent svg tag and return false. No mouse accidental mouse scroll zooming :-)
from vivagraphjs.
@henry74 very nice :)!
from vivagraphjs.
@henry74 I need to prevent the mouse wheel scroll as well, I tried many things, but no luck, can you share a snippet.
For example this does NOT work:
document.body.addEventListener('DOMMouseScroll', function(e){
e.preventDefault();
}, false);
from vivagraphjs.
Related to this, would there a way to set a max/min zoom level? Max zoom being something like 'fit all to screen' level.
from vivagraphjs.
Old question, but I was able to prevent zooming and thought I'd share a snippet of my solution/workaround incase anyone has the same problem(solution in Coffeescript):
renderer.run() # the SVG element is created when the renderer is run
svgElement = renderer.getGraphics().getGraphicsRoot() # Temporary var containing SVG element
$(svgElement.bind( 'mousewheel DOMMouseScroll', (e) ->
if e.shiftKey isnt true #Zoom only if shift key is being held down
e.preventDefault() # Prevent zooming
return false
)
from vivagraphjs.
Thank you @joerodrig3!
A small note about renderer.run()
. You mentioned that SVG element is created when the renderer is run. This was fixed in version v0.5.8
, and now you can call getGraphicsRoot()
from graphics object as soon as it is created, no need to execute renderer.run()
beforehand.
from vivagraphjs.
Related Issues (20)
- Feedback
- how many nodes can this graph support
- Feedback - WebAssembly
- Cannot render graph HOT 2
- Documentation?
- Bug with links
- Go to the link by clicking on the node. HOT 1
- Adding text label functionality HOT 4
- render images on nodes instead of squares
- ngraph dependencies and other dependencies versions
- Messaging between nodes' position to optimise layout
- Request to be added to the list of examples
- how to make hyperlink <a href > from node
- How to fix nodes coordinates
- when you click on an object it jumps
- Performance is not good!
- change image in webgl graph node
- Extend Options to add Custom Force-Directed Layouts
- Node icon images turn to green when nodes number exceed 15,000.
- Custom nodes get stacked on top of each other HOT 1
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 vivagraphjs.