Skip to content

Instantly share code, notes, and snippets.

@BJTerry
Last active August 29, 2015 14:09
Show Gist options
  • Save BJTerry/e0d55197ccf18ea562f9 to your computer and use it in GitHub Desktop.
Save BJTerry/e0d55197ccf18ea562f9 to your computer and use it in GitHub Desktop.
Workaround example for highmaps media query issue
// Workaround for https://github.com/highslide-software/highcharts.com/issues/3385
// Uses default bootstrap media query sizes.
// display_heatmap is a function that displays the heatmap once the map data has been downloaded.
// Requires enquire.js (http://wicky.nillia.ms/enquire.js/)
// Download map data and save the jqXHR promise.
var states_promise = jQuery.getJSON('http://blog.statricks.com/media/system/maps/US.min.json', {});
// Use enquire to re-render the heatmap if we change browser width
enquire.register("(max-width: 767px)", {
match: function(){
states_promise.done(display_heatmap);
}
});
enquire.register("(min-width: 768px) and (max-width: 991px)", {
match: function(){
states_promise.done(display_heatmap);
}
});
enquire.register("(min-width: 992px) and (max-width: 1199px)", {
match: function(){
states_promise.done(display_heatmap);
}
});
enquire.register("(min-width: 1200px)", {
match: function(){
states_promise.done(display_heatmap);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment