refactoring rating visualization JS