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 |
(...skipping 10 matching lines...) Expand all Loading... |
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 |
25 /// the aggregation type and spend is fact's field name. | 25 /// the aggregation type and spend is fact's field name. |
26 /// | 26 /// |
27 /// Currently, "sum", "count", "min", "max", "avg", "valid" and "avgOfValid" | 27 /// Currently, "sum", "count", "min", "max", "avg", "valid" and "avgOfValid" |
28 /// are supported as the operators. | 28 /// are supported as the operators. |
29 operator [](String key); | 29 operator [](String key); |
30 | 30 |
| 31 /// List of lower aggregations. |
| 32 List<AggregationItem> lowerAggregations(); |
| 33 |
31 /// Check if we support a given key. | 34 /// Check if we support a given key. |
32 bool containsKey(String key); | 35 bool containsKey(String key); |
33 | 36 |
34 /// List of valid field names for this entity. | 37 /// List of valid field names for this entity. |
35 /// 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 |
36 /// the next dimension and all possible facts defined on the view. | 39 /// the next dimension and all possible facts defined on the view. |
37 Iterable<String> get fieldNames; | 40 Iterable<String> get fieldNames; |
38 } | 41 } |
39 | 42 |
40 /// Implementation of AggregationItem | 43 /// Implementation of AggregationItem |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return model._aggregations[offset + model._offsetSum] / | 128 return model._aggregations[offset + model._offsetSum] / |
126 model._aggregations[offset + model._offsetCnt].toInt(); | 129 model._aggregations[offset + model._offsetCnt].toInt(); |
127 } | 130 } |
128 return null; | 131 return null; |
129 } | 132 } |
130 | 133 |
131 dynamic _nonAggregationMember(String key) { | 134 dynamic _nonAggregationMember(String key) { |
132 if (key == 'items') { | 135 if (key == 'items') { |
133 return new _AggregationItemsIterator(model, dimensions, _key); | 136 return new _AggregationItemsIterator(model, dimensions, _key); |
134 } | 137 } |
135 if (key == 'aggregations') { | |
136 return _lowerAggregations(); | |
137 } | |
138 return null; | 138 return null; |
139 } | 139 } |
140 | 140 |
141 List<AggregationItem> _lowerAggregations() { | 141 List<AggregationItem> lowerAggregations() { |
142 List<AggregationItem> aggregations = new List<AggregationItem>(); | 142 List<AggregationItem> aggregations = new List<AggregationItem>(); |
143 if (dimensions.length == model._dimFields.length) { | 143 if (dimensions.length == model._dimFields.length) { |
144 return aggregations; | 144 return aggregations; |
145 } | 145 } |
146 | 146 |
147 var lowerDimensionField = model._dimFields[dimensions.length]; | 147 var lowerDimensionField = model._dimFields[dimensions.length]; |
148 List lowerVals = model.valuesForDimension(lowerDimensionField); | 148 List lowerVals = model.valuesForDimension(lowerDimensionField); |
149 | 149 |
150 lowerVals.forEach((name) { | 150 lowerVals.forEach((name) { |
151 List lowerDims = new List.from(dimensions)..add(name); | 151 List<String> lowerDims = new List.from(dimensions)..add(name); |
152 AggregationItem entity = model.facts(lowerDims); | 152 AggregationItem entity = model.facts(lowerDims); |
153 if (entity != null) { | 153 if (entity != null) { |
154 aggregations.add(entity); | 154 aggregations.add(entity); |
155 } | 155 } |
156 }); | 156 }); |
157 | 157 |
158 return aggregations; | 158 return aggregations; |
159 } | 159 } |
160 | 160 |
161 bool containsKey(String key) => fieldNames.contains(key); | 161 bool containsKey(String key) => fieldNames.contains(key); |
(...skipping 71 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 |