from = new DateTime(Long.parseLong(firstTimestamp) * 1000, DateTimeZone.UTC);
} else {
from = DateTime.parse(histogram.getHistogramBoundaries().getFrom());
}
final DateTime to = DateTime.parse(histogram.getHistogramBoundaries().getTo());
final MutableDateTime currentTime = new MutableDateTime(from);
final Duration step = estimateIntervalStep(histogram.getInterval());
final int dataPoints = (int) ((to.getMillis() - from.getMillis()) / step.getMillis());
// using the absolute value guarantees, that there will always be enough values for the given resolution
final int factor = (maxDataPoints != -1 && dataPoints > maxDataPoints) ? dataPoints / maxDataPoints : 1;
int index = 0;
floorToBeginningOfInterval(histogram.getInterval(), currentTime);
while (currentTime.isBefore(to) || currentTime.isEqual(to)) {
if (index % factor == 0) {
String timestamp = Long.toString(currentTime.getMillis() / 1000);
Long result = histogramResults.get(timestamp);
Map<String, Long> point = Maps.newHashMap();
point.put("x", Long.parseLong(timestamp));
point.put("y", result != null ? result : 0);
points.add(point);