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

Side by Side Diff: tracing/tracing/ui/base/line_chart_test.html

Issue 2771723003: [tracing] Move math utilities from base into their own subdirectory (attempt 2) (Closed)
Patch Set: rebase 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
« no previous file with comments | « tracing/tracing/ui/base/draw_helpers.html ('k') | tracing/tracing/ui/base/name_bar_chart.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <link rel="import" href="/tracing/ui/base/line_chart.html"> 7 <link rel="import" href="/tracing/ui/base/line_chart.html">
8 <script> 8 <script>
9 'use strict'; 9 'use strict';
10 10
(...skipping 12 matching lines...) Expand all
23 test('instantiation_twoSeries', function() { 23 test('instantiation_twoSeries', function() {
24 var chart = new tr.ui.b.LineChart(); 24 var chart = new tr.ui.b.LineChart();
25 this.addHTMLOutput(chart); 25 this.addHTMLOutput(chart);
26 chart.data = [ 26 chart.data = [
27 {x: 10, alpha: 100, beta: 50}, 27 {x: 10, alpha: 100, beta: 50},
28 {x: 20, alpha: 110, beta: 75}, 28 {x: 20, alpha: 110, beta: 75},
29 {x: 30, alpha: 100, beta: 125}, 29 {x: 30, alpha: 100, beta: 125},
30 {x: 40, alpha: 50, beta: 125} 30 {x: 40, alpha: 50, beta: 125}
31 ]; 31 ];
32 32
33 var r = new tr.b.Range(); 33 var r = new tr.b.math.Range();
34 r.addValue(20); 34 r.addValue(20);
35 r.addValue(40); 35 r.addValue(40);
36 chart.brushedRange = r; 36 chart.brushedRange = r;
37 }); 37 });
38 38
39 test('instantiation_twoSparseSeriesWithFirstValueSparse', function() { 39 test('instantiation_twoSparseSeriesWithFirstValueSparse', function() {
40 var chart = new tr.ui.b.LineChart(); 40 var chart = new tr.ui.b.LineChart();
41 this.addHTMLOutput(chart); 41 this.addHTMLOutput(chart);
42 chart.data = [ 42 chart.data = [
43 {x: 10, alpha: 20, beta: undefined}, 43 {x: 10, alpha: 20, beta: undefined},
(...skipping 19 matching lines...) Expand all
63 test('brushRangeFromIndices', function() { 63 test('brushRangeFromIndices', function() {
64 var chart = new tr.ui.b.LineChart(); 64 var chart = new tr.ui.b.LineChart();
65 this.addHTMLOutput(chart); 65 this.addHTMLOutput(chart);
66 chart.data = [ 66 chart.data = [
67 {x: 10, value: 50}, 67 {x: 10, value: 50},
68 {x: 30, value: 60}, 68 {x: 30, value: 60},
69 {x: 70, value: 70}, 69 {x: 70, value: 70},
70 {x: 80, value: 80}, 70 {x: 80, value: 80},
71 {x: 120, value: 90} 71 {x: 120, value: 90}
72 ]; 72 ];
73 var r = new tr.b.Range(); 73 var r = new tr.b.math.Range();
74 74
75 // Range min should be 10. 75 // Range min should be 10.
76 r = chart.computeBrushRangeFromIndices(-2, 1); 76 r = chart.computeBrushRangeFromIndices(-2, 1);
77 assert.equal(r.min, 10); 77 assert.equal(r.min, 10);
78 78
79 // Range max should be 120. 79 // Range max should be 120.
80 r = chart.computeBrushRangeFromIndices(3, 10); 80 r = chart.computeBrushRangeFromIndices(3, 10);
81 assert.equal(r.max, 120); 81 assert.equal(r.max, 120);
82 82
83 // Range should be [10, 120] 83 // Range should be [10, 120]
(...skipping 19 matching lines...) Expand all
103 {x: 60, value: 20}, 103 {x: 60, value: 20},
104 {x: 70, value: 15}, 104 {x: 70, value: 15},
105 {x: 80, value: 20} 105 {x: 80, value: 20}
106 ]; 106 ];
107 107
108 var mouseDownIndex = undefined; 108 var mouseDownIndex = undefined;
109 var curMouseIndex = undefined; 109 var curMouseIndex = undefined;
110 110
111 function updateBrushedRange() { 111 function updateBrushedRange() {
112 if (mouseDownIndex === undefined) { 112 if (mouseDownIndex === undefined) {
113 chart.brushedRange = new tr.b.Range(); 113 chart.brushedRange = new tr.b.math.Range();
114 return; 114 return;
115 } 115 }
116 chart.brushedRange = chart.computeBrushRangeFromIndices( 116 chart.brushedRange = chart.computeBrushRangeFromIndices(
117 mouseDownIndex, curMouseIndex); 117 mouseDownIndex, curMouseIndex);
118 } 118 }
119 119
120 chart.addEventListener('item-mousedown', function(e) { 120 chart.addEventListener('item-mousedown', function(e) {
121 mouseDownIndex = e.index; 121 mouseDownIndex = e.index;
122 curMouseIndex = e.index; 122 curMouseIndex = e.index;
123 updateBrushedRange(); 123 updateBrushedRange();
124 }); 124 });
125 chart.addEventListener('item-mousemove', function(e) { 125 chart.addEventListener('item-mousemove', function(e) {
126 if (e.button === undefined) 126 if (e.button === undefined)
127 return; 127 return;
128 curMouseIndex = e.index; 128 curMouseIndex = e.index;
129 updateBrushedRange(); 129 updateBrushedRange();
130 }); 130 });
131 chart.addEventListener('item-mouseup', function(e) { 131 chart.addEventListener('item-mouseup', function(e) {
132 curMouseIndex = e.index; 132 curMouseIndex = e.index;
133 updateBrushedRange(); 133 updateBrushedRange();
134 }); 134 });
135 }); 135 });
136 136
137 test('overrideDataRange', function() { 137 test('overrideDataRange', function() {
138 var chart = new tr.ui.b.LineChart(); 138 var chart = new tr.ui.b.LineChart();
139 this.addHTMLOutput(chart); 139 this.addHTMLOutput(chart);
140 chart.overrideDataRange = tr.b.Range.fromExplicitRange(10, 90); 140 chart.overrideDataRange = tr.b.math.Range.fromExplicitRange(10, 90);
141 chart.data = [ 141 chart.data = [
142 {x: 0, value: 0}, 142 {x: 0, value: 0},
143 {x: 1, value: 100}, 143 {x: 1, value: 100},
144 ]; 144 ];
145 145
146 chart = new tr.ui.b.LineChart(); 146 chart = new tr.ui.b.LineChart();
147 this.addHTMLOutput(chart); 147 this.addHTMLOutput(chart);
148 chart.overrideDataRange = tr.b.Range.fromExplicitRange(-10, 100); 148 chart.overrideDataRange = tr.b.math.Range.fromExplicitRange(-10, 100);
149 chart.data = [ 149 chart.data = [
150 {x: 0, value: 0}, 150 {x: 0, value: 0},
151 {x: 1, value: 50}, 151 {x: 1, value: 50},
152 ]; 152 ];
153 }); 153 });
154 }); 154 });
155 </script> 155 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/ui/base/draw_helpers.html ('k') | tracing/tracing/ui/base/name_bar_chart.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698