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

Side by Side Diff: tracing/tracing/ui/base/scatter_chart.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
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 7
8 <link rel="import" href="/tracing/base/range.html"> 8 <link rel="import" href="/tracing/base/math/range.html">
9 <link rel="import" href="/tracing/ui/base/chart_base_2d.html"> 9 <link rel="import" href="/tracing/ui/base/chart_base_2d.html">
10 10
11 <script> 11 <script>
12 'use strict'; 12 'use strict';
13 13
14 tr.exportTo('tr.ui.b', function() { 14 tr.exportTo('tr.ui.b', function() {
15 var ScatterChart = tr.ui.b.define('scatter-chart', tr.ui.b.ChartBase2D); 15 var ScatterChart = tr.ui.b.define('scatter-chart', tr.ui.b.ChartBase2D);
16 16
17 // @constructor 17 // @constructor
18 ScatterChart.Dot = function(x, y, radius, color, breadcrumb) { 18 ScatterChart.Dot = function(x, y, radius, color, breadcrumb) {
19 this.x = x; 19 this.x = x;
20 this.y = y; 20 this.y = y;
21 this.radius = radius; 21 this.radius = radius;
22 this.color = color; 22 this.color = color;
23 this.breadcrumb = breadcrumb; 23 this.breadcrumb = breadcrumb;
24 }; 24 };
25 25
26 ScatterChart.prototype = { 26 ScatterChart.prototype = {
27 __proto__: tr.ui.b.ChartBase2D.prototype, 27 __proto__: tr.ui.b.ChartBase2D.prototype,
28 28
29 decorate() { 29 decorate() {
30 super.decorate(); 30 super.decorate();
31 this.brushedXRange_ = new tr.b.Range(); 31 this.brushedXRange_ = new tr.b.math.Range();
32 this.brushedYRange_ = new tr.b.Range(); 32 this.brushedYRange_ = new tr.b.math.Range();
33 }, 33 },
34 34
35 get hideLegend() { 35 get hideLegend() {
36 return true; 36 return true;
37 }, 37 },
38 38
39 get defaultGraphHeight() { 39 get defaultGraphHeight() {
40 return 100; 40 return 100;
41 }, 41 },
42 42
43 get defaultGraphWidth() { 43 get defaultGraphWidth() {
44 return 100; 44 return 100;
45 }, 45 },
46 46
47 updateMargins_() { 47 updateMargins_() {
48 super.updateMargins_(); 48 super.updateMargins_();
49 if (this.data.length === 0) return; 49 if (this.data.length === 0) return;
50 50
51 var rightOverhangPx = tr.b.Statistics.max( 51 var rightOverhangPx = tr.b.math.Statistics.max(
52 this.data, d => this.xScale_(d.x) + d.radius - this.graphWidth); 52 this.data, d => this.xScale_(d.x) + d.radius - this.graphWidth);
53 this.margin.right = Math.max(this.margin.right, rightOverhangPx); 53 this.margin.right = Math.max(this.margin.right, rightOverhangPx);
54 54
55 var topOverhangPx = tr.b.Statistics.max( 55 var topOverhangPx = tr.b.math.Statistics.max(
56 this.data, d => (this.graphHeight - this.yScale_(d.y)) + d.radius) - 56 this.data, d => (this.graphHeight - this.yScale_(d.y)) + d.radius) -
57 this.graphHeight; 57 this.graphHeight;
58 this.margin.top = Math.max(this.margin.top, topOverhangPx); 58 this.margin.top = Math.max(this.margin.top, topOverhangPx);
59 }, 59 },
60 60
61 setBrushedRanges(xRange, yRange) { 61 setBrushedRanges(xRange, yRange) {
62 this.brushedXRange_.reset(); 62 this.brushedXRange_.reset();
63 this.brushedYRange_.reset(); 63 this.brushedYRange_.reset();
64 this.brushedXRange_.addRange(xRange); 64 this.brushedXRange_.addRange(xRange);
65 this.brushedYRange_.addRange(yRange); 65 this.brushedYRange_.addRange(yRange);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 .attr('r', d => d.radius) 101 .attr('r', d => d.radius)
102 .attr('fill', d => d.color); 102 .attr('fill', d => d.color);
103 } 103 }
104 }; 104 };
105 105
106 return { 106 return {
107 ScatterChart, 107 ScatterChart,
108 }; 108 };
109 }); 109 });
110 </script> 110 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/ui/base/quad_stack_view.html ('k') | tracing/tracing/ui/base/scatter_chart_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698