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 /// AggregationItem is created by [AggregationModel] to make access to facts | 11 /// AggregationItem is created by [AggregationModel] to make access to facts |
12 /// observable. Users must use AggregationItem.isValid before trying to access | 12 /// observable. Users must use AggregationItem.isValid before trying to access |
13 /// the aggregations. | 13 /// the aggregations. |
14 abstract class AggregationItem extends ChangeNotifier { | 14 abstract class AggregationItem extends Observable { |
15 /// List of dimension fields in effect | 15 /// List of dimension fields in effect |
16 List<String> dimensions; | 16 List<String> dimensions; |
17 | 17 |
18 /// Check if this entity is valid. | 18 /// Check if this entity is valid. |
19 /// Currently the only case where an entity becomes invalid | 19 /// Currently the only case where an entity becomes invalid |
20 /// is when a groupBy is called on the model. | 20 /// is when a groupBy is called on the model. |
21 bool get isValid; | 21 bool get isValid; |
22 | 22 |
23 /// Fetch the fact from AggregationModel and return it | 23 /// Fetch the fact from AggregationModel and return it |
24 /// Currently takes keys in the form of "sum(spend)", where sum is | 24 /// Currently takes keys in the form of "sum(spend)", where sum is |
(...skipping 10 matching lines...) Expand all Loading... |
35 bool containsKey(String key); | 35 bool containsKey(String key); |
36 | 36 |
37 /// List of valid field names for this entity. | 37 /// List of valid field names for this entity. |
38 /// It's the combined list of accessors for individual items, items in | 38 /// It's the combined list of accessors for individual items, items in |
39 /// the next dimension and all possible facts defined on the view. | 39 /// the next dimension and all possible facts defined on the view. |
40 Iterable<String> get fieldNames; | 40 Iterable<String> get fieldNames; |
41 } | 41 } |
42 | 42 |
43 /// Implementation of AggregationItem | 43 /// Implementation of AggregationItem |
44 /// Instances of _AggregationItemImpl are created only by AggregationModel | 44 /// Instances of _AggregationItemImpl are created only by AggregationModel |
45 class _AggregationItemImpl extends ChangeNotifier implements AggregationItem { | 45 class _AggregationItemImpl extends Observable implements AggregationItem { |
46 static final List<String> derivedAggregationTypes = ['count', 'avg']; | 46 static final List<String> derivedAggregationTypes = ['count', 'avg']; |
47 | 47 |
48 AggregationModel model; | 48 AggregationModel model; |
49 List<String> dimensions; | 49 List<String> dimensions; |
50 | 50 |
51 String _key; | 51 String _key; |
52 | 52 |
53 int _factsOffset; | 53 int _factsOffset; |
54 | 54 |
55 /// Currently entities are created only when they have valid aggregations | 55 /// Currently entities are created only when they have valid aggregations |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 return (_current < _endOfRows); | 233 return (_current < _endOfRows); |
234 } | 234 } |
235 | 235 |
236 get current { | 236 get current { |
237 if (_current == null || _counter > _count) { | 237 if (_current == null || _counter > _count) { |
238 return null; | 238 return null; |
239 } | 239 } |
240 return model._rows[model._sorted[_current]]; | 240 return model._rows[model._sorted[_current]]; |
241 } | 241 } |
242 } | 242 } |
OLD | NEW |