Refactor js and update rank history diagram