Last active
September 9, 2015 22:08
-
-
Save refactornator/de5d88ea4c540611d888 to your computer and use it in GitHub Desktop.
Zoomdata Javascript SDK Resize Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This example illustrates listening to the window resize event and triggering a visualization to be resized. | |
*/ | |
var visualization, | |
el = document.getElementById('visualization'); | |
var zoomdataClient = new ZoomdataClient({ | |
apiKey: 'YOUR API KEY', | |
host: 'localhost:8080/zoomdata', | |
secure: false | |
}); | |
zoomdataClient.visualize({ | |
visualization: 'Horizontal Bars by Make', | |
source: 'Real Time Sales', | |
element: el | |
}).done(function(vis) { | |
visualization = vis; | |
}); | |
// Add a resize handler to trigger this callback whenever the window is resized. | |
window.addEventListener('resize', function(event){ | |
// Get the width and height of the element that the visualization was attached to. | |
var width = el.getBoundingClientRect().width, | |
height = el.getBoundingClientRect().height; | |
// Pass the new width and height as parameters to the 'resize' function. | |
visualization.controller._controller.resize(width, height); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment