refactoring for a simpler function
add more test and fix bug in corner cases
fix test and generation function
add generation of a full bar chart
fix html code for better display