Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save danpette/aec02c1a7a7fbaaf299b to your computer and use it in GitHub Desktop.
Save danpette/aec02c1a7a7fbaaf299b to your computer and use it in GitHub Desktop.
//graph1, graph2 are Chart instance
//modal is a global modal = $(this); from within $('.yourdiv').on('shown', function(event){ ....
//generateChart is method setting graph1 to new Chart.
//if dynamic/many charts make this dynamic, in this example i will always try to load both tabs, logic for only generating current should be implementet :)
$('#statistics-tabs a').click(function (e) {
e.preventDefault();
$(this).tab('show');
setTimeout(function(){
if(graph1 != undefined) graph1.destroy();
if(graph2 != undefined) graph2.destroy();
$('#graph1').attr('height',300).attr('width',868);
$('#graph2').attr('height',300).attr('width',868);
generateChart(modal, '1');
generateChart(modal, '2');
}, 500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment