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

Side by Side Diff: packages/charted/lib/layout/src/treemap_layout.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 2015 Google Inc. All rights reserved. 2 * Copyright 2015 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 part of charted.layout; 8 part of charted.layout;
9 9
10 /// PaddingFunction takes a node and generates the padding for the particular 10 /// PaddingFunction takes a node and generates the padding for the particular
11 /// node 11 /// node
12 typedef List PaddingFunction(TreeMapNode node); 12 typedef List PaddingFunction(TreeMapNode node);
13 13
14 /** 14 /**
15 * Utility layout class which recursively subdivides area into rectangles which 15 * Utility layout class which recursively subdivides area into rectangles which
16 * can be used to quickly visualize the size of any node in the tree. 16 * can be used to quickly visualize the size of any node in the tree.
17 */ 17 */
18 class TreeMapLayout extends HierarchyLayout { 18 class TreeMapLayout extends HierarchyLayout<TreeMapNode> {
19 /// Rectangular subdivision; squareness controlled via the target ratio. 19 /// Rectangular subdivision; squareness controlled via the target ratio.
20 static const TREEMAP_LAYOUT_SQUARIFY = 0; 20 static const TREEMAP_LAYOUT_SQUARIFY = 0;
21 21
22 /// Horizontal subdivision. 22 /// Horizontal subdivision.
23 static const TREEMAP_LAYOUT_SLICE = 1; 23 static const TREEMAP_LAYOUT_SLICE = 1;
24 24
25 /// Vertical subdivision. 25 /// Vertical subdivision.
26 static const TREEMAP_LAYOUT_DICE = 2; 26 static const TREEMAP_LAYOUT_DICE = 2;
27 27
28 /// Alternating between horizontal and vertical subdivision. 28 /// Alternating between horizontal and vertical subdivision.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 156 }
157 157
158 /// Recursively compute each nodes (and its children nodes) position and size 158 /// Recursively compute each nodes (and its children nodes) position and size
159 /// base on the node's property and layout mode. 159 /// base on the node's property and layout mode.
160 void _squarify(TreeMapNode node) { 160 void _squarify(TreeMapNode node) {
161 var children = node.children; 161 var children = node.children;
162 if (children.isNotEmpty) { 162 if (children.isNotEmpty) {
163 var rect = _treeMapPad(node, paddingFunction(node)); 163 var rect = _treeMapPad(node, paddingFunction(node));
164 List<TreeMapNode> nodes = []; 164 List<TreeMapNode> nodes = [];
165 var area = 0; 165 var area = 0;
166 var remaining = new List.from(children); 166 var remaining = new List<TreeMapNode>.from(children);
167 var score, 167 var score,
168 n, 168 n,
169 best = double.INFINITY, 169 best = double.INFINITY,
170 length = (mode == TREEMAP_LAYOUT_SLICE) 170 length = (mode == TREEMAP_LAYOUT_SLICE)
171 ? rect.width 171 ? rect.width
172 : (mode == TREEMAP_LAYOUT_DICE) 172 : (mode == TREEMAP_LAYOUT_DICE)
173 ? rect.height 173 ? rect.height
174 : (mode == TREEMAP_LAYOUT_SLICE_DICE) 174 : (mode == TREEMAP_LAYOUT_SLICE_DICE)
175 ? (node.depth & 1 == 1) ? rect.height : rect.width 175 ? (node.depth & 1 == 1) ? rect.height : rect.width
176 : math.min(rect.width, rect.height); 176 : math.min(rect.width, rect.height);
(...skipping 19 matching lines...) Expand all
196 _position(nodes, length, rect, true, area); 196 _position(nodes, length, rect, true, area);
197 nodes.clear(); 197 nodes.clear();
198 area = 0; 198 area = 0;
199 } 199 }
200 children.forEach(_squarify); 200 children.forEach(_squarify);
201 } 201 }
202 } 202 }
203 } 203 }
204 204
205 class TreeMapNode extends HierarchyNode { 205 class TreeMapNode extends HierarchyNode {
206 final List<TreeMapNode> children = <TreeMapNode>[];
207
206 /// The minimum x-coordinate of the node position. 208 /// The minimum x-coordinate of the node position.
207 num x = 0; 209 num x = 0;
208 210
209 /// The minimum y-coordinate of the node position. 211 /// The minimum y-coordinate of the node position.
210 num y = 0; 212 num y = 0;
211 213
212 /// The x-extent of the node position. 214 /// The x-extent of the node position.
213 num dx = 0; 215 num dx = 0;
214 216
215 /// The y-extent of the node position. 217 /// The y-extent of the node position.
216 num dy = 0; 218 num dy = 0;
217 219
218 /// The area the node should take up. 220 /// The area the node should take up.
219 num area = 0; 221 num area = 0;
220 222
221 /// Attribute for the last node in the row, only used for sticky layout. 223 /// Attribute for the last node in the row, only used for sticky layout.
222 bool sticky = false; 224 bool sticky = false;
223 } 225 }
OLDNEW
« no previous file with comments | « packages/charted/lib/layout/src/pie_layout.dart ('k') | packages/charted/lib/locale/format/number_format.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698