Fixing problem with charts in javascript