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

Unified Diff: packages/charted/lib/layout/src/hierarchy_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/charted/lib/core/utils/rect.dart ('k') | packages/charted/lib/layout/src/pie_layout.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/charted/lib/layout/src/hierarchy_layout.dart
diff --git a/packages/charted/lib/layout/src/hierarchy_layout.dart b/packages/charted/lib/layout/src/hierarchy_layout.dart
index 9997ab06ca9e518dec603d1e9bc78a5ccf691a4a..f4da426ad002f5c60b775c31be68f548654d38a7 100644
--- a/packages/charted/lib/layout/src/hierarchy_layout.dart
+++ b/packages/charted/lib/layout/src/hierarchy_layout.dart
@@ -28,7 +28,7 @@ abstract class HierarchyLayout<T extends HierarchyNode> {
/// first element its children in depth first order.
List<T> layout(
List rows, int parentColumn, int labelColumn, int valueColumn) {
- List<HierarchyNode> nodeList = [];
+ List<T> nodeList = [];
for (var row in rows) {
nodeList.add(createNode(row[labelColumn], row[valueColumn], 0));
}
@@ -38,9 +38,7 @@ abstract class HierarchyLayout<T extends HierarchyNode> {
if (parentRow == ROOT_ROW_INDEX) continue;
var currentNode = nodeList[i];
var parentNode = nodeList[parentRow];
- (parentNode.children.isEmpty)
- ? parentNode.children = [currentNode]
- : parentNode.children.add(currentNode);
+ parentNode.children.add(currentNode);
currentNode.parent = parentNode;
currentNode.depth = parentNode.depth + 1;
for (var child in currentNode.children) {
@@ -50,9 +48,9 @@ abstract class HierarchyLayout<T extends HierarchyNode> {
// Reorder the list so that root is the first element and the list contains
// the hierarchy of nodes in depth first order.
- var hierarchyNodeList = [];
+ var hierarchyNodeList = <HierarchyNode>[];
var root = nodeList.where((e) => e.depth == 0).elementAt(0);
- var children = [root];
+ var children = <HierarchyNode>[root];
while (children.length > 0) {
var node = children.removeLast();
children.addAll(node.children);
@@ -80,7 +78,7 @@ abstract class HierarchyNode {
HierarchyNode parent = null;
/// The list of children nodes, or null for leaf nodes.
- List children = [];
+ List<HierarchyNode> get children;
/// The label to show for each block of hierarchy
String label = '';
« no previous file with comments | « packages/charted/lib/core/utils/rect.dart ('k') | packages/charted/lib/layout/src/pie_layout.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698