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

Side by Side Diff: packages/charted/lib/charts/behaviors/axis_label_tooltip.dart

Issue 2213693002: Updated charted DEP to 0.4.X (Closed) Base URL: https://github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 4 years, 4 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 // 1 //
2 // Copyright 2014 Google Inc. All rights reserved. 2 // Copyright 2014 Google Inc. All rights reserved.
3 // 3 //
4 // Use of this source code is governed by a BSD-style 4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at 5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd 6 // https://developers.google.com/open-source/licenses/bsd
7 // 7 //
8 8
9 part of charted.charts; 9 part of charted.charts;
10 10
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 void dispose() { 33 void dispose() {
34 _disposer.dispose(); 34 _disposer.dispose();
35 if (_tooltipRoot != null) _tooltipRoot.remove(); 35 if (_tooltipRoot != null) _tooltipRoot.remove();
36 } 36 }
37 37
38 void _subscribe() { 38 void _subscribe() {
39 var elements = _area.host.querySelectorAll(_AXIS_SELECTOR); 39 var elements = _area.host.querySelectorAll(_AXIS_SELECTOR);
40 _disposer.dispose(); 40 _disposer.dispose();
41 _disposer 41 _disposer.addAll(
42 .addAll(elements.map((x) => x.onMouseOver.listen(_handleMouseOver))); 42 elements.map((Element x) => x.onMouseOver.listen(_handleMouseOver)));
43 _disposer.addAll(elements.map((x) => x.onMouseOut.listen(_handleMouseOut))); 43 _disposer.addAll(elements.map((x) => x.onMouseOut.listen(_handleMouseOut)));
44 } 44 }
45 45
46 void _handleMouseOver(MouseEvent e) { 46 void _handleMouseOver(MouseEvent e) {
47 Element target = e.target; 47 Element target = e.target;
48 if (!target.dataset.containsKey('detail')) return; 48 if (!target.dataset.containsKey('detail')) return;
49 ensureTooltipRoot(); 49 ensureTooltipRoot();
50 ensureRenderAreaRect(); 50 ensureRenderAreaRect();
51 51
52 _tooltipRoot.text = target.dataset['detail']; 52 _tooltipRoot.text = target.dataset['detail'];
(...skipping 28 matching lines...) Expand all
81 } else { 81 } else {
82 _tooltipRoot.classes.remove('rtl'); 82 _tooltipRoot.classes.remove('rtl');
83 } 83 }
84 _area.host.append(_tooltipRoot); 84 _area.host.append(_tooltipRoot);
85 } 85 }
86 } 86 }
87 87
88 void ensureRenderAreaRect() { 88 void ensureRenderAreaRect() {
89 var layout = _area.layout; 89 var layout = _area.layout;
90 _hostAreaRect = _area.host.getBoundingClientRect(); 90 _hostAreaRect = _area.host.getBoundingClientRect();
91 _renderAreaRect = new math.Rectangle( 91 _renderAreaRect = new math.Rectangle<num>(
92 _hostAreaRect.left + layout.chartArea.x + layout.renderArea.x, 92 _hostAreaRect.left + layout.chartArea.x + layout.renderArea.x,
93 _hostAreaRect.top + layout.chartArea.y + layout.renderArea.y, 93 _hostAreaRect.top + layout.chartArea.y + layout.renderArea.y,
94 layout.renderArea.width, 94 layout.renderArea.width,
95 layout.renderArea.height); 95 layout.renderArea.height);
96 } 96 }
97 97
98 /// Computes the ideal tooltip position based on orientation. 98 /// Computes the ideal tooltip position based on orientation.
99 math.Point computeTooltipPosition( 99 math.Point computeTooltipPosition(
100 math.Rectangle label, math.Rectangle tooltip, math.Rectangle renderArea) { 100 math.Rectangle label, math.Rectangle tooltip, math.Rectangle renderArea) {
101 var x = label.left + (label.width - tooltip.width) / 2, 101 var x = label.left + (label.width - tooltip.width) / 2,
102 y = label.top + (label.height - tooltip.height) / 2; 102 y = label.top + (label.height - tooltip.height) / 2;
103 103
104 if (x + tooltip.width > renderArea.right) { 104 if (x + tooltip.width > renderArea.right) {
105 x = renderArea.right - tooltip.width; 105 x = renderArea.right - tooltip.width;
106 } else if (x < renderArea.left) { 106 } else if (x < renderArea.left) {
107 x = renderArea.left; 107 x = renderArea.left;
108 } 108 }
109 109
110 if (y + tooltip.height > renderArea.bottom) { 110 if (y + tooltip.height > renderArea.bottom) {
111 y = renderArea.bottom - tooltip.height; 111 y = renderArea.bottom - tooltip.height;
112 } else if (y < renderArea.top) { 112 } else if (y < renderArea.top) {
113 y = renderArea.top; 113 y = renderArea.top;
114 } 114 }
115 115
116 return new math.Point(x - _hostAreaRect.left, y - _hostAreaRect.top); 116 return new math.Point(x - _hostAreaRect.left, y - _hostAreaRect.top);
117 } 117 }
118 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698