refactor line chart in graph controller