Don't filter out the latest data point in chart data sampling
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Aug 2016 23:22:05 +0000 (23:22 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Aug 2016 23:22:05 +0000 (23:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160714

Reviewed by Chris Dumez.

Exclude the last data point from sampling so that it's always included in the "sampled" charts data.
Without this, the last data point can change as we zoom out the time domain.

Luckily, we already had a mechanism to exclude the user selected point from sampling. Extend this
feature by supporting an array of point IDs instead of a single ID to exclude from filering.

* public/v3/components/interactive-time-series-chart.js:
(InteractiveTimeSeriesChart.prototype._sampleTimeSeries): Replaced exclusionPointID by excludedPoints.

* public/v3/components/time-series-chart.js:
(TimeSeriesChart.prototype._ensureSampledTimeSeries): Put the last data point in excludedPoints.
(TimeSeriesChart.prototype._sampleTimeSeries): Check point's id against the list of IDs.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204313 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/v3/components/interactive-time-series-chart.js
Websites/perf.webkit.org/public/v3/components/time-series-chart.js

index cf79d01..3d9ab61 100644 (file)
@@ -1,5 +1,25 @@
 2016-08-09  Ryosuke Niwa  <rniwa@webkit.org>
 
+        Don't filter out the latest data point in chart data sampling
+        https://bugs.webkit.org/show_bug.cgi?id=160714
+
+        Reviewed by Chris Dumez.
+
+        Exclude the last data point from sampling so that it's always included in the "sampled" charts data.
+        Without this, the last data point can change as we zoom out the time domain.
+
+        Luckily, we already had a mechanism to exclude the user selected point from sampling. Extend this
+        feature by supporting an array of point IDs instead of a single ID to exclude from filering.
+
+        * public/v3/components/interactive-time-series-chart.js:
+        (InteractiveTimeSeriesChart.prototype._sampleTimeSeries): Replaced exclusionPointID by excludedPoints. 
+
+        * public/v3/components/time-series-chart.js:
+        (TimeSeriesChart.prototype._ensureSampledTimeSeries): Put the last data point in excludedPoints.
+        (TimeSeriesChart.prototype._sampleTimeSeries): Check point's id against the list of IDs.
+
+2016-08-09  Ryosuke Niwa  <rniwa@webkit.org>
+
         Build fix after r204187. interval has to be a getter, not a method.
 
         * public/v3/components/time-series-chart.js:
index 7427c22..a71bc8d 100644 (file)
@@ -383,10 +383,11 @@ class InteractiveTimeSeriesChart extends TimeSeriesChart {
         return metrics;
     }
 
-    _sampleTimeSeries(data, maximumNumberOfPoints, exclusionPointID)
+    _sampleTimeSeries(data, maximumNumberOfPoints, excludedPoints)
     {
-        console.assert(!exclusionPointID);
-        return super._sampleTimeSeries(data, maximumNumberOfPoints, this._indicatorID);
+        if (this._indicatorID)
+            excludedPoints.push(this._indicatorID);
+        return super._sampleTimeSeries(data, maximumNumberOfPoints, excludedPoints);
     }
 
     _renderChartContent(context, metrics)
index 4ddd225..1ccf52a 100644 (file)
@@ -536,7 +536,7 @@ class TimeSeriesChart extends ComponentBase {
             if (!source.sampleData)
                 return filteredData;
             else
-                return self._sampleTimeSeries(filteredData, maximumNumberOfPoints);
+                return self._sampleTimeSeries(filteredData, maximumNumberOfPoints, filteredData.slice(-1).map(function (point) { return point.id; }));
         });
 
         Instrumentation.endMeasuringTime('TimeSeriesChart', 'ensureSampledTimeSeries');
@@ -547,7 +547,7 @@ class TimeSeriesChart extends ComponentBase {
         return true;
     }
 
-    _sampleTimeSeries(data, maximumNumberOfPoints, exclusionPointID)
+    _sampleTimeSeries(data, maximumNumberOfPoints, excludedPoints)
     {
         Instrumentation.startMeasuringTime('TimeSeriesChart', 'sampleTimeSeries');
 
@@ -571,7 +571,7 @@ class TimeSeriesChart extends ComponentBase {
             var j;
             for (j = i; j <= lastIndex; j++) {
                 var endPoint = data[j];
-                if (endPoint.id == exclusionPointID) {
+                if (excludedPoints.includes(endPoint.id)) {
                     j--;
                     break;
                 }