OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2014 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2014 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/ui/base/chart_base_2d.html"> | 8 <link rel="import" href="/tracing/ui/base/chart_base_2d.html"> |
9 | 9 |
10 <script> | 10 <script> |
11 'use strict'; | 11 'use strict'; |
12 | 12 |
13 tr.exportTo('tr.ui.b', function() { | 13 tr.exportTo('tr.ui.b', function() { |
14 var ChartBase2D = tr.ui.b.ChartBase2D; | 14 var ChartBase2D = tr.ui.b.ChartBase2D; |
15 var ChartBase2DBrushX = tr.ui.b.define('chart-base-2d-brush-1d', ChartBase2D); | 15 var ChartBase2DBrushX = tr.ui.b.define('chart-base-2d-brush-1d', ChartBase2D); |
16 | 16 |
17 ChartBase2DBrushX.prototype = { | 17 ChartBase2DBrushX.prototype = { |
18 __proto__: ChartBase2D.prototype, | 18 __proto__: ChartBase2D.prototype, |
19 | 19 |
20 decorate() { | 20 decorate() { |
21 super.decorate(); | 21 super.decorate(); |
22 this.brushedRange_ = new tr.b.Range(); | 22 this.brushedRange_ = new tr.b.math.Range(); |
23 }, | 23 }, |
24 | 24 |
25 set brushedRange(range) { | 25 set brushedRange(range) { |
26 this.brushedRange_.reset(); | 26 this.brushedRange_.reset(); |
27 this.brushedRange_.addRange(range); | 27 this.brushedRange_.addRange(range); |
28 this.updateContents_(); | 28 this.updateContents_(); |
29 }, | 29 }, |
30 | 30 |
31 get brushedRange() { | 31 get brushedRange() { |
32 return tr.b.Range.fromDict(this.brushedRange_.toJSON()); | 32 return tr.b.math.Range.fromDict(this.brushedRange_.toJSON()); |
33 }, | 33 }, |
34 | 34 |
35 computeBrushRangeFromIndices(indexA, indexB) { | 35 computeBrushRangeFromIndices(indexA, indexB) { |
36 indexA = tr.b.clamp(indexA, 0, this.data_.length - 1); | 36 indexA = tr.b.math.clamp(indexA, 0, this.data_.length - 1); |
37 indexB = tr.b.clamp(indexB, 0, this.data_.length - 1); | 37 indexB = tr.b.math.clamp(indexB, 0, this.data_.length - 1); |
38 var leftIndex = Math.min(indexA, indexB); | 38 var leftIndex = Math.min(indexA, indexB); |
39 var rightIndex = Math.max(indexA, indexB); | 39 var rightIndex = Math.max(indexA, indexB); |
40 | 40 |
41 var brushRange = new tr.b.Range(); | 41 var brushRange = new tr.b.math.Range(); |
42 brushRange.addValue( | 42 brushRange.addValue( |
43 this.getXForDatum_(this.data_[leftIndex], leftIndex) - | 43 this.getXForDatum_(this.data_[leftIndex], leftIndex) - |
44 this.getSampleWidth_(this.data_, leftIndex, true)); | 44 this.getSampleWidth_(this.data_, leftIndex, true)); |
45 brushRange.addValue( | 45 brushRange.addValue( |
46 this.getXForDatum_(this.data_[rightIndex], rightIndex) + | 46 this.getXForDatum_(this.data_[rightIndex], rightIndex) + |
47 this.getSampleWidth_(this.data_, rightIndex, false)); | 47 this.getSampleWidth_(this.data_, rightIndex, false)); |
48 return brushRange; | 48 return brushRange; |
49 }, | 49 }, |
50 | 50 |
51 getDataIndex_(dataX) { | 51 getDataIndex_(dataX) { |
(...skipping 27 matching lines...) Expand all Loading... |
79 .attr('width', d => this.xScale_(d.max) - this.xScale_(d.min)) | 79 .attr('width', d => this.xScale_(d.max) - this.xScale_(d.min)) |
80 .attr('height', this.graphHeight); | 80 .attr('height', this.graphHeight); |
81 } | 81 } |
82 }; | 82 }; |
83 | 83 |
84 return { | 84 return { |
85 ChartBase2DBrushX, | 85 ChartBase2DBrushX, |
86 }; | 86 }; |
87 }); | 87 }); |
88 </script> | 88 </script> |
OLD | NEW |