2016-01-06 Ryosuke Niwa <rniwa@webkit.org>
+ The sampling of time series on v3 UI is too aggressive
+ https://bugs.webkit.org/show_bug.cgi?id=152804
+
+ Reviewed by Chris Dumez.
+
+ Fixed a bug that we were always halving the number of data points in _sampleTimeSeries
+ and increased the number of data points allowed to make the sampling less aggressive.
+
+ * public/v3/components/time-series-chart.js:
+ (TimeSeriesChart.prototype._ensureSampledTimeSeries): Increase the number of maximum points
+ to 2x the number of pixels divided by the radius of each point.
+ (TimeSeriesChart.prototype._sampleTimeSeries.findMedian): Changed the semantics of endIndex
+ to mean the index after the last point and renamed it to indexAfterEnd.
+ (TimeSeriesChart.prototype._sampleTimeSeries): Fixed a bug that this code always coerced two
+ data points into one sampled data point despite of the fact i and j are sufficiently apart
+ since data[j].time - data[i].time > timePerSample by definition.
+
+2016-01-06 Ryosuke Niwa <rniwa@webkit.org>
+
Commit the forgotten change for r194651.
* public/v3/pages/domain-control-toolbar.js:
if (!timeSeries)
return null;
- // A chart with X px width shouldn't have more than X / <radius-of-points> data points.
- var maximumNumberOfPoints = metrics.chartWidth / source.pointRadius;
+ // A chart with X px width shouldn't have more than 2X / <radius-of-points> data points.
+ var maximumNumberOfPoints = 2 * metrics.chartWidth / source.pointRadius;
var pointAfterStart = timeSeries.findPointAfterTime(startTime);
var pointBeforeStart = (pointAfterStart ? timeSeries.previousPoint(pointAfterStart) : null) || timeSeries.firstPoint();
// FIXME: Move this to TimeSeries.prototype.
var filteredData = timeSeries.dataBetweenPoints(pointBeforeStart, pointAfterEnd);
- if (filteredData.length <= maximumNumberOfPoints || !source.sampleData)
+ if (!source.sampleData)
return filteredData;
else
return self._sampleTimeSeries(filteredData, maximumNumberOfPoints);
Instrumentation.startMeasuringTime('TimeSeriesChart', 'sampleTimeSeries');
// FIXME: Do this in O(n) using quickselect: https://en.wikipedia.org/wiki/Quickselect
- function findMedian(list, startIndex, endIndex)
+ function findMedian(list, startIndex, indexAfterEnd)
{
- var sortedList = list.slice(startIndex, endIndex + 1).sort(function (a, b) { return a.value - b.value; });
+ var sortedList = list.slice(startIndex, indexAfterEnd).sort(function (a, b) { return a.value - b.value; });
return sortedList[Math.floor(sortedList.length / 2)];
}
if (endPoint.time - startPoint.time >= timePerSample)
break;
}
- if (i < j) {
+ if (i < j - 1) {
sampledData.push(findMedian(data, i, j));
- i = j + 1;
+ i = j;
} else {
sampledData.push(startPoint);
i++;