updated constructor to handle multiple instances of barchart class