| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2015 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2015 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/color_scheme.html"> | 8 <link rel="import" href="/tracing/base/color_scheme.html"> |
| 9 <link rel="import" href="/tracing/base/range.html"> | 9 <link rel="import" href="/tracing/base/math/range.html"> |
| 10 <link rel="import" href="/tracing/base/unit.html"> | 10 <link rel="import" href="/tracing/base/unit.html"> |
| 11 | 11 |
| 12 <script> | 12 <script> |
| 13 'use strict'; | 13 'use strict'; |
| 14 | 14 |
| 15 tr.exportTo('tr.ui.tracks', function() { | 15 tr.exportTo('tr.ui.tracks', function() { |
| 16 var ColorScheme = tr.b.ColorScheme; | 16 var ColorScheme = tr.b.ColorScheme; |
| 17 var IDEAL_MAJOR_MARK_HEIGHT_PX = 30; | 17 var IDEAL_MAJOR_MARK_HEIGHT_PX = 30; |
| 18 var AXIS_LABLE_MARGIN_PX = 10; | 18 var AXIS_LABLE_MARGIN_PX = 10; |
| 19 var AXIS_LABLE_FONT_SIZE_PX = 9; | 19 var AXIS_LABLE_FONT_SIZE_PX = 9; |
| 20 var AXIS_LABLE_FONT = 'Arial'; | 20 var AXIS_LABLE_FONT = 'Arial'; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * A vertical axis for a (set of) chart series which maps an arbitrary range | 23 * A vertical axis for a (set of) chart series which maps an arbitrary range |
| 24 * of values [min, max] to the unit range [0, 1]. | 24 * of values [min, max] to the unit range [0, 1]. |
| 25 * | 25 * |
| 26 * @constructor | 26 * @constructor |
| 27 */ | 27 */ |
| 28 function ChartSeriesYAxis(opt_min, opt_max) { | 28 function ChartSeriesYAxis(opt_min, opt_max) { |
| 29 this.guid_ = tr.b.GUID.allocateSimple(); | 29 this.guid_ = tr.b.GUID.allocateSimple(); |
| 30 this.bounds = new tr.b.Range(); | 30 this.bounds = new tr.b.math.Range(); |
| 31 if (opt_min !== undefined) | 31 if (opt_min !== undefined) |
| 32 this.bounds.addValue(opt_min); | 32 this.bounds.addValue(opt_min); |
| 33 if (opt_max !== undefined) | 33 if (opt_max !== undefined) |
| 34 this.bounds.addValue(opt_max); | 34 this.bounds.addValue(opt_max); |
| 35 } | 35 } |
| 36 | 36 |
| 37 ChartSeriesYAxis.prototype = { | 37 ChartSeriesYAxis.prototype = { |
| 38 get guid() { | 38 get guid() { |
| 39 return this.guid_; | 39 return this.guid_; |
| 40 }, | 40 }, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 56 }, | 56 }, |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * Automatically set the y-axis bounds from the range of values of all | 59 * Automatically set the y-axis bounds from the range of values of all |
| 60 * series in a list. | 60 * series in a list. |
| 61 * | 61 * |
| 62 * See the description of autoSetFromRange for the optional configuration | 62 * See the description of autoSetFromRange for the optional configuration |
| 63 * argument flags. | 63 * argument flags. |
| 64 */ | 64 */ |
| 65 autoSetFromSeries: function(series, opt_config) { | 65 autoSetFromSeries: function(series, opt_config) { |
| 66 var range = new tr.b.Range(); | 66 var range = new tr.b.math.Range(); |
| 67 series.forEach(function(s) { | 67 series.forEach(function(s) { |
| 68 range.addRange(s.range); | 68 range.addRange(s.range); |
| 69 }, this); | 69 }, this); |
| 70 this.autoSetFromRange(range, opt_config); | 70 this.autoSetFromRange(range, opt_config); |
| 71 }, | 71 }, |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * Automatically set the y-axis bound from a range of values. | 74 * Automatically set the y-axis bound from a range of values. |
| 75 * | 75 * |
| 76 * The following four flags, which affect the behavior of this method with | 76 * The following four flags, which affect the behavior of this method with |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 bounds.max = Math.max(range.max, bounds.min); | 132 bounds.max = Math.max(range.max, bounds.min); |
| 133 } | 133 } |
| 134 }, | 134 }, |
| 135 | 135 |
| 136 | 136 |
| 137 majorMarkHeightWorld_: function(transform, pixelRatio) { | 137 majorMarkHeightWorld_: function(transform, pixelRatio) { |
| 138 var idealMajorMarkHeightPx = IDEAL_MAJOR_MARK_HEIGHT_PX * pixelRatio; | 138 var idealMajorMarkHeightPx = IDEAL_MAJOR_MARK_HEIGHT_PX * pixelRatio; |
| 139 var idealMajorMarkHeightWorld = | 139 var idealMajorMarkHeightWorld = |
| 140 transform.vectorToWorldDistance(idealMajorMarkHeightPx); | 140 transform.vectorToWorldDistance(idealMajorMarkHeightPx); |
| 141 | 141 |
| 142 return tr.b.preferredNumberLargerThanMin(idealMajorMarkHeightWorld); | 142 return tr.b.math.preferredNumberLargerThanMin(idealMajorMarkHeightWorld); |
| 143 }, | 143 }, |
| 144 | 144 |
| 145 draw: function(ctx, transform, showYAxisLabels, showYGridLines) { | 145 draw: function(ctx, transform, showYAxisLabels, showYGridLines) { |
| 146 if (!showYAxisLabels && !showYGridLines) return; | 146 if (!showYAxisLabels && !showYGridLines) return; |
| 147 | 147 |
| 148 var pixelRatio = transform.pixelRatio; | 148 var pixelRatio = transform.pixelRatio; |
| 149 var viewTop = transform.outerTopViewY; | 149 var viewTop = transform.outerTopViewY; |
| 150 var worldTop = transform.viewYToWorldY(viewTop); | 150 var worldTop = transform.viewYToWorldY(viewTop); |
| 151 var viewBottom = transform.outerBottomViewY; | 151 var viewBottom = transform.outerBottomViewY; |
| 152 var viewHeight = viewBottom - viewTop; | 152 var viewHeight = viewBottom - viewTop; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 ctx.stroke(); | 209 ctx.stroke(); |
| 210 ctx.restore(); | 210 ctx.restore(); |
| 211 } | 211 } |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 return { | 214 return { |
| 215 ChartSeriesYAxis, | 215 ChartSeriesYAxis, |
| 216 }; | 216 }; |
| 217 }); | 217 }); |
| 218 </script> | 218 </script> |
| OLD | NEW |