build chart automatically when a plot is changed