Index: packages/charted/lib/charts/data_transformers/filter_transformer.dart |
diff --git a/packages/charted/lib/charts/data_transformers/filter_transformer.dart b/packages/charted/lib/charts/data_transformers/filter_transformer.dart |
index 393c453f6fbb85dba29b18ae610b29ad110c5c7a..bc12597a632b5f26efab0e604d35df44f77d4ccd 100644 |
--- a/packages/charted/lib/charts/data_transformers/filter_transformer.dart |
+++ b/packages/charted/lib/charts/data_transformers/filter_transformer.dart |
@@ -1,21 +1,19 @@ |
-/* |
- * 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; |
typedef bool FilterFunction(dynamic value); |
-/** |
- * Transforms the ChartData base on the specified FilterDefinitions. Each row |
- * of data will be tested by passing the value at target column to the filter |
- * function. If filter function returns false, the row will be filtered out. |
- * This transformer does not modify the column part of the input ChartData. |
- */ |
+/// Transforms the ChartData base on the specified FilterDefinitions. Each row |
+/// of data will be tested by passing the value at target column to the filter |
+/// function. If filter function returns false, the row will be filtered out. |
+/// This transformer does not modify the column part of the input ChartData. |
class FilterTransformer extends ChangeNotifier |
implements ChartDataTransform, ChartData { |
final SubscriptionsDisposer _dataSubscriptions = new SubscriptionsDisposer(); |
@@ -26,12 +24,10 @@ class FilterTransformer extends ChangeNotifier |
FilterTransformer(this.filterFunctions); |
- /** |
- * Transforms the input data with the list of [FilterDefinition] specified in |
- * the constructor. If the rows and columns are ObservableList in the data, |
- * changes in rows and columns in input data will trigger transform to be |
- * performed again to update the output rows and columns. |
- */ |
+ /// Transforms the input data with the list of [FilterDefinition] specified in |
+ /// the constructor. If the rows and columns are ObservableList in the data, |
+ /// changes in rows and columns in input data will trigger transform to be |
+ /// performed again to update the output rows and columns. |
ChartData transform(ChartData data) { |
_data = data; |
_registerListeners(); |
@@ -39,11 +35,11 @@ class FilterTransformer extends ChangeNotifier |
return this; |
} |
- /** Registers listeners if data.rows or data.columns are Observable. */ |
+ /// Registers listeners if data.rows or data.columns are Observable. |
_registerListeners() { |
_dataSubscriptions.dispose(); |
- if(_data is Observable) { |
+ if (_data is Observable) { |
var observable = (_data as Observable); |
_dataSubscriptions.add(observable.changes.listen((records) { |
_transform(); |
@@ -56,18 +52,16 @@ class FilterTransformer extends ChangeNotifier |
} |
} |
- /** |
- * Performs the filter transform with _data. This is called on transform and |
- * onChange if the input ChartData is Observable. |
- */ |
+ /// Performs the filter transform with _data. This is called on transform and |
+ /// onChange if the input ChartData is Observable. |
_transform() { |
columns = _data.columns; |
rows.clear(); |
for (var row in _data.rows) { |
// Add the row if each value in target column passes the filter function. |
- if (filterFunctions.every((e) => |
- e.filterFunc(row.elementAt(e.targetColumn)))) { |
+ if (filterFunctions |
+ .every((e) => e.filterFunc(row.elementAt(e.targetColumn)))) { |
rows.add(row); |
} |
} |