made charts resize when new data selected

split variable declarations and assignment