I'm resizing the page by clicking 'menu toggle button', but when am doing so the Morris charts are not resized, I tried to trigger it, but its not working.
I added a line of code in my js $(window).trigger('resize');
but this dint worked. can any body help me? as I'm not aware of resize option in jQuery.
Thanks -Riot Zeast Captain
html:
<div id="area-chart" class="col-sm-12"></div>
Make a variable and all Morris chart initialization you required but make sure not to include the following properties while initializing Morris chart redraw: true
and resize: true
var bar = Morris.Bar({......});
Here the jquery resize function magic which trigger when ever div resizes no need to trigger window resize.
$('#area-chart').resize(function () {
bar.redraw();
});
Whenever DIV resize the Morris Chart automatically fit to it's parent DIV which is col-sm-6
.
This solution give you the size of chart according to the parent div size.
You don't need to add click function also.