Index: packages/charted/lib/charts/data_transformers/transpose_transformer.dart |
diff --git a/packages/charted/lib/charts/data_transformers/transpose_transformer.dart b/packages/charted/lib/charts/data_transformers/transpose_transformer.dart |
index 2ed8e84686205014df72615c4b1548af0ad3bbe5..fcab1a0699fe0998550c8526f660e3d57d6d71cb 100644 |
--- a/packages/charted/lib/charts/data_transformers/transpose_transformer.dart |
+++ b/packages/charted/lib/charts/data_transformers/transpose_transformer.dart |
@@ -1,24 +1,22 @@ |
-/* |
- * Copyright 2014 Google Inc. All rights reserved. |
- * |
- * Use of this source code is governed by a BSD-style |
- * license that can be found in the LICENSE file or at |
- * https://developers.google.com/open-source/licenses/bsd |
- */ |
+// |
+// Copyright 2014 Google Inc. All rights reserved. |
+// |
+// Use of this source code is governed by a BSD-style |
+// license that can be found in the LICENSE file or at |
+// https://developers.google.com/open-source/licenses/bsd |
+// |
part of charted.charts; |
-/** |
- * Transforms the ChartData by transposing the columns and rows. A label column |
- * index in the original data will need to be specified (default to 0), all |
- * values in the specified label column will be used as the label for the |
- * transformed data, all the labels in the original Chart data columns will be |
- * populated in the label column as values of that column. |
- * |
- * All values in the data except for the data in the label column must have the |
- * same type; All columns except for the label column must have the same |
- * formatter if a formatter exist for columns. |
- */ |
+/// Transforms the ChartData by transposing the columns and rows. A label column |
+/// index in the original data will need to be specified (default to 0), all |
+/// values in the specified label column will be used as the label for the |
+/// transformed data, all the labels in the original Chart data columns will be |
+/// populated in the label column as values of that column. |
+/// |
+/// All values in the data except for the data in the label column must have the |
+/// same type; All columns except for the label column must have the same |
+/// formatter if a formatter exist for columns. |
class TransposeTransformer extends ChangeNotifier |
implements ChartDataTransform, ChartData { |
final SubscriptionsDisposer _dataSubscriptions = new SubscriptionsDisposer(); |
@@ -32,12 +30,10 @@ class TransposeTransformer extends ChangeNotifier |
TransposeTransformer([this._labelColumn = 0]); |
- /** |
- * Transforms the input data with the specified label column in the |
- * constructor. If the ChartData is Observable, changes fired by the input |
- * data will trigger transform to be performed again to update the output rows |
- * and columns. |
- */ |
+ /// Transforms the input data with the specified label column in the |
+ /// constructor. If the ChartData is Observable, changes fired by the input |
+ /// data will trigger transform to be performed again to update the output rows |
+ /// and columns. |
ChartData transform(ChartData data) { |
_data = data; |
_registerListeners(); |
@@ -45,11 +41,11 @@ class TransposeTransformer extends ChangeNotifier |
return this; |
} |
- /** Registers listeners if input ChartData is Observable. */ |
+ /// Registers listeners if input ChartData is Observable. |
_registerListeners() { |
_dataSubscriptions.dispose(); |
- if(_data is Observable) { |
+ if (_data is Observable) { |
var observable = (_data as Observable); |
_dataSubscriptions.add(observable.changes.listen((records) { |
_transform(); |
@@ -62,10 +58,8 @@ class TransposeTransformer extends ChangeNotifier |
} |
} |
- /** |
- * Performs the transpose transform with _data. This is called on transform |
- * and on changes if ChartData is Observable. |
- */ |
+ /// Performs the transpose transform with _data. This is called on transform |
+ /// and on changes if ChartData is Observable. |
_transform() { |
// Assert all columns are of the same type and formatter, excluding the |
// label column. |
@@ -88,7 +82,8 @@ class TransposeTransformer extends ChangeNotifier |
columns.clear(); |
rows.clear(); |
- rows.addAll(new List<Iterable>.generate(_data.columns.length - 1, (i) => [])); |
+ rows.addAll( |
+ new List<Iterable>.generate(_data.columns.length - 1, (i) => [])); |
// Populate the transposed rows' data, excluding the label column, visit |
// each value in the original data once. |
@@ -108,18 +103,19 @@ class TransposeTransformer extends ChangeNotifier |
// column that is used as the new label. |
for (var i = 0; i < rows.length; i++) { |
var columnOffset = (i < _labelColumn) ? 0 : 1; |
- (rows.elementAt(i) as List).insert(_labelColumn, |
- _data.columns.elementAt(i + columnOffset).label); |
- |
+ (rows.elementAt(i) as List).insert( |
+ _labelColumn, _data.columns.elementAt(i + columnOffset).label); |
} |
// Construct new ColumnSpaces base on the label column. |
for (var label in columnLabels) { |
- columns.add(new ChartColumnSpec(type: type, label: label, |
- formatter: formatter)); |
+ columns.add( |
+ new ChartColumnSpec(type: type, label: label, formatter: formatter)); |
} |
- columns.insert(_labelColumn, |
- new ChartColumnSpec(type: ChartColumnSpec.TYPE_STRING, label: |
- _data.columns.elementAt(_labelColumn).label)); |
+ columns.insert( |
+ _labelColumn, |
+ new ChartColumnSpec( |
+ type: ChartColumnSpec.TYPE_STRING, |
+ label: _data.columns.elementAt(_labelColumn).label)); |
} |
} |