working Chart, and fix some bugs