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/name_column_chart.html"> | 8 <link rel="import" href="/tracing/ui/base/name_column_chart.html"> |
9 | 9 |
10 <script> | 10 <script> |
(...skipping 26 matching lines...) Expand all Loading... |
37 test('instantiation_twoSeries', function() { | 37 test('instantiation_twoSeries', function() { |
38 var chart = new tr.ui.b.NameColumnChart(); | 38 var chart = new tr.ui.b.NameColumnChart(); |
39 this.addHTMLOutput(chart); | 39 this.addHTMLOutput(chart); |
40 chart.data = [ | 40 chart.data = [ |
41 {x: 'apple', alpha: 100, beta: 50}, | 41 {x: 'apple', alpha: 100, beta: 50}, |
42 {x: 'ball', alpha: 110, beta: 75}, | 42 {x: 'ball', alpha: 110, beta: 75}, |
43 {x: 'cat', alpha: 100, beta: 125}, | 43 {x: 'cat', alpha: 100, beta: 125}, |
44 {x: 'dog', alpha: 50, beta: 125} | 44 {x: 'dog', alpha: 50, beta: 125} |
45 ]; | 45 ]; |
46 | 46 |
47 var r = new tr.b.Range(); | 47 var r = new tr.b.math.Range(); |
48 r.addValue(20); | 48 r.addValue(20); |
49 r.addValue(40); | 49 r.addValue(40); |
50 chart.brushedRange = r; | 50 chart.brushedRange = r; |
51 }); | 51 }); |
52 | 52 |
53 test('instantiation_twoSparseSeriesWithFirstValueSparse', function() { | 53 test('instantiation_twoSparseSeriesWithFirstValueSparse', function() { |
54 var chart = new tr.ui.b.NameColumnChart(); | 54 var chart = new tr.ui.b.NameColumnChart(); |
55 this.addHTMLOutput(chart); | 55 this.addHTMLOutput(chart); |
56 chart.data = [ | 56 chart.data = [ |
57 {x: 'apple', alpha: 20, beta: undefined}, | 57 {x: 'apple', alpha: 20, beta: undefined}, |
(...skipping 27 matching lines...) Expand all Loading... |
85 {x: 'echo', value: 30}, | 85 {x: 'echo', value: 30}, |
86 {x: 'fortune', value: 20}, | 86 {x: 'fortune', value: 20}, |
87 {x: 'gpu', value: 15}, | 87 {x: 'gpu', value: 15}, |
88 {x: 'happy', value: 20} | 88 {x: 'happy', value: 20} |
89 ]; | 89 ]; |
90 | 90 |
91 var mouseDownIndex = undefined; | 91 var mouseDownIndex = undefined; |
92 var currentMouseIndex = undefined; | 92 var currentMouseIndex = undefined; |
93 | 93 |
94 function updateBrushedRange() { | 94 function updateBrushedRange() { |
95 var r = new tr.b.Range(); | 95 var r = new tr.b.math.Range(); |
96 r.min = Math.max(0, Math.min(mouseDownIndex, currentMouseIndex)); | 96 r.min = Math.max(0, Math.min(mouseDownIndex, currentMouseIndex)); |
97 r.max = Math.min(chart.data.length, | 97 r.max = Math.min(chart.data.length, |
98 Math.max(mouseDownIndex, currentMouseIndex) + 1); | 98 Math.max(mouseDownIndex, currentMouseIndex) + 1); |
99 chart.brushedRange = r; | 99 chart.brushedRange = r; |
100 } | 100 } |
101 | 101 |
102 chart.addEventListener('item-mousedown', function(e) { | 102 chart.addEventListener('item-mousedown', function(e) { |
103 mouseDownIndex = e.index; | 103 mouseDownIndex = e.index; |
104 currentMouseIndex = e.index; | 104 currentMouseIndex = e.index; |
105 updateBrushedRange(); | 105 updateBrushedRange(); |
106 }); | 106 }); |
107 chart.addEventListener('item-mousemove', function(e) { | 107 chart.addEventListener('item-mousemove', function(e) { |
108 if (e.button === undefined) | 108 if (e.button === undefined) |
109 return; | 109 return; |
110 currentMouseIndex = e.index; | 110 currentMouseIndex = e.index; |
111 updateBrushedRange(); | 111 updateBrushedRange(); |
112 }); | 112 }); |
113 chart.addEventListener('item-mouseup', function(e) { | 113 chart.addEventListener('item-mouseup', function(e) { |
114 currentMouseIndex = e.index; | 114 currentMouseIndex = e.index; |
115 updateBrushedRange(); | 115 updateBrushedRange(); |
116 }); | 116 }); |
117 }); | 117 }); |
118 }); | 118 }); |
119 </script> | 119 </script> |
OLD | NEW |