OLD | NEW |
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 |
11 /// Transforms the ChartData based on the specified dimension columns and facts | 11 /// Transforms the ChartData based on the specified dimension columns and facts |
12 /// columns indices. The values in the facts columns will be aggregated by the | 12 /// columns indices. The values in the facts columns will be aggregated by the |
13 /// tree hierarchy generated by the dimension columns. Expand and Collapse | 13 /// tree hierarchy generated by the dimension columns. Expand and Collapse |
14 /// methods may be called to display different levels of aggregation. | 14 /// methods may be called to display different levels of aggregation. |
15 /// | 15 /// |
16 /// The output ChartData produced by transform() will contain only columns in th
e | 16 /// The output ChartData produced by transform() will contain only columns in th
e |
17 /// original ChartData that were specified in dimensions or facts column indices
. | 17 /// original ChartData that were specified in dimensions or facts column indices
. |
18 /// The output column will be re-ordered first by the indices specified in the | 18 /// The output column will be re-ordered first by the indices specified in the |
19 /// dimension column indices then by the facts column indices. The data in the | 19 /// dimension column indices then by the facts column indices. The data in the |
20 /// cells of each row will also follow this rule. | 20 /// cells of each row will also follow this rule. |
21 class AggregationTransformer extends ChangeNotifier | 21 class AggregationTransformer extends Observable |
22 implements ChartDataTransform, ChartData { | 22 implements ChartDataTransform, ChartData { |
23 static const String AGGREGATION_TYPE_SUM = 'sum'; | 23 static const String AGGREGATION_TYPE_SUM = 'sum'; |
24 static const String AGGREGATION_TYPE_MIN = 'min'; | 24 static const String AGGREGATION_TYPE_MIN = 'min'; |
25 static const String AGGREGATION_TYPE_MAX = 'max'; | 25 static const String AGGREGATION_TYPE_MAX = 'max'; |
26 static const String AGGREGATION_TYPE_VALID = 'valid'; | 26 static const String AGGREGATION_TYPE_VALID = 'valid'; |
27 final SubscriptionsDisposer _dataSubscriptions = new SubscriptionsDisposer(); | 27 final SubscriptionsDisposer _dataSubscriptions = new SubscriptionsDisposer(); |
28 final Set<List> _expandedSet = new Set(); | 28 final Set<List> _expandedSet = new Set(); |
29 List<ChartColumnSpec> columns; | 29 List<ChartColumnSpec> columns; |
30 ObservableList<List> rows = new ObservableList<List>(); | 30 ObservableList<List> rows = new ObservableList<List>(); |
31 List<int> _dimensionColumnIndices; | 31 List<int> _dimensionColumnIndices; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 _expandAllDimension = false; | 201 _expandAllDimension = false; |
202 _expandedSet.clear(); | 202 _expandedSet.clear(); |
203 } | 203 } |
204 | 204 |
205 /// Tests if specific dimension is expanded. | 205 /// Tests if specific dimension is expanded. |
206 bool _isExpanded(List dimension) { | 206 bool _isExpanded(List dimension) { |
207 Function eq = const ListEquality().equals; | 207 Function eq = const ListEquality().equals; |
208 return _expandedSet.any((e) => eq(e, dimension)); | 208 return _expandedSet.any((e) => eq(e, dimension)); |
209 } | 209 } |
210 } | 210 } |
OLD | NEW |