Updated code to return the correct data near the time boundaries for the charts.