PDA

View Full Version : Toggle legend with chart resize



marcin.sielski
15 Sep 2015, 7:46 AM
Hi guys,
I'm struggling with toggle a legend. I want to turn off the legend to give the chart series more space.

I've created a checkbox control and in its handler fn I've placed this code:



var chart = Ext.getCmp('myChart');
if ( checked === true ) {
chart.legend.toggle(true);
} else {
chart.legend.toggle(false);
}
chart.redraw();


This just turn off/on the legend and don't resize chart (the size of series area).
The code below works but with error in FireFox (whole chart is sliding to left):



var chart = Ext.getCmp('myChart');
chart.hide();
chart.redraw(); //chart size = Nan (in firefox error)
if ( checked === true ) {
chart.legend.toggle(true);
} else {
chart.legend.toggle(false);
}
chart.show();
chart.redraw();


Nonetheless it's wrong way to resize chart when legend is on/off, but I realize that in FF.
The error doesn't appear (second code with hide-redraw-show-redraw) when hideMode is set to 'offsets' or 'visibility', but at this settings the series space doesn't resize to the chart space (the legend is just turned off).

I've tried many variations of fn (resize, redraw, render, hide, show, etc) but haven't found the solution. Any idea?

Thanks for help!

Marcin

Gary Schlosberg
15 Sep 2015, 10:59 AM
Looks like this is an existing issue (as you've found):
https://www.sencha.com/forum/showthread.php?282882

I added a note to the bug ticket so hopefully we can get this one fixed soon.

marcin.sielski
15 Sep 2015, 11:15 AM
So I belive (since it's a old issue and still not solved) is better to avoid this method (hide-redraw) in FF.