Refactoring for generic/responsive bar and pie charts