Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: tracing/tracing/ui/tracks/chart_series.html

Issue 2776653002: [ESLint] Fix violations when enabling curly rule in eslint. (Closed)
Patch Set: Fix test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2015 The Chromium Authors. All rights reserved. 3 Copyright (c) 2015 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/color_scheme.html"> 8 <link rel="import" href="/tracing/base/color_scheme.html">
9 <link rel="import" href="/tracing/base/range.html"> 9 <link rel="import" href="/tracing/base/range.html">
10 <link rel="import" href="/tracing/model/proxy_selectable_item.html"> 10 <link rel="import" href="/tracing/model/proxy_selectable_item.html">
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 ChartSeries.prototype = { 110 ChartSeries.prototype = {
111 useRenderingConfig_: function(opt_renderingConfig) { 111 useRenderingConfig_: function(opt_renderingConfig) {
112 var config = opt_renderingConfig || {}; 112 var config = opt_renderingConfig || {};
113 113
114 // Store all configuration flags as private properties. 114 // Store all configuration flags as private properties.
115 for (var [key, defaultValue] of 115 for (var [key, defaultValue] of
116 Object.entries(DEFAULT_RENDERING_CONFIG)) { 116 Object.entries(DEFAULT_RENDERING_CONFIG)) {
117 var value = config[key]; 117 var value = config[key];
118 if (value === undefined) 118 if (value === undefined) {
119 value = defaultValue; 119 value = defaultValue;
120 }
120 this[key + '_'] = value; 121 this[key + '_'] = value;
121 } 122 }
122 123
123 // Avoid unnecessary recomputation in getters. 124 // Avoid unnecessary recomputation in getters.
124 this.topPadding = this.bottomPadding = Math.max( 125 this.topPadding = this.bottomPadding = Math.max(
125 this.selectedPointSize_, this.unselectedPointSize_) / 2; 126 this.selectedPointSize_, this.unselectedPointSize_) / 2;
126 }, 127 },
127 128
128 get range() { 129 get range() {
129 var range = new tr.b.Range(); 130 var range = new tr.b.Range();
130 this.points.forEach(function(point) { 131 this.points.forEach(function(point) {
131 range.addValue(point.y); 132 range.addValue(point.y);
132 }, this); 133 }, this);
133 return range; 134 return range;
134 }, 135 },
135 136
136 draw: function(ctx, transform, highDetails) { 137 draw: function(ctx, transform, highDetails) {
137 if (this.points === undefined || this.points.length === 0) 138 if (this.points === undefined || this.points.length === 0) {
138 return; 139 return;
140 }
139 141
140 // Draw the background. 142 // Draw the background.
141 if (this.chartType_ === ChartSeriesType.AREA) { 143 if (this.chartType_ === ChartSeriesType.AREA) {
142 this.drawComponent_(ctx, transform, ChartSeriesComponent.BACKGROUND, 144 this.drawComponent_(ctx, transform, ChartSeriesComponent.BACKGROUND,
143 highDetails); 145 highDetails);
144 } 146 }
145 147
146 // Draw the line at the top. 148 // Draw the line at the top.
147 if (this.chartType_ === ChartSeriesType.LINE || highDetails) { 149 if (this.chartType_ === ChartSeriesType.LINE || highDetails) {
148 this.drawComponent_(ctx, transform, ChartSeriesComponent.LINE, 150 this.drawComponent_(ctx, transform, ChartSeriesComponent.LINE,
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 498 }
497 } 499 }
498 ctx.restore(); 500 ctx.restore();
499 }, 501 },
500 502
501 addIntersectingEventsInRangeToSelectionInWorldSpace: function( 503 addIntersectingEventsInRangeToSelectionInWorldSpace: function(
502 loWX, hiWX, viewPixWidthWorld, selection) { 504 loWX, hiWX, viewPixWidthWorld, selection) {
503 var points = this.points; 505 var points = this.points;
504 506
505 function getPointWidth(point, i) { 507 function getPointWidth(point, i) {
506 if (i === points.length - 1) 508 if (i === points.length - 1) {
507 return LAST_POINT_WIDTH * viewPixWidthWorld; 509 return LAST_POINT_WIDTH * viewPixWidthWorld;
510 }
508 var nextPoint = points[i + 1]; 511 var nextPoint = points[i + 1];
509 return nextPoint.x - point.x; 512 return nextPoint.x - point.x;
510 } 513 }
511 514
512 function selectPoint(point) { 515 function selectPoint(point) {
513 point.addToSelection(selection); 516 point.addToSelection(selection);
514 } 517 }
515 518
516 tr.b.iterateOverIntersectingIntervals( 519 tr.b.iterateOverIntersectingIntervals(
517 this.points, 520 this.points,
518 function(point) { return point.x; }, 521 function(point) { return point.x; },
519 getPointWidth, 522 getPointWidth,
520 loWX, 523 loWX,
521 hiWX, 524 hiWX,
522 selectPoint); 525 selectPoint);
523 }, 526 },
524 527
525 addEventNearToProvidedEventToSelection: function(event, offset, selection) { 528 addEventNearToProvidedEventToSelection: function(event, offset, selection) {
526 if (this.points === undefined) 529 if (this.points === undefined) return false;
527 return false;
528 530
529 var index = tr.b.findFirstIndexInArray(this.points, function(point) { 531 var index = tr.b.findFirstIndexInArray(this.points, function(point) {
530 return point.modelItem === event; 532 return point.modelItem === event;
531 }, this); 533 }, this);
532 if (index === -1) 534 if (index === -1) return false;
533 return false;
534 535
535 var newIndex = index + offset; 536 var newIndex = index + offset;
536 if (newIndex < 0 || newIndex >= this.points.length) 537 if (newIndex < 0 || newIndex >= this.points.length) return false;
537 return false;
538 538
539 this.points[newIndex].addToSelection(selection); 539 this.points[newIndex].addToSelection(selection);
540 return true; 540 return true;
541 }, 541 },
542 542
543 addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, 543 addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY,
544 selection) { 544 selection) {
545 if (this.points === undefined) 545 if (this.points === undefined) return;
546 return;
547 546
548 var item = tr.b.findClosestElementInSortedArray( 547 var item = tr.b.findClosestElementInSortedArray(
549 this.points, 548 this.points,
550 function(point) { return point.x; }, 549 function(point) { return point.x; },
551 worldX, 550 worldX,
552 worldMaxDist); 551 worldMaxDist);
553 552
554 if (!item) 553 if (!item) return;
555 return;
556 554
557 item.addToSelection(selection); 555 item.addToSelection(selection);
558 } 556 }
559 }; 557 };
560 558
561 return { 559 return {
562 ChartSeries, 560 ChartSeries,
563 ChartSeriesType, 561 ChartSeriesType,
564 }; 562 };
565 }); 563 });
566 </script> 564 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698