public function getAnnotationCountForDates($idSite, $date, $period, $lastN = false, $getAnnotationText = false)
    {
        Piwik::checkUserHasViewAccess($idSite);

        // get start & end date for request. lastN is ignored if $period == 'range'
        list($startDate, $endDate) = self::getDateRangeForPeriod($date, $period, $lastN);
        if ($period == 'range') {
            $period = 'day';
        }

        // create list of dates
        $dates = array();
        for (; $startDate->getTimestamp() <= $endDate->getTimestamp(); $startDate = $startDate->addPeriod(1, $period)) {
            $dates[] = $startDate;
        }
        // we add one for the end of the last period (used in for loop below to bound annotation dates)
        $dates[] = $startDate;

        // get annotations for the site
        $annotations = new AnnotationList($idSite);

        // create result w/ 0-counts
        $result = array();
        for ($i = 0; $i != count($dates) - 1; ++$i) {
            $date = $dates[$i];
            $nextDate = $dates[$i + 1];
            $strDate = $date->toString();

            foreach ($annotations->getIdSites() as $idSite) {
                $result[$idSite][$strDate] = $annotations->count($idSite, $date, $nextDate);

                // if only one annotation, return the one annotation's text w/ the counts
                if ($getAnnotationText
                    && $result[$idSite][$strDate]['count'] == 1
                ) {
                    $annotationsForSite = $annotations->search(
                        $date, Date::factory($nextDate->getTimestamp() - 1), $idSite);
                    $annotation = reset($annotationsForSite[$idSite]);

                    $result[$idSite][$strDate]['note'] = $annotation['note'];
                }
            }
        }

        // convert associative array into array of pairs (so it can be traversed by index)
        $pairResult = array();
        foreach ($result as $idSite => $counts) {
            foreach ($counts as $date => $count) {
                $pairResult[$idSite][] = array($date, $count);
            }
        }
        return $pairResult;
    }