OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 2016 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/name_line_chart.html"> | 8 <link rel="import" href="/tracing/ui/base/name_line_chart.html"> |
9 | 9 |
10 <script> | 10 <script> |
(...skipping 21 matching lines...) Expand all Loading... |
32 test('instantiation_twoSeries', function() { | 32 test('instantiation_twoSeries', function() { |
33 var chart = new tr.ui.b.NameLineChart(); | 33 var chart = new tr.ui.b.NameLineChart(); |
34 this.addHTMLOutput(chart); | 34 this.addHTMLOutput(chart); |
35 chart.data = [ | 35 chart.data = [ |
36 {x: 'apple', alpha: 100, beta: 50}, | 36 {x: 'apple', alpha: 100, beta: 50}, |
37 {x: 'ball', alpha: 110, beta: 75}, | 37 {x: 'ball', alpha: 110, beta: 75}, |
38 {x: 'cat', alpha: 100, beta: 125}, | 38 {x: 'cat', alpha: 100, beta: 125}, |
39 {x: 'dog', alpha: 50, beta: 125} | 39 {x: 'dog', alpha: 50, beta: 125} |
40 ]; | 40 ]; |
41 | 41 |
42 var r = new tr.b.Range(); | 42 var r = new tr.b.math.Range(); |
43 r.addValue(20); | 43 r.addValue(20); |
44 r.addValue(40); | 44 r.addValue(40); |
45 chart.brushedRange = r; | 45 chart.brushedRange = r; |
46 }); | 46 }); |
47 | 47 |
48 test('instantiation_twoSparseSeriesWithFirstValueSparse', function() { | 48 test('instantiation_twoSparseSeriesWithFirstValueSparse', function() { |
49 var chart = new tr.ui.b.NameLineChart(); | 49 var chart = new tr.ui.b.NameLineChart(); |
50 this.addHTMLOutput(chart); | 50 this.addHTMLOutput(chart); |
51 chart.data = [ | 51 chart.data = [ |
52 {x: 'apple', alpha: 20, beta: undefined}, | 52 {x: 'apple', alpha: 20, beta: undefined}, |
(...skipping 27 matching lines...) Expand all Loading... |
80 {x: 'echo', value: 30}, | 80 {x: 'echo', value: 30}, |
81 {x: 'fortune', value: 20}, | 81 {x: 'fortune', value: 20}, |
82 {x: 'gpu', value: 15}, | 82 {x: 'gpu', value: 15}, |
83 {x: 'happy', value: 20} | 83 {x: 'happy', value: 20} |
84 ]; | 84 ]; |
85 | 85 |
86 var mouseDownIndex = undefined; | 86 var mouseDownIndex = undefined; |
87 var currentMouseIndex = undefined; | 87 var currentMouseIndex = undefined; |
88 | 88 |
89 function updateBrushedRange() { | 89 function updateBrushedRange() { |
90 var r = new tr.b.Range(); | 90 var r = new tr.b.math.Range(); |
91 r.min = Math.max(0, Math.min(mouseDownIndex, currentMouseIndex)); | 91 r.min = Math.max(0, Math.min(mouseDownIndex, currentMouseIndex)); |
92 r.max = Math.min(chart.data.length, Math.max(mouseDownIndex, | 92 r.max = Math.min(chart.data.length, Math.max(mouseDownIndex, |
93 currentMouseIndex) + 1); | 93 currentMouseIndex) + 1); |
94 chart.brushedRange = r; | 94 chart.brushedRange = r; |
95 } | 95 } |
96 | 96 |
97 chart.addEventListener('item-mousedown', function(e) { | 97 chart.addEventListener('item-mousedown', function(e) { |
98 mouseDownIndex = e.index; | 98 mouseDownIndex = e.index; |
99 currentMouseIndex = e.index; | 99 currentMouseIndex = e.index; |
100 updateBrushedRange(); | 100 updateBrushedRange(); |
101 }); | 101 }); |
102 chart.addEventListener('item-mousemove', function(e) { | 102 chart.addEventListener('item-mousemove', function(e) { |
103 if (e.button === undefined) | 103 if (e.button === undefined) |
104 return; | 104 return; |
105 currentMouseIndex = e.index; | 105 currentMouseIndex = e.index; |
106 updateBrushedRange(); | 106 updateBrushedRange(); |
107 }); | 107 }); |
108 chart.addEventListener('item-mouseup', function(e) { | 108 chart.addEventListener('item-mouseup', function(e) { |
109 currentMouseIndex = e.index; | 109 currentMouseIndex = e.index; |
110 updateBrushedRange(); | 110 updateBrushedRange(); |
111 }); | 111 }); |
112 }); | 112 }); |
113 }); | 113 }); |
114 </script> | 114 </script> |
OLD | NEW |