some refactoring plus extra tests
some refactoring on the chart function
tests for bar charter