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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 _valueFilterCache.clear(); | 72 _valueFilterCache.clear(); |
73 _computeColumnStates(); | 73 _computeColumnStates(); |
74 } | 74 } |
75 | 75 |
76 /// Override this method to handle state changes. | 76 /// Override this method to handle state changes. |
77 void handleStateChanges(List<ChangeRecord> changes); | 77 void handleStateChanges(List<ChangeRecord> changes); |
78 | 78 |
79 @override | 79 @override |
80 Extent get extent { | 80 Extent get extent { |
81 assert(series != null && area != null); | 81 assert(series != null && area != null); |
82 var rows = area.data.rows, | 82 var rows = area.data.rows, measures = series.measures; |
83 measures = series.measures, | 83 num max = SMALL_INT_MIN; |
84 max = SMALL_INT_MIN, | 84 num min = SMALL_INT_MAX; |
85 min = SMALL_INT_MAX; | |
86 | 85 |
87 for (int i = 0, len = rows.length; i < len; ++i) { | 86 for (int i = 0, len = rows.length; i < len; ++i) { |
88 var row = rows.elementAt(i); | 87 var row = rows.elementAt(i); |
89 for (int j = 0, jLen = measures.length; j < jLen; ++j) { | 88 for (int j = 0, jLen = measures.length; j < jLen; ++j) { |
90 var value = row.elementAt(measures.elementAt(j)); | 89 var value = row.elementAt(measures.elementAt(j)); |
91 if (value != null && value.isFinite) { | 90 if (value != null && value.isFinite) { |
92 if (value > max) { | 91 if (value > max) { |
93 max = value; | 92 max = value; |
94 } else if (value < min) { | 93 } else if (value < min) { |
95 min = value; | 94 min = value; |
96 } | 95 } |
97 } | 96 } |
98 } | 97 } |
99 } | 98 } |
| 99 |
| 100 // If all values are null or non finite, set the extent to be 0. |
| 101 if (max == SMALL_INT_MIN && min == SMALL_INT_MAX) { |
| 102 max = 0; |
| 103 min = 0; |
| 104 } |
100 return new Extent(min, max); | 105 return new Extent(min, max); |
101 } | 106 } |
102 | 107 |
103 @override | 108 @override |
104 Extent extentForRow(Iterable row) { | 109 Extent extentForRow(Iterable row) { |
105 assert(series != null && area != null); | 110 assert(series != null && area != null); |
106 var measures = series.measures, max = SMALL_INT_MIN, min = SMALL_INT_MAX; | 111 var measures = series.measures, max = SMALL_INT_MIN, min = SMALL_INT_MAX; |
107 | 112 |
108 for (int i = 0, len = measures.length; i < len; ++i) { | 113 for (int i = 0, len = measures.length; i < len; ++i) { |
109 var measure = measures.elementAt(i), value = row.elementAt(measure); | 114 var measure = measures.elementAt(i), value = row.elementAt(measure); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 274 } |
270 if (state.hovered != null && state.hovered.last == row) { | 275 if (state.hovered != null && state.hovered.last == row) { |
271 flags |= ChartState.VAL_HOVERED; | 276 flags |= ChartState.VAL_HOVERED; |
272 } | 277 } |
273 _valueColorCache[hash] = | 278 _valueColorCache[hash] = |
274 theme.getColorForKey(area.useRowColoring ? row : column, flags); | 279 theme.getColorForKey(area.useRowColoring ? row : column, flags); |
275 _valueFilterCache[hash] = theme.getFilterForState(flags); | 280 _valueFilterCache[hash] = theme.getFilterForState(flags); |
276 } | 281 } |
277 } | 282 } |
278 } | 283 } |
OLD | NEW |