OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2015 The Chromium Authors. All rights reserved. | 3 Copyright 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/unit.html"> | 8 <link rel="import" href="/tracing/base/unit.html"> |
9 <link rel="import" href="/tracing/ui/base/deep_utils.html"> | 9 <link rel="import" href="/tracing/ui/base/deep_utils.html"> |
10 <link rel="import" href="/tracing/value/histogram.html"> | 10 <link rel="import" href="/tracing/value/histogram.html"> |
11 <link rel="import" href="/tracing/value/ui/scalar_context_controller.html"> | 11 <link rel="import" href="/tracing/value/ui/scalar_context_controller.html"> |
12 | 12 |
13 <script> | 13 <script> |
14 'use strict'; | 14 'use strict'; |
15 tr.exportTo('tr.v.ui', function() { | 15 tr.exportTo('tr.v.ui', function() { |
16 /** | 16 /** |
17 * One common simple way to use this function is | 17 * One common simple way to use this function is |
18 * createScalarSpan(number, {unit: tr.b.Unit.byName.whatever}) | 18 * createScalarSpan(number, {unit: tr.b.Unit.byName.whatever}) |
19 * | 19 * |
20 * This function can also take a Scalar, undefined, or a Histogram plus | 20 * This function can also take a Scalar, undefined, or a Histogram plus |
21 * significance, contextGroup, customContextRange, leftAlign and/or inline. | 21 * significance, contextGroup, customContextRange, leftAlign and/or inline. |
22 * | 22 * |
23 * @param {undefined|tr.b.Scalar|tr.v.Histogram} value | 23 * @param {undefined|tr.b.Scalar|tr.v.Histogram} value |
24 * @param {Object=} opt_config | 24 * @param {Object=} opt_config |
25 * @param {!tr.b.Range=} opt_config.customContextRange | 25 * @param {!tr.b.math.Range=} opt_config.customContextRange |
26 * @param {boolean=} opt_config.leftAlign | 26 * @param {boolean=} opt_config.leftAlign |
27 * @param {boolean=} opt_config.inline | 27 * @param {boolean=} opt_config.inline |
28 * @param {!tr.b.Unit=} opt_config.unit | 28 * @param {!tr.b.Unit=} opt_config.unit |
29 * @param {tr.b.Statistics.Significance=} opt_config.significance | 29 * @param {tr.b.math.Statistics.Significance=} opt_config.significance |
30 * @param {string=} opt_config.contextGroup | 30 * @param {string=} opt_config.contextGroup |
31 * @return {(string|!HTMLElement)} | 31 * @return {(string|!HTMLElement)} |
32 */ | 32 */ |
33 function createScalarSpan(value, opt_config) { | 33 function createScalarSpan(value, opt_config) { |
34 if (value === undefined) | 34 if (value === undefined) |
35 return ''; | 35 return ''; |
36 | 36 |
37 let config = opt_config || {}; | 37 let config = opt_config || {}; |
38 let ownerDocument = config.ownerDocument || document; | 38 let ownerDocument = config.ownerDocument || document; |
39 | 39 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 }, | 238 }, |
239 | 239 |
240 created: function() { | 240 created: function() { |
241 this.value_ = undefined; | 241 this.value_ = undefined; |
242 this.unit_ = undefined; | 242 this.unit_ = undefined; |
243 | 243 |
244 // TODO(petrcermak): Merge this into the context controller. | 244 // TODO(petrcermak): Merge this into the context controller. |
245 this.context_ = undefined; | 245 this.context_ = undefined; |
246 | 246 |
247 this.warning_ = undefined; | 247 this.warning_ = undefined; |
248 this.significance_ = tr.b.Statistics.Significance.DONT_CARE; | 248 this.significance_ = tr.b.math.Statistics.Significance.DONT_CARE; |
249 | 249 |
250 // To avoid unnecessary DOM traversal, search for the context controller | 250 // To avoid unnecessary DOM traversal, search for the context controller |
251 // only when necessary (when the span is attached and has a context group). | 251 // only when necessary (when the span is attached and has a context group). |
252 this.shouldSearchForContextController_ = false; | 252 this.shouldSearchForContextController_ = false; |
253 this.lazyContextController_ = undefined; | 253 this.lazyContextController_ = undefined; |
254 this.onContextUpdated_ = this.onContextUpdated_.bind(this); | 254 this.onContextUpdated_ = this.onContextUpdated_.bind(this); |
255 | 255 |
256 // The span can specify a custom context range, which will override the | 256 // The span can specify a custom context range, which will override the |
257 // values from the context controller. | 257 // values from the context controller. |
258 this.customContextRange_ = undefined; | 258 this.customContextRange_ = undefined; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 520 |
521 default: | 521 default: |
522 throw new Error('Unknown change class: ' + changeClass); | 522 throw new Error('Unknown change class: ' + changeClass); |
523 } | 523 } |
524 | 524 |
525 // Set the content class separately from the significance class so that | 525 // Set the content class separately from the significance class so that |
526 // the Neutral face is always a neutral color. | 526 // the Neutral face is always a neutral color. |
527 Polymer.dom(this.$.content).classList.add(changeClass); | 527 Polymer.dom(this.$.content).classList.add(changeClass); |
528 | 528 |
529 switch (this.significance) { | 529 switch (this.significance) { |
530 case tr.b.Statistics.Significance.DONT_CARE: | 530 case tr.b.math.Statistics.Significance.DONT_CARE: |
531 break; | 531 break; |
532 | 532 |
533 case tr.b.Statistics.Significance.INSIGNIFICANT: | 533 case tr.b.math.Statistics.Significance.INSIGNIFICANT: |
534 if (changeClass !== 'same') | 534 if (changeClass !== 'same') |
535 title = 'insignificant ' + title; | 535 title = 'insignificant ' + title; |
536 this.$.insignificant.style.display = 'inline'; | 536 this.$.insignificant.style.display = 'inline'; |
537 changeClass = 'same'; | 537 changeClass = 'same'; |
538 break; | 538 break; |
539 | 539 |
540 case tr.b.Statistics.Significance.SIGNIFICANT: | 540 case tr.b.math.Statistics.Significance.SIGNIFICANT: |
541 if (changeClass === 'same') | 541 if (changeClass === 'same') |
542 throw new Error('How can no change be significant?'); | 542 throw new Error('How can no change be significant?'); |
543 this.$['significantly_' + changeClass].style.display = 'inline'; | 543 this.$['significantly_' + changeClass].style.display = 'inline'; |
544 title = 'significant ' + title; | 544 title = 'significant ' + title; |
545 break; | 545 break; |
546 | 546 |
547 default: | 547 default: |
548 throw new Error('Unknown significance ' + this.significance); | 548 throw new Error('Unknown significance ' + this.significance); |
549 } | 549 } |
550 | 550 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 612 |
613 set duration(duration) { | 613 set duration(duration) { |
614 if (duration instanceof tr.b.u.TimeDuration) { | 614 if (duration instanceof tr.b.u.TimeDuration) { |
615 this.value = duration; | 615 this.value = duration; |
616 return; | 616 return; |
617 } | 617 } |
618 this.setValueAndUnit(duration, tr.b.u.Units.timeDurationInMs); | 618 this.setValueAndUnit(duration, tr.b.u.Units.timeDurationInMs); |
619 } | 619 } |
620 }); | 620 }); |
621 </script> | 621 </script> |
OLD | NEW |