Add logic function for charts