Help with Chart Component

Just saw that you did the casting it in your date query. Can you iterate through the list and do it in a script instead with the function I mentioned above?