nullify the current Highchart when modal closed

This commit is contained in:
Stephen Birarda 2015-05-01 16:21:05 -07:00
parent 6d0e612923
commit 7b4522e950

View file

@ -32,7 +32,7 @@ $(document).ready(function(){
// start shifting the chart once we hit 20 data points // start shifting the chart once we hit 20 data points
var shift = currentHighchart.series[0].data.length > 20; var shift = currentHighchart.series[0].data.length > 20;
currentHighchart.series[0].addPoint([x, y], true, shift); currentHighchart.series[0].addPoint([x, y], true, shift);
} }
}).fail(function(data) { }).fail(function(data) {
$('#stats-container th').each(function(){ $('#stats-container th').each(function(){
$(this).addClass('stale'); $(this).addClass('stale');
@ -56,13 +56,18 @@ $(document).ready(function(){
// add a function to help create the graph modal // add a function to help create the graph modal
function createGraphModal() { function createGraphModal() {
bootbox.dialog({ var chartModal = bootbox.dialog({
title: graphKeypath, title: graphKeypath,
message: "<div id='highchart-container'></div>", message: "<div id='highchart-container'></div>",
buttons: {}, buttons: {},
className: 'highchart-modal' className: 'highchart-modal'
}); });
chartModal.on('hidden.bs.modal', function(e) {
currentHighchart.destroy();
currentHighchart = null;
});
currentHighchart = new Highcharts.Chart({ currentHighchart = new Highcharts.Chart({
chart: { chart: {
renderTo: 'highchart-container', renderTo: 'highchart-container',