1 window.App = Ember.Application.create();
3 App.Router.map(function () {
4 this.resource('charts', {path: 'charts'});
5 this.resource('analysis', {path: 'analysis'});
6 this.resource('analysisTask', {path: 'analysis/task/:taskId'});
9 App.DashboardRow = Ember.Object.extend({
17 var cellsInfo = this.get('cellsInfo') || [];
18 var columnCount = this.get('columnCount');
19 while (cellsInfo.length < columnCount)
22 this.set('cells', cellsInfo.map(this._createPane.bind(this)));
24 addPane: function (paneInfo)
26 var pane = this._createPane(paneInfo);
27 this.get('cells').pushObject(pane);
28 this.set('columnCount', this.get('columnCount') + 1);
30 _createPane: function (paneInfo)
32 if (!paneInfo || !paneInfo.length || (!paneInfo[0] && !paneInfo[1]))
35 var pane = App.Pane.create({
36 store: this.get('store'),
37 platformId: paneInfo ? paneInfo[0] : null,
38 metricId: paneInfo ? paneInfo[1] : null,
41 return App.DashboardPaneProxyForPicker.create({content: pane});
45 App.DashboardPaneProxyForPicker = Ember.ObjectProxy.extend({
46 _platformOrMetricIdChanged: function ()
49 App.buildPopup(this.get('store'), 'choosePane', this)
50 .then(function (platforms) { self.set('pickerData', platforms); });
51 }.observes('platformId', 'metricId').on('init'),
52 paneList: function () {
53 return App.encodePrettifiedJSON([[this.get('platformId'), this.get('metricId'), null, null, false]]);
54 }.property('platformId', 'metricId'),
57 App.IndexController = Ember.Controller.extend({
58 queryParams: ['grid', 'numberOfDays'],
66 gridChanged: function ()
68 var grid = this.get('grid');
69 if (grid === this._previousGrid)
75 table = JSON.parse(grid);
77 console.log("Failed to parse the grid:", error, grid);
80 if (!table || !table.length) // FIXME: We should fetch this from the manifest.
81 table = this.get('defaultTable');
83 table = this._normalizeTable(table);
84 var columnCount = table[0].length;
85 this.set('columnCount', columnCount);
87 this.set('headerColumns', table[0].map(function (name, index) {
88 return {label:name, index: index};
91 var store = this.store;
92 this.set('rows', table.slice(1).map(function (rowParam) {
93 return App.DashboardRow.create({
96 cellsInfo: rowParam.slice(1),
97 columnCount: columnCount,
101 this.set('emptyRow', new Array(columnCount));
102 }.observes('grid').on('init'),
104 _normalizeTable: function (table)
106 var maxColumnCount = Math.max(table.map(function (column) { return column.length; }));
107 for (var i = 1; i < table.length; i++) {
109 for (var j = 1; j < row.length; j++) {
110 if (row[j] && !(row[j] instanceof Array)) {
111 console.log('Unrecognized (platform, metric) pair at column ' + i + ' row ' + j + ':' + row[j]);
119 updateGrid: function()
121 var headers = this.get('headerColumns').map(function (header) { return header.label; });
122 var table = [headers].concat(this.get('rows').map(function (row) {
123 return [row.get('header')].concat(row.get('cells').map(function (pane) {
124 var platformAndMetric = [pane.get('platformId'), pane.get('metricId')];
125 return platformAndMetric[0] || platformAndMetric[1] ? platformAndMetric : [];
128 this._previousGrid = JSON.stringify(table);
129 this.set('grid', this._previousGrid);
132 _sharedDomainChanged: function ()
134 var numberOfDays = this.get('numberOfDays');
138 numberOfDays = parseInt(numberOfDays);
139 var present = Date.now();
140 var past = present - numberOfDays * 24 * 3600 * 1000;
141 this.set('sharedDomain', [past, present]);
142 }.observes('numberOfDays').on('init'),
145 setNumberOfDays: function (numberOfDays)
147 this.set('numberOfDays', numberOfDays);
149 choosePane: function (param)
151 var pane = param.position;
152 pane.set('platformId', param.platform.get('id'));
153 pane.set('metricId', param.metric.get('id'));
155 addColumn: function ()
157 this.get('headerColumns').pushObject({
158 label: this.get('newColumnHeader'),
159 index: this.get('headerColumns').length,
161 this.get('rows').forEach(function (row) {
164 this.set('newColumnHeader', null);
166 removeColumn: function (index)
168 this.get('headerColumns').removeAt(index);
169 this.get('rows').forEach(function (row) {
170 row.get('cells').removeAt(index);
175 this.get('rows').pushObject(App.DashboardRow.create({
177 header: this.get('newRowHeader'),
178 columnCount: this.get('columnCount'),
180 this.set('newRowHeader', null);
182 removeRow: function (row)
184 this.get('rows').removeObject(row);
186 resetPane: function (pane)
188 pane.set('platformId', null);
189 pane.set('metricId', null);
191 toggleEditMode: function ()
193 this.toggleProperty('editMode');
194 if (!this.get('editMode'))
202 App.Manifest.fetch(this.get('store'));
206 App.NumberOfDaysControlView = Ember.View.extend({
207 classNames: ['controls'],
208 templateName: 'number-of-days-controls',
209 didInsertElement: function ()
211 this._matchingElements(this._previousNumberOfDaysClass).addClass('active');
213 _numberOfDaysChanged: function ()
215 this._matchingElements(this._previousNumberOfDaysClass).removeClass('active');
217 var newNumberOfDaysClass = 'numberOfDaysIs' + this.get('numberOfDays');
218 this._matchingElements(this._previousNumberOfDaysClass).addClass('active');
219 this._previousNumberOfDaysClass = newNumberOfDaysClass;
220 }.observes('numberOfDays').on('init'),
221 _matchingElements: function (className)
223 var element = this.get('element');
226 return $(element.getElementsByClassName(className));
230 App.StartTimeSliderView = Ember.View.extend({
231 templateName: 'start-time-slider',
232 classNames: ['start-time-slider'],
233 startTime: Date.now() - 7 * 24 * 3600 * 1000,
234 oldestStartTime: null,
235 _numberOfDaysView: null,
237 _startTimeInSlider: null,
238 _currentNumberOfDays: null,
239 _MILLISECONDS_PER_DAY: 24 * 3600 * 1000,
241 didInsertElement: function ()
243 this.oldestStartTime = Date.now() - 365 * 24 * 3600 * 1000;
244 this._slider = $(this.get('element')).find('input');
245 this._numberOfDaysView = $(this.get('element')).find('.numberOfDays');
246 this._sliderRangeChanged();
247 this._slider.change(this._sliderMoved.bind(this));
249 _sliderRangeChanged: function ()
251 var minimumNumberOfDays = 1;
252 var maximumNumberOfDays = this._timeInPastToNumberOfDays(this.get('oldestStartTime'));
253 var precision = 1000; // FIXME: Compute this from maximumNumberOfDays.
254 var slider = this._slider;
255 slider.attr('min', Math.floor(Math.log(Math.max(1, minimumNumberOfDays)) * precision) / precision);
256 slider.attr('max', Math.ceil(Math.log(maximumNumberOfDays) * precision) / precision);
257 slider.attr('step', 1 / precision);
258 this._startTimeChanged();
259 }.observes('oldestStartTime'),
260 _sliderMoved: function ()
262 this._currentNumberOfDays = Math.round(Math.exp(this._slider.val()));
263 this._numberOfDaysView.text(this._currentNumberOfDays);
264 this._startTimeInSlider = this._numberOfDaysToTimeInPast(this._currentNumberOfDays);
265 this.set('startTime', this._startTimeInSlider);
267 _startTimeChanged: function ()
269 var startTime = this.get('startTime');
270 if (startTime == this._startTimeSetBySlider)
272 this._currentNumberOfDays = this._timeInPastToNumberOfDays(startTime);
275 this._numberOfDaysView.text(this._currentNumberOfDays);
276 this._slider.val(Math.log(this._currentNumberOfDays));
277 this._startTimeInSlider = startTime;
279 }.observes('startTime').on('init'),
280 _timeInPastToNumberOfDays: function (timeInPast)
282 return Math.max(1, Math.round((Date.now() - timeInPast) / this._MILLISECONDS_PER_DAY));
284 _numberOfDaysToTimeInPast: function (numberOfDays)
286 return Date.now() - numberOfDays * this._MILLISECONDS_PER_DAY;
290 App.Pane = Ember.Object.extend({
296 searchCommit: function (repository, keyword) {
298 var repositoryName = repository.get('id');
299 CommitLogs.fetchForTimeRange(repositoryName, null, null, keyword).then(function (commits) {
300 if (self.isDestroyed || !self.get('chartData') || !commits.length)
302 var currentRuns = self.get('chartData').current.timeSeriesByCommitTime().series();
303 if (!currentRuns.length)
306 var highlightedItems = {};
308 for (var runIndex = 0; runIndex < currentRuns.length && commitIndex < commits.length; runIndex++) {
309 var measurement = currentRuns[runIndex].measurement;
310 var commitTime = measurement.commitTimeForRepository(repositoryName);
313 if (commits[commitIndex].time <= commitTime) {
314 highlightedItems[measurement.id()] = true;
317 } while (commitIndex < commits.length && commits[commitIndex].time <= commitTime);
321 self.set('highlightedItems', highlightedItems);
323 // FIXME: Report errors
324 this.set('highlightedItems', {});
327 _fetch: function () {
328 var platformId = this.get('platformId');
329 var metricId = this.get('metricId');
330 if (!platformId && !metricId) {
331 this.set('empty', true);
334 this.set('empty', false);
335 this.set('platform', null);
336 this.set('chartData', null);
337 this.set('metric', null);
338 this.set('failure', null);
340 if (!this._isValidId(platformId))
341 this.set('failure', platformId ? 'Invalid platform id:' + platformId : 'Platform id was not specified');
342 else if (!this._isValidId(metricId))
343 this.set('failure', metricId ? 'Invalid metric id:' + metricId : 'Metric id was not specified');
347 App.Manifest.fetchRunsWithPlatformAndMetric(this.get('store'), platformId, metricId).then(function (result) {
348 self.set('platform', result.platform);
349 self.set('metric', result.metric);
350 self.set('chartData', result.runs);
351 }, function (result) {
352 if (!result || typeof(result) === "string")
353 self.set('failure', 'Failed to fetch the JSON with an error: ' + result);
354 else if (!result.platform)
355 self.set('failure', 'Could not find the platform "' + platformId + '"');
356 else if (!result.metric)
357 self.set('failure', 'Could not find the metric "' + metricId + '"');
359 self.set('failure', 'An internal error');
362 this.fetchAnalyticRanges();
364 }.observes('platformId', 'metricId').on('init'),
365 fetchAnalyticRanges: function ()
367 var platformId = this.get('platformId');
368 var metricId = this.get('metricId');
371 .find('analysisTask', {platform: platformId, metric: metricId})
372 .then(function (tasks) {
373 self.set('analyticRanges', tasks.filter(function (task) { return task.get('startRun') && task.get('endRun'); }));
376 _isValidId: function (id)
378 if (typeof(id) == "number")
380 if (typeof(id) == "string")
381 return !!id.match(/^[A-Za-z0-9_]+$/);
386 App.encodePrettifiedJSON = function (plain)
388 function numberIfPossible(string) {
389 return string == parseInt(string) ? parseInt(string) : string;
392 function recursivelyConvertNumberIfPossible(input) {
393 if (input instanceof Array) {
394 return input.map(recursivelyConvertNumberIfPossible);
396 return numberIfPossible(input);
399 return JSON.stringify(recursivelyConvertNumberIfPossible(plain))
400 .replace(/\[/g, '(').replace(/\]/g, ')').replace(/\,/g, '-');
403 App.decodePrettifiedJSON = function (encoded)
405 var parsed = encoded.replace(/\(/g, '[').replace(/\)/g, ']').replace(/\-/g, ',');
407 return JSON.parse(parsed);
408 } catch (exception) {
413 App.ChartsController = Ember.Controller.extend({
414 queryParams: ['paneList', 'zoom', 'since'],
416 _currentEncodedPaneList: null,
421 defaultSince: Date.now() - 7 * 24 * 3600 * 1000,
423 addPane: function (pane)
425 this.panes.unshiftObject(pane);
428 removePane: function (pane)
430 this.panes.removeObject(pane);
433 refreshPanes: function()
435 var paneList = this.get('paneList');
436 if (paneList === this._currentEncodedPaneList)
439 var panes = this._parsePaneList(paneList || '[]');
441 console.log('Failed to parse', jsonPaneList, exception);
444 this.set('panes', panes);
445 this._currentEncodedPaneList = paneList;
446 }.observes('paneList').on('init'),
448 refreshZoom: function()
450 var zoom = this.get('zoom');
452 this.set('sharedZoom', null);
456 zoom = zoom.split('-');
457 var selection = new Array(2);
459 selection[0] = new Date(parseFloat(zoom[0]));
460 selection[1] = new Date(parseFloat(zoom[1]));
462 console.log('Failed to parse the zoom', zoom);
464 this.set('sharedZoom', selection);
466 var startTime = this.get('startTime');
467 if (startTime && startTime > selection[0])
468 this.set('startTime', selection[0]);
470 }.observes('zoom').on('init'),
472 updateSharedDomain: function ()
474 var panes = this.get('panes');
478 var union = [undefined, undefined];
479 for (var i = 0; i < panes.length; i++) {
480 var domain = panes[i].intrinsicDomain;
483 if (!union[0] || domain[0] < union[0])
484 union[0] = domain[0];
485 if (!union[1] || domain[1] > union[1])
486 union[1] = domain[1];
488 if (union[0] === undefined)
491 var startTime = this.get('startTime');
492 var zoom = this.get('sharedZoom');
494 union[0] = zoom ? Math.min(zoom[0], startTime) : startTime;
496 this.set('sharedDomain', union);
497 }.observes('panes.@each'),
499 _startTimeChanged: function () {
500 this.updateSharedDomain();
501 this._scheduleQueryStringUpdate();
502 }.observes('startTime'),
504 _sinceChanged: function () {
505 var since = parseInt(this.get('since'));
507 since = this.defaultSince;
508 this.set('startTime', new Date(since));
509 }.observes('since').on('init'),
511 _parsePaneList: function (encodedPaneList)
513 var parsedPaneList = App.decodePrettifiedJSON(encodedPaneList);
517 // Don't re-create all panes.
519 return parsedPaneList.map(function (paneInfo) {
520 var timeRange = null;
521 if (paneInfo[3] && paneInfo[3] instanceof Array) {
522 var timeRange = paneInfo[3];
524 timeRange = [new Date(timeRange[0]), new Date(timeRange[1])];
526 console.log("Failed to parse the time range:", timeRange, error);
529 return App.Pane.create({
532 platformId: paneInfo[0],
533 metricId: paneInfo[1],
534 selectedItem: paneInfo[2],
535 timeRange: timeRange,
536 timeRangeIsLocked: !!paneInfo[4],
541 _serializePaneList: function (panes)
545 return App.encodePrettifiedJSON(panes.map(function (pane) {
547 pane.get('platformId'),
548 pane.get('metricId'),
549 pane.get('selectedItem'),
550 pane.get('timeRange') ? pane.get('timeRange').map(function (date) { return date.getTime() }) : null,
551 !!pane.get('timeRangeIsLocked'),
556 _scheduleQueryStringUpdate: function ()
558 Ember.run.debounce(this, '_updateQueryString', 500);
559 }.observes('sharedZoom')
560 .observes('panes.@each.platform', 'panes.@each.metric', 'panes.@each.selectedItem',
561 'panes.@each.timeRange', 'panes.@each.timeRangeIsLocked'),
563 _updateQueryString: function ()
565 this._currentEncodedPaneList = this._serializePaneList(this.get('panes'));
566 this.set('paneList', this._currentEncodedPaneList);
568 var zoom = undefined;
569 var selection = this.get('sharedZoom');
571 zoom = (selection[0] - 0) + '-' + (selection[1] - 0);
572 this.set('zoom', zoom);
574 if (this.get('startTime') - this.defaultSince)
575 this.set('since', this.get('startTime') - 0);
579 addPaneByMetricAndPlatform: function (param)
581 this.addPane(App.Pane.create({
583 platformId: param.platform.get('id'),
584 metricId: param.metric.get('id'),
585 showingDetails: false
594 App.buildPopup(this.store, 'addPaneByMetricAndPlatform').then(function (platforms) {
595 self.set('platforms', platforms);
600 App.buildPopup = function(store, action, position)
602 return App.Manifest.fetch(store).then(function () {
603 return App.Manifest.get('platforms').map(function (platform) {
604 return App.PlatformProxyForPopup.create({content: platform,
605 action: action, position: position});
610 App.PlatformProxyForPopup = Ember.ObjectProxy.extend({
611 children: function ()
613 var platform = this.content;
614 var containsTest = this.content.containsTest.bind(this.content);
615 var action = this.get('action');
616 var position = this.get('position');
617 return App.Manifest.get('topLevelTests')
618 .filter(containsTest)
619 .map(function (test) {
620 return App.TestProxyForPopup.create({content: test, platform: platform, action: action, position: position});
622 }.property('App.Manifest.topLevelTests'),
625 App.TestProxyForPopup = Ember.ObjectProxy.extend({
627 children: function ()
629 var platform = this.get('platform');
630 var action = this.get('action');
631 var position = this.get('position');
633 var childTests = this.get('childTests')
634 .filter(function (test) { return platform.containsTest(test); })
635 .map(function (test) {
636 return App.TestProxyForPopup.create({content: test, platform: platform, action: action, position: position});
639 var metrics = this.get('metrics')
640 .filter(function (metric) { return platform.containsMetric(metric); })
641 .map(function (metric) {
642 var aggregator = metric.get('aggregator');
645 actionArgument: {platform: platform, metric: metric, position:position},
646 label: metric.get('label')
650 if (childTests.length && metrics.length)
651 metrics.push({isSeparator: true});
653 return metrics.concat(childTests);
654 }.property('childTests', 'metrics'),
657 App.PaneController = Ember.ObjectController.extend({
659 sharedTime: Ember.computed.alias('parentController.sharedTime'),
660 sharedSelection: Ember.computed.alias('parentController.sharedSelection'),
663 toggleDetails: function()
665 this.toggleProperty('showingDetails');
669 this.parentController.removePane(this.get('model'));
671 toggleBugsPane: function ()
673 if (this.toggleProperty('showingAnalysisPane'))
674 this.set('showingSearchPane', false);
676 createAnalysisTask: function ()
678 var name = this.get('newAnalysisTaskName');
679 var points = this._selectedPoints;
680 Ember.assert('The analysis name should not be empty', name);
681 Ember.assert('There should be at least two points in the range', points && points.length >= 2);
683 var newWindow = window.open();
685 App.AnalysisTask.create(name, points[0].measurement, points[points.length - 1].measurement).then(function (data) {
686 // FIXME: Update the UI to show the new analysis task.
687 var url = App.Router.router.generate('analysisTask', data['taskId']);
688 newWindow.location.href = '#' + url;
689 self.get('model').fetchAnalyticRanges();
690 }, function (error) {
692 if (error === 'DuplicateAnalysisTask') {
693 // FIXME: Duplicate this error more gracefully.
698 toggleSearchPane: function ()
700 if (!App.Manifest.repositoriesWithReportedCommits)
702 var model = this.get('model');
703 if (!model.get('commitSearchRepository'))
704 model.set('commitSearchRepository', App.Manifest.repositoriesWithReportedCommits[0]);
705 if (this.toggleProperty('showingSearchPane'))
706 this.set('showingAnalysisPane', false);
708 searchCommit: function () {
709 var model = this.get('model');
710 model.searchCommit(model.get('commitSearchRepository'), model.get('commitSearchKeyword'));
712 zoomed: function (selection)
714 this.set('mainPlotDomain', selection ? selection : this.get('overviewDomain'));
715 Ember.run.debounce(this, 'propagateZoom', 100);
717 overviewDomainChanged: function (domain, intrinsicDomain)
719 this.set('overviewDomain', domain);
720 this.set('intrinsicDomain', intrinsicDomain);
721 this.get('parentController').updateSharedDomain();
723 rangeChanged: function (extent, points)
726 this._hasRange = false;
727 this.set('details', null);
728 this.set('timeRange', null);
731 this._hasRange = true;
732 this._showDetails(points);
733 this.set('timeRange', extent);
736 _detailsChanged: function ()
738 this.set('showingAnalysisPane', false);
739 }.observes('details'),
740 _overviewSelectionChanged: function ()
742 var overviewSelection = this.get('overviewSelection');
743 this.set('mainPlotDomain', overviewSelection);
744 Ember.run.debounce(this, 'propagateZoom', 100);
745 }.observes('overviewSelection'),
746 _sharedDomainChanged: function ()
748 var newDomain = this.get('parentController').get('sharedDomain');
749 if (newDomain == this.get('overviewDomain'))
751 this.set('overviewDomain', newDomain);
752 if (!this.get('overviewSelection'))
753 this.set('mainPlotDomain', newDomain);
754 }.observes('parentController.sharedDomain').on('init'),
755 propagateZoom: function ()
757 this.get('parentController').set('sharedZoom', this.get('mainPlotDomain'));
759 _sharedZoomChanged: function ()
761 var newSelection = this.get('parentController').get('sharedZoom');
762 if (newSelection == this.get('mainPlotDomain'))
764 this.set('overviewSelection', newSelection);
765 this.set('mainPlotDomain', newSelection);
766 }.observes('parentController.sharedZoom').on('init'),
767 _currentItemChanged: function ()
771 var point = this.get('currentItem');
772 if (!point || !point.measurement)
773 this.set('details', null);
775 var previousPoint = point.series.previousPoint(point);
776 this._showDetails(previousPoint ? [previousPoint, point] : [point]);
778 }.observes('currentItem'),
779 _showDetails: function (points)
781 var isShowingEndPoint = !this._hasRange;
782 var currentMeasurement = points[points.length - 1].measurement;
783 var oldMeasurement = points[0].measurement;
784 var formattedRevisions = currentMeasurement.formattedRevisions(oldMeasurement);
785 var revisions = App.Manifest.get('repositories')
786 .filter(function (repository) { return formattedRevisions[repository.get('id')]; })
787 .map(function (repository) {
788 var repositoryName = repository.get('id');
789 var revision = Ember.Object.create(formattedRevisions[repositoryName]);
790 revision['url'] = revision.previousRevision
791 ? repository.urlForRevisionRange(revision.previousRevision, revision.currentRevision)
792 : repository.urlForRevision(revision.currentRevision);
793 revision['name'] = repositoryName;
794 revision['repository'] = repository;
798 var buildNumber = null;
800 if (isShowingEndPoint) {
801 buildNumber = currentMeasurement.buildNumber();
802 var builder = App.Manifest.builder(currentMeasurement.builderId());
804 buildURL = builder.urlFromBuildNumber(buildNumber);
807 this._selectedPoints = points;
808 this.set('details', Ember.Object.create({
809 currentValue: currentMeasurement.mean().toFixed(2),
810 oldValue: oldMeasurement && !isShowingEndPoint ? oldMeasurement.mean().toFixed(2) : null,
811 buildNumber: buildNumber,
813 buildTime: currentMeasurement.formattedBuildTime(),
814 revisions: revisions,
816 this._updateCanAnalyze();
818 _updateCanAnalyze: function ()
820 var points = this._selectedPoints;
821 this.set('cannotAnalyze', !this.get('newAnalysisTaskName') || !this._hasRange || !points || points.length < 2);
822 }.observes('newAnalysisTaskName'),
825 App.InteractiveChartComponent = Ember.Component.extend({
830 enableSelection: true,
831 classNames: ['chart'],
835 this._needsConstruction = true;
836 this._eventHandlers = [];
837 $(window).resize(this._updateDimensionsIfNeeded.bind(this));
839 chartDataDidChange: function ()
841 var chartData = this.get('chartData');
844 this._needsConstruction = true;
845 this._constructGraphIfPossible(chartData);
846 }.observes('chartData').on('init'),
847 didInsertElement: function ()
849 var chartData = this.get('chartData');
851 this._constructGraphIfPossible(chartData);
853 willClearRender: function ()
855 this._eventHandlers.forEach(function (item) {
856 $(item[0]).off(item[1], item[2]);
859 _attachEventListener: function(target, eventName, listener)
861 this._eventHandlers.push([target, eventName, listener]);
862 $(target).on(eventName, listener);
864 _constructGraphIfPossible: function (chartData)
866 if (!this._needsConstruction || !this.get('element'))
869 var element = this.get('element');
871 this._x = d3.time.scale();
872 this._y = d3.scale.linear();
874 // FIXME: Tear down the old SVG element.
875 this._svgElement = d3.select(element).append("svg")
876 .attr("width", "100%")
877 .attr("height", "100%");
879 var svg = this._svg = this._svgElement.append("g");
881 var clipId = element.id + "-clip";
882 this._clipPath = svg.append("defs").append("clipPath")
886 if (this.get('showXAxis')) {
887 this._xAxis = d3.svg.axis().scale(this._x).orient("bottom").ticks(6);
888 this._xAxisLabels = svg.append("g")
889 .attr("class", "x axis");
892 if (this.get('showYAxis')) {
893 this._yAxis = d3.svg.axis().scale(this._y).orient("left").ticks(6).tickFormat(d3.format("s"));
894 this._yAxisLabels = svg.append("g")
895 .attr("class", "y axis");
898 this._clippedContainer = svg.append("g")
899 .attr("clip-path", "url(#" + clipId + ")");
901 var xScale = this._x;
902 var yScale = this._y;
903 this._timeLine = d3.svg.line()
904 .x(function(point) { return xScale(point.time); })
905 .y(function(point) { return yScale(point.value); });
907 this._confidenceArea = d3.svg.area()
908 // .interpolate("cardinal")
909 .x(function(point) { return xScale(point.time); })
910 .y0(function(point) { return point.interval ? yScale(point.interval[0]) : null; })
911 .y1(function(point) { return point.interval ? yScale(point.interval[1]) : null; });
914 this._paths.forEach(function (path) { path.remove(); });
917 this._areas.forEach(function (area) { area.remove(); });
920 this._dots.forEach(function (dot) { dots.remove(); });
922 if (this._highlights)
923 this._highlights.forEach(function (highlight) { highlight.remove(); });
924 this._highlights = [];
926 this._currentTimeSeries = chartData.current.timeSeriesByCommitTime();
927 this._currentTimeSeriesData = this._currentTimeSeries.series();
928 this._baselineTimeSeries = chartData.baseline ? chartData.baseline.timeSeriesByCommitTime() : null;
929 this._targetTimeSeries = chartData.target ? chartData.target.timeSeriesByCommitTime() : null;
931 this._yAxisUnit = chartData.unit;
933 var minMax = this._minMaxForAllTimeSeries();
934 var smallEnoughValue = minMax[0] - (minMax[1] - minMax[0]) * 10;
935 var largeEnoughValue = minMax[1] + (minMax[1] - minMax[0]) * 10;
937 // FIXME: Flip the sides based on smallerIsBetter-ness.
938 if (this._baselineTimeSeries) {
939 var data = this._baselineTimeSeries.series();
940 this._areas.push(this._clippedContainer
942 .datum(data.map(function (point) { return {time: point.time, value: point.value, interval: point.interval ? point.interval : [point.value, largeEnoughValue]}; }))
943 .attr("class", "area baseline"));
945 if (this._targetTimeSeries) {
946 var data = this._targetTimeSeries.series();
947 this._areas.push(this._clippedContainer
949 .datum(data.map(function (point) { return {time: point.time, value: point.value, interval: point.interval ? point.interval : [smallEnoughValue, point.value]}; }))
950 .attr("class", "area target"));
953 this._areas.push(this._clippedContainer
955 .datum(this._currentTimeSeriesData)
956 .attr("class", "area"));
958 this._paths.push(this._clippedContainer
960 .datum(this._currentTimeSeriesData)
961 .attr("class", "commit-time-line"));
963 this._dots.push(this._clippedContainer
965 .data(this._currentTimeSeriesData)
966 .enter().append("circle")
967 .attr("class", "dot")
968 .attr("r", this.get('chartPointRadius') || 1));
970 if (this.get('interactive')) {
971 this._attachEventListener(element, "mousemove", this._mouseMoved.bind(this));
972 this._attachEventListener(element, "mouseleave", this._mouseLeft.bind(this));
973 this._attachEventListener(element, "mousedown", this._mouseDown.bind(this));
974 this._attachEventListener($(element).parents("[tabindex]"), "keydown", this._keyPressed.bind(this));
976 this._currentItemLine = this._clippedContainer
978 .attr("class", "current-item");
980 this._currentItemCircle = this._clippedContainer
982 .attr("class", "dot current-item")
987 if (this.get('enableSelection')) {
988 this._brush = d3.svg.brush()
990 .on("brush", this._brushChanged.bind(this));
992 this._brushRect = this._clippedContainer
994 .attr("class", "x brush");
997 this._updateDomain();
998 this._updateDimensionsIfNeeded();
1000 // Work around the fact the brush isn't set if we updated it synchronously here.
1001 setTimeout(this._selectionChanged.bind(this), 0);
1003 setTimeout(this._selectedItemChanged.bind(this), 0);
1005 this._needsConstruction = false;
1007 this._rangesChanged();
1009 _updateDomain: function ()
1011 var xDomain = this.get('domain');
1012 var intrinsicXDomain = this._computeXAxisDomain(this._currentTimeSeriesData);
1014 xDomain = intrinsicXDomain;
1015 var currentDomain = this._x.domain();
1016 if (currentDomain && this._xDomainsAreSame(currentDomain, xDomain))
1017 return currentDomain;
1019 var yDomain = this._computeYAxisDomain(xDomain[0], xDomain[1]);
1020 this._x.domain(xDomain);
1021 this._y.domain(yDomain);
1022 this.sendAction('domainChanged', xDomain, intrinsicXDomain);
1025 _updateDimensionsIfNeeded: function (newSelection)
1027 var element = $(this.get('element'));
1029 var newTotalWidth = element.width();
1030 var newTotalHeight = element.height();
1031 if (this._totalWidth == newTotalWidth && this._totalHeight == newTotalHeight)
1034 this._totalWidth = newTotalWidth;
1035 this._totalHeight = newTotalHeight;
1038 this._rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
1039 var rem = this._rem;
1041 var padding = 0.5 * rem;
1042 var margin = {top: padding, right: padding, bottom: padding, left: padding};
1044 margin.bottom += rem;
1046 margin.left += 3 * rem;
1048 this._margin = margin;
1049 this._contentWidth = this._totalWidth - margin.left - margin.right;
1050 this._contentHeight = this._totalHeight - margin.top - margin.bottom;
1052 this._svg.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
1055 .attr("width", this._contentWidth)
1056 .attr("height", this._contentHeight);
1058 this._x.range([0, this._contentWidth]);
1059 this._y.range([this._contentHeight, 0]);
1062 this._xAxis.tickSize(-this._contentHeight);
1063 this._xAxisLabels.attr("transform", "translate(0," + this._contentHeight + ")");
1067 this._yAxis.tickSize(-this._contentWidth);
1069 if (this._currentItemLine) {
1070 this._currentItemLine
1072 .attr("y2", margin.top + this._contentHeight);
1075 this._relayoutDataAndAxes(this._currentSelection());
1077 _updateBrush: function ()
1083 .attr("height", this._contentHeight - 2);
1084 this._updateSelectionToolbar();
1086 _relayoutDataAndAxes: function (selection)
1088 var timeline = this._timeLine;
1089 this._paths.forEach(function (path) { path.attr("d", timeline); });
1091 var confidenceArea = this._confidenceArea;
1092 this._areas.forEach(function (path) { path.attr("d", confidenceArea); });
1094 var xScale = this._x;
1095 var yScale = this._y;
1096 this._dots.forEach(function (dot) {
1098 .attr("cx", function(measurement) { return xScale(measurement.time); })
1099 .attr("cy", function(measurement) { return yScale(measurement.value); });
1101 this._updateMarkedDots();
1102 this._updateHighlightPositions();
1103 this._updateRangeBarRects();
1107 this._brush.extent(selection);
1109 this._brush.clear();
1110 this._updateBrush();
1113 this._updateCurrentItemIndicators();
1116 this._xAxisLabels.call(this._xAxis);
1120 this._yAxisLabels.call(this._yAxis);
1121 if (this._yAxisUnitContainer)
1122 this._yAxisUnitContainer.remove();
1123 this._yAxisUnitContainer = this._yAxisLabels.append("text")
1124 .attr("x", 0.5 * this._rem)
1125 .attr("y", 0.2 * this._rem)
1126 .attr("dy", 0.8 * this._rem)
1127 .style("text-anchor", "start")
1128 .style("z-index", "100")
1129 .text(this._yAxisUnit);
1131 _updateMarkedDots: function () {
1132 var markedPoints = this.get('markedPoints') || {};
1133 var defaultDotRadius = this.get('chartPointRadius') || 1;
1134 this._dots.forEach(function (dot) {
1135 dot.classed('marked', function (point) { return markedPoints[point.measurement.id()]; });
1136 dot.attr('r', function (point) {
1137 return markedPoints[point.measurement.id()] ? defaultDotRadius * 1.5 : defaultDotRadius; });
1139 }.observes('markedPoints'),
1140 _updateHighlightPositions: function () {
1141 var xScale = this._x;
1142 var yScale = this._y;
1143 var y2 = this._margin.top + this._contentHeight;
1144 this._highlights.forEach(function (highlight) {
1148 .attr("y", function(measurement) { return yScale(measurement.value); })
1149 .attr("x1", function(measurement) { return xScale(measurement.time); })
1150 .attr("x2", function(measurement) { return xScale(measurement.time); });
1153 _computeXAxisDomain: function (timeSeries)
1155 var extent = d3.extent(timeSeries, function(point) { return point.time; });
1156 var margin = 3600 * 1000; // Use x.inverse to compute the right amount from a margin.
1157 return [+extent[0] - margin, +extent[1] + margin];
1159 _computeYAxisDomain: function (startTime, endTime)
1161 var range = this._minMaxForAllTimeSeries(startTime, endTime);
1166 var diff = max - min;
1167 var margin = diff * 0.05;
1169 yExtent = [min - margin, max + margin];
1170 // if (yMin !== undefined)
1171 // yExtent[0] = parseInt(yMin);
1174 _minMaxForAllTimeSeries: function (startTime, endTime)
1176 var currentRange = this._currentTimeSeries.minMaxForTimeRange(startTime, endTime);
1177 var baselineRange = this._baselineTimeSeries ? this._baselineTimeSeries.minMaxForTimeRange(startTime, endTime) : [Number.MAX_VALUE, Number.MIN_VALUE];
1178 var targetRange = this._targetTimeSeries ? this._targetTimeSeries.minMaxForTimeRange(startTime, endTime) : [Number.MAX_VALUE, Number.MIN_VALUE];
1180 Math.min(currentRange[0], baselineRange[0], targetRange[0]),
1181 Math.max(currentRange[1], baselineRange[1], targetRange[1]),
1184 _currentSelection: function ()
1186 return this._brush && !this._brush.empty() ? this._brush.extent() : null;
1188 _domainChanged: function ()
1190 var selection = this._currentSelection() || this.get('sharedSelection');
1191 var newXDomain = this._updateDomain();
1193 if (selection && newXDomain && selection[0] <= newXDomain[0] && newXDomain[1] <= selection[1])
1194 selection = null; // Otherwise the user has no way of clearing the selection.
1196 this._relayoutDataAndAxes(selection);
1197 }.observes('domain'),
1198 _selectionChanged: function ()
1200 this._updateSelection(this.get('selection'));
1201 }.observes('selection'),
1202 _sharedSelectionChanged: function ()
1204 if (this.get('selectionIsLocked'))
1206 this._updateSelection(this.get('sharedSelection'));
1207 }.observes('sharedSelection'),
1208 _updateSelection: function (newSelection)
1213 var currentSelection = this._currentSelection();
1214 if (newSelection && currentSelection && this._xDomainsAreSame(newSelection, currentSelection))
1217 var domain = this._x.domain();
1218 if (!newSelection || this._xDomainsAreSame(domain, newSelection))
1219 this._brush.clear();
1221 this._brush.extent(newSelection);
1222 this._updateBrush();
1224 this._setCurrentSelection(newSelection);
1226 _xDomainsAreSame: function (domain1, domain2)
1228 return !(domain1[0] - domain2[0]) && !(domain1[1] - domain2[1]);
1230 _brushChanged: function ()
1232 if (this._brush.empty()) {
1233 if (!this._brushExtent)
1236 this.set('selectionIsLocked', false);
1237 this._setCurrentSelection(undefined);
1239 // Avoid locking the indicator in _mouseDown when the brush was cleared in the same mousedown event.
1240 this._brushJustChanged = true;
1242 setTimeout(function () {
1243 self._brushJustChanged = false;
1249 this.set('selectionIsLocked', true);
1250 this._setCurrentSelection(this._brush.extent());
1252 _keyPressed: function (event)
1254 if (!this._currentItemIndex || this._currentSelection())
1258 switch (event.keyCode) {
1260 newIndex = this._currentItemIndex - 1;
1263 newIndex = this._currentItemIndex + 1;
1271 // Unlike mousemove, keydown shouldn't move off the edge.
1272 if (this._currentTimeSeriesData[newIndex])
1273 this._setCurrentItem(newIndex);
1275 _mouseMoved: function (event)
1277 if (!this._margin || this._currentSelection() || this._currentItemLocked)
1280 var point = this._mousePointInGraph(event);
1282 this._selectClosestPointToMouseAsCurrentItem(point);
1284 _mouseLeft: function (event)
1286 if (!this._margin || this._currentItemLocked)
1289 this._selectClosestPointToMouseAsCurrentItem(null);
1291 _mouseDown: function (event)
1293 if (!this._margin || this._currentSelection() || this._brushJustChanged)
1296 var point = this._mousePointInGraph(event);
1300 if (this._currentItemLocked) {
1301 this._currentItemLocked = false;
1302 this.set('selectedItem', null);
1306 this._currentItemLocked = true;
1307 this._selectClosestPointToMouseAsCurrentItem(point);
1309 _mousePointInGraph: function (event)
1311 var offset = $(this.get('element')).offset();
1312 if (!offset || !$(event.target).closest('svg').length)
1316 x: event.pageX - offset.left - this._margin.left,
1317 y: event.pageY - offset.top - this._margin.top
1320 var xScale = this._x;
1321 var yScale = this._y;
1322 var xDomain = xScale.domain();
1323 var yDomain = yScale.domain();
1324 if (point.x >= xScale(xDomain[0]) && point.x <= xScale(xDomain[1])
1325 && point.y <= yScale(yDomain[0]) && point.y >= yScale(yDomain[1]))
1330 _selectClosestPointToMouseAsCurrentItem: function (point)
1332 var xScale = this._x;
1333 var yScale = this._y;
1334 var distanceHeuristics = function (m) {
1335 var mX = xScale(m.time);
1336 var mY = yScale(m.value);
1337 var xDiff = mX - point.x;
1338 var yDiff = mY - point.y;
1339 return xDiff * xDiff + yDiff * yDiff / 16; // Favor horizontal affinity.
1341 distanceHeuristics = function (m) {
1342 return Math.abs(xScale(m.time) - point.x);
1346 if (point && !this._currentSelection()) {
1347 var distances = this._currentTimeSeriesData.map(distanceHeuristics);
1348 var minDistance = Number.MAX_VALUE;
1349 for (var i = 0; i < distances.length; i++) {
1350 if (distances[i] < minDistance) {
1352 minDistance = distances[i];
1357 this._setCurrentItem(newItemIndex);
1358 this._updateSelectionToolbar();
1360 _currentTimeChanged: function ()
1362 if (!this._margin || this._currentSelection() || this._currentItemLocked)
1365 var currentTime = this.get('currentTime');
1367 for (var i = 0; i < this._currentTimeSeriesData.length; i++) {
1368 var point = this._currentTimeSeriesData[i];
1369 if (point.time >= currentTime) {
1370 this._setCurrentItem(i, /* doNotNotify */ true);
1375 this._setCurrentItem(undefined, /* doNotNotify */ true);
1376 }.observes('currentTime'),
1377 _setCurrentItem: function (newItemIndex, doNotNotify)
1379 if (newItemIndex === this._currentItemIndex) {
1380 if (this._currentItemLocked)
1381 this.set('selectedItem', this.get('currentItem') ? this.get('currentItem').measurement.id() : null);
1385 var newItem = this._currentTimeSeriesData[newItemIndex];
1386 this._brushExtent = undefined;
1387 this._currentItemIndex = newItemIndex;
1390 this._currentItemLocked = false;
1391 this.set('selectedItem', null);
1394 this._updateCurrentItemIndicators();
1397 this.set('currentTime', newItem ? newItem.time : undefined);
1399 this.set('currentItem', newItem);
1400 if (this._currentItemLocked)
1401 this.set('selectedItem', newItem ? newItem.measurement.id() : null);
1403 _selectedItemChanged: function ()
1408 var selectedId = this.get('selectedItem');
1409 var currentItem = this.get('currentItem');
1410 if (currentItem && currentItem.measurement.id() == selectedId)
1413 var series = this._currentTimeSeriesData;
1414 var selectedItemIndex = undefined;
1415 for (var i = 0; i < series.length; i++) {
1416 if (series[i].measurement.id() == selectedId) {
1417 this._updateSelection(null);
1418 this._currentItemLocked = true;
1419 this._setCurrentItem(i);
1420 this._updateSelectionToolbar();
1424 }.observes('selectedItem').on('init'),
1425 _highlightedItemsChanged: function () {
1429 var highlightedItems = this.get('highlightedItems');
1431 var data = this._currentTimeSeriesData.filter(function (item) { return highlightedItems[item.measurement.id()]; });
1433 if (this._highlights.length)
1434 this._highlights.forEach(function (highlight) { highlight.remove(); });
1436 this._highlights.push(this._clippedContainer
1437 .selectAll(".highlight")
1439 .enter().append("line")
1440 .attr("class", "highlight"));
1442 this._updateHighlightPositions();
1444 }.observes('highlightedItems'),
1445 _rangesChanged: function ()
1447 if (!this._currentTimeSeries)
1450 function midPoint(firstPoint, secondPoint) {
1451 if (firstPoint && secondPoint)
1452 return (+firstPoint.time + +secondPoint.time) / 2;
1454 return firstPoint.time;
1455 return secondPoint.time;
1457 var currentTimeSeries = this._currentTimeSeries;
1458 var linkRoute = this.get('rangeRoute');
1459 this.set('rangeBars', (this.get('ranges') || []).map(function (range) {
1460 var start = currentTimeSeries.findPointByMeasurementId(range.get('startRun'));
1461 var end = currentTimeSeries.findPointByMeasurementId(range.get('endRun'));
1462 return Ember.Object.create({
1463 startTime: midPoint(currentTimeSeries.previousPoint(start), start),
1464 endTime: midPoint(end, currentTimeSeries.nextPoint(end)),
1471 linkRoute: linkRoute,
1472 linkId: range.get('id'),
1476 this._updateRangeBarRects();
1477 }.observes('ranges'),
1478 _updateRangeBarRects: function () {
1479 var rangeBars = this.get('rangeBars');
1480 if (!rangeBars || !rangeBars.length)
1483 var xScale = this._x;
1484 var yScale = this._y;
1486 // Expand the width of each range as needed and sort ranges by the left-edge of ranges.
1488 var sortedBars = rangeBars.map(function (bar) {
1489 var left = xScale(bar.get('startTime'));
1490 var right = xScale(bar.get('endTime'));
1491 if (right - left < minWidth) {
1492 left -= minWidth / 2;
1493 right += minWidth / 2;
1495 bar.set('left', left);
1496 bar.set('right', right);
1498 }).sort(function (first, second) { return first.get('left') - second.get('left'); });
1500 // At this point, left edges of all ranges prior to a range R1 is on the left of R1.
1501 // Place R1 into a row in which right edges of all ranges prior to R1 is on the left of R1 to avoid overlapping ranges.
1503 sortedBars.forEach(function (bar) {
1505 for (; rowIndex < rows.length; rowIndex++) {
1506 var currentRow = rows[rowIndex];
1507 if (currentRow[currentRow.length - 1].get('right') < bar.get('left')) {
1508 currentRow.push(bar);
1512 if (rowIndex >= rows.length)
1514 bar.set('rowIndex', rowIndex);
1516 var rowHeight = 0.6 * this._rem;
1517 var firstRowTop = this._contentHeight - rows.length * rowHeight;
1518 var barHeight = 0.5 * this._rem;
1520 $(this.get('element')).find('.rangeBarsContainerInlineStyle').css({
1521 left: this._margin.left + 'px',
1522 top: this._margin.top + firstRowTop + 'px',
1523 width: this._contentWidth + 'px',
1524 height: rows.length * barHeight + 'px',
1526 position: 'absolute',
1529 var margin = this._margin;
1530 sortedBars.forEach(function (bar) {
1531 var top = bar.get('rowIndex') * rowHeight;
1532 var height = barHeight;
1533 var left = bar.get('left');
1534 var width = bar.get('right') - left;
1535 bar.set('inlineStyle', 'left: ' + left + 'px; top: ' + top + 'px; width: ' + width + 'px; height: ' + height + 'px;');
1538 _updateCurrentItemIndicators: function ()
1540 if (!this._currentItemLine)
1543 var item = this._currentTimeSeriesData[this._currentItemIndex];
1545 this._currentItemLine.attr("x1", -1000).attr("x2", -1000);
1546 this._currentItemCircle.attr("cx", -1000);
1550 var x = this._x(item.time);
1551 var y = this._y(item.value);
1553 this._currentItemLine
1557 this._currentItemCircle
1561 _setCurrentSelection: function (newSelection)
1563 if (this._brushExtent === newSelection)
1568 points = this._currentTimeSeriesData
1569 .filter(function (point) { return point.time >= newSelection[0] && point.time <= newSelection[1]; });
1574 this._brushExtent = newSelection;
1575 this._setCurrentItem(undefined);
1576 this._updateSelectionToolbar();
1578 this.set('sharedSelection', newSelection);
1579 this.sendAction('selectionChanged', newSelection, points);
1581 _updateSelectionToolbar: function ()
1583 if (!this.get('interactive'))
1586 var selection = this._currentSelection();
1587 var selectionToolbar = $(this.get('element')).children('.selection-toolbar');
1589 var left = this._x(selection[0]);
1590 var right = this._x(selection[1]);
1592 .css({left: this._margin.left + right, top: this._margin.top + this._contentHeight})
1595 selectionToolbar.hide();
1600 this.sendAction('zoom', this._currentSelection());
1601 this.set('selection', null);
1603 openRange: function (range)
1605 this.sendAction('openRange', range);
1612 App.CommitsViewerComponent = Ember.Component.extend({
1616 commitsChanged: function ()
1618 var revisionInfo = this.get('revisionInfo');
1620 var to = revisionInfo.get('currentRevision');
1621 var from = revisionInfo.get('previousRevision');
1622 var repository = this.get('repository');
1623 if (!from || !repository || !repository.get('hasReportedCommits'))
1627 CommitLogs.fetchForTimeRange(repository.get('id'), from, to).then(function (commits) {
1628 if (self.isDestroyed)
1630 self.set('commits', commits.map(function (commit) {
1631 return Ember.Object.create({
1632 repository: repository,
1633 revision: commit.revision,
1634 url: repository.urlForRevision(commit.revision),
1635 author: commit.authorName || commit.authorEmail,
1636 message: commit.message ? commit.message.substr(0, 75) : null,
1640 if (!self.isDestroyed)
1641 self.set('commits', []);
1643 }.observes('repository').observes('revisionInfo').on('init'),
1647 App.AnalysisRoute = Ember.Route.extend({
1648 model: function () {
1649 return this.store.findAll('analysisTask').then(function (tasks) {
1650 return Ember.Object.create({'tasks': tasks});
1655 App.AnalysisTaskRoute = Ember.Route.extend({
1656 model: function (param) {
1657 return this.store.find('analysisTask', param.taskId).then(function (task) {
1658 return App.AnalysisTaskViewModel.create({content: task, store: store});
1663 App.AnalysisTaskViewModel = Ember.ObjectProxy.extend({
1666 _taskUpdated: function ()
1668 var platformId = this.get('platform').get('id');
1669 var metricId = this.get('metric').get('id');
1670 App.Manifest.fetchRunsWithPlatformAndMetric(this.get('store'), platformId, metricId).then(this._fetchedRuns.bind(this));
1671 }.observes('platform', 'metric').on('init'),
1672 _fetchedRuns: function (data) {
1673 var runs = data.runs;
1675 var currentTimeSeries = runs.current.timeSeriesByCommitTime();
1676 if (!currentTimeSeries)
1677 return; // FIXME: Report an error.
1679 var start = currentTimeSeries.findPointByMeasurementId(this.get('startRun'));
1680 var end = currentTimeSeries.findPointByMeasurementId(this.get('endRun'));
1682 return; // FIXME: Report an error.
1684 var markedPoints = {};
1685 markedPoints[start.measurement.id()] = true;
1686 markedPoints[end.measurement.id()] = true;
1688 var formatedPoints = currentTimeSeries.seriesBetweenPoints(start, end).map(function (point, index) {
1690 id: point.measurement.id(),
1691 measurement: point.measurement,
1692 label: 'Point ' + (index + 1),
1693 value: point.value + (runs.unit ? ' ' + runs.unit : ''),
1697 var margin = (end.time - start.time) * 0.1;
1698 this.set('chartData', runs);
1699 this.set('chartDomain', [start.time - margin, +end.time + margin]);
1700 this.set('markedPoints', markedPoints);
1701 this.set('analysisPoints', formatedPoints);
1703 testSets: function ()
1705 var analysisPoints = this.get('analysisPoints');
1706 if (!analysisPoints)
1708 var pointOptions = [{value: ' ', label: 'None'}]
1709 .concat(analysisPoints.map(function (point) { return {value: point.id, label: point.label}; }));
1711 Ember.Object.create({name: "A", options: pointOptions, selection: pointOptions[1]}),
1712 Ember.Object.create({name: "B", options: pointOptions, selection: pointOptions[pointOptions.length - 1]}),
1714 }.property('analysisPoints'),
1715 _rootChangedForTestSet: function () {
1716 var sets = this.get('testSets');
1717 var roots = this.get('roots');
1718 if (!sets || !roots)
1721 sets.forEach(function (testSet, setIndex) {
1722 var currentSelection = testSet.get('selection');
1723 if (currentSelection == testSet.get('previousSelection'))
1725 testSet.set('previousSelection', currentSelection);
1726 var pointIndex = testSet.get('options').indexOf(currentSelection);
1728 roots.forEach(function (root) {
1729 var set = root.sets[setIndex];
1730 set.set('selection', set.revisions[pointIndex]);
1734 }.observes('testSets.@each.selection'),
1737 var analysisPoints = this.get('analysisPoints');
1738 if (!analysisPoints)
1740 var repositoryToRevisions = {};
1741 analysisPoints.forEach(function (point, pointIndex) {
1742 var revisions = point.measurement.formattedRevisions();
1743 for (var repositoryName in revisions) {
1744 if (!repositoryToRevisions[repositoryName])
1745 repositoryToRevisions[repositoryName] = new Array(analysisPoints.length);
1746 var revision = revisions[repositoryName];
1747 repositoryToRevisions[repositoryName][pointIndex] = {
1748 label: point.label + ': ' + revision.label,
1749 value: revision.currentRevision,
1755 for (var repositoryName in repositoryToRevisions) {
1756 var revisions = [{value: ' ', label: 'None'}].concat(repositoryToRevisions[repositoryName]);
1757 roots.push(Ember.Object.create({
1758 name: repositoryName,
1760 Ember.Object.create({name: 'A[' + repositoryName + ']',
1761 revisions: revisions,
1762 selection: revisions[1]}),
1763 Ember.Object.create({name: 'B[' + repositoryName + ']',
1764 revisions: revisions,
1765 selection: revisions[revisions.length - 1]}),
1770 }.property('analysisPoints'),