Mourad Qqch Mourad Qqch - 7 months ago 95
Javascript Question

How to set options in vis js?

How can I set options in my network using Vis.js library ?

I can't find any answer.
Everyone say :

network.setOptions(options);


But I do not understand. How can I edit these options ?

I want to toggle the zoomView in the network.

$("#zoom-network").click(function(e) {
// what to do here ?
network.setOptions(options);
});


EDIT
Thanks to AlexP, I found the answer :

$("#zoom-network").click(function(e) {
var options = {
interaction : {
zoomView : true
}
};
network.setOptions(options);
});

Answer

For animations like zooming you have to use .moveTo

$("#zoom-network").click(function(e) { 
    var options = { 
      scale: 1.5,
      animation: {      
        duration: 1000,
        easingFunction: "easeInOutQuad"
      }
    }
    network.moveTo(options); 
});
Comments