+2015-02-04 Ryosuke Niwa <rniwa@webkit.org>
+
+ Interactive chart component provides two duplicate API for highlighting points
+ https://bugs.webkit.org/show_bug.cgi?id=141234
+
+ Reviewed by Chris Dumez.
+
+ Prior to this patch, the interactive chart component supported highlightedItems for finding commits
+ on the main charts page and markedPoints to show the two end points in the analysis task page.
+
+ This patch merges markedPoints into highlightedItems.
+
+ * public/v2/app.js:
+ (App.AnalysisTaskController._fetchedRuns): Use highlightedItems.
+ * public/v2/chart-pane.css:
+ * public/v2/index.html: Ditto.
+ * public/v2/interactive-chart.js:
+ (App.InteractiveChartComponent._constructGraphIfPossible): Make this._highlights an array instead of
+ array of arrays. Also call _highlightedItemsChanged at the end to fix the bug that we never highlight
+ items if highlightedItems was set before the initial layout.
+ (App.InteractiveChartComponent._relayoutDataAndAxes):
+ (App.InteractiveChartComponent._updateHighlightPositions): Now that highlights are circles instead of
+ vertical lines, just set cx and cy as done for other "dots".
+ (App.InteractiveChartComponent._highlightedItemsChanged): Exit early only if _clippedContainer wasn't
+ already set; i.e. _constructGraphIfPossible hasn't been called. Also updated the logic to accommodate
+ the fact this._highlights is an array of elements instead of an array of arrays of elements. Finally,
+ set the radius of highlight circles here.
+
2015-02-03 Ryosuke Niwa <rniwa@webkit.org>
Don’t use repository names as id’s.
if (!start || !end)
return; // FIXME: Report an error.
- var markedPoints = {};
- markedPoints[start.measurement.id()] = true;
- markedPoints[end.measurement.id()] = true;
+ var highlightedItems = {};
+ highlightedItems[start.measurement.id()] = true;
+ highlightedItems[end.measurement.id()] = true;
var formatedPoints = currentTimeSeries.seriesBetweenPoints(start, end).map(function (point, index) {
return {
var margin = (end.time - start.time) * 0.1;
this.set('chartData', runs);
this.set('chartDomain', [start.time - margin, +end.time + margin]);
- this.set('markedPoints', markedPoints);
+ this.set('highlightedItems', highlightedItems);
this.set('analysisPoints', formatedPoints);
},
testSets: function ()
this._dots.forEach(function (dot) { dots.remove(); });
this._dots = [];
if (this._highlights)
- this._highlights.forEach(function (highlight) { highlight.remove(); });
- this._highlights = [];
+ this._highlights.remove();
+ this._highlights = null;
this._currentTimeSeries = chartData.current.timeSeriesByCommitTime();
this._currentTimeSeriesData = this._currentTimeSeries.series();
this._needsConstruction = false;
+ this._highlightedItemsChanged();
this._rangesChanged();
},
_updateDomain: function ()
.attr("cx", function(measurement) { return xScale(measurement.time); })
.attr("cy", function(measurement) { return yScale(measurement.value); });
});
- this._updateMarkedDots();
this._updateHighlightPositions();
this._updateRangeBarRects();
.style("z-index", "100")
.text(this._yAxisUnit);
},
- _updateMarkedDots: function () {
- var markedPoints = this.get('markedPoints') || {};
- var defaultDotRadius = this.get('chartPointRadius') || 1;
- this._dots.forEach(function (dot) {
- dot.classed('marked', function (point) { return markedPoints[point.measurement.id()]; });
- dot.attr('r', function (point) {
- return markedPoints[point.measurement.id()] ? defaultDotRadius * 1.5 : defaultDotRadius; });
- });
- }.observes('markedPoints'),
_updateHighlightPositions: function () {
+ if (!this._highlights)
+ return;
+
var xScale = this._x;
var yScale = this._y;
- var y2 = this._margin.top + this._contentHeight;
- this._highlights.forEach(function (highlight) {
- highlight
- .attr("y1", 0)
- .attr("y2", y2)
- .attr("y", function(measurement) { return yScale(measurement.value); })
- .attr("x1", function(measurement) { return xScale(measurement.time); })
- .attr("x2", function(measurement) { return xScale(measurement.time); });
- });
+ this._highlights
+ .attr("cy", function(point) { return yScale(point.value); })
+ .attr("cx", function(point) { return xScale(point.time); });
},
_computeXAxisDomain: function (timeSeries)
{
}
}.observes('selectedItem').on('init'),
_highlightedItemsChanged: function () {
- if (!this._margin)
+ if (!this._clippedContainer)
return;
var highlightedItems = this.get('highlightedItems');
var data = this._currentTimeSeriesData.filter(function (item) { return highlightedItems[item.measurement.id()]; });
- if (this._highlights.length)
- this._highlights.forEach(function (highlight) { highlight.remove(); });
-
- this._highlights.push(this._clippedContainer
+ if (this._highlights)
+ this._highlights.remove();
+ this._highlights = this._clippedContainer
.selectAll(".highlight")
.data(data)
- .enter().append("line")
- .attr("class", "highlight"));
+ .enter().append("circle")
+ .attr("class", "highlight")
+ .attr("r", (this.get('chartPointRadius') || 1) * 1.8);
this._updateHighlightPositions();
-
}.observes('highlightedItems'),
_rangesChanged: function ()
{