Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: packages/charted/lib/charts/cartesian_renderers/stackedbar_chart_renderer.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (yPos != pos) { 162 if (yPos != pos) {
163 yPos += (theme.defaultSeparatorWidth + theme.defaultStrokeWidth); 163 yPos += (theme.defaultSeparatorWidth + theme.defaultStrokeWidth);
164 } 164 }
165 return pos; 165 return pos;
166 } 166 }
167 }; 167 };
168 168
169 var buildPath = (d, int i, Element e, bool animate, int roundIdx) { 169 var buildPath = (d, int i, Element e, bool animate, int roundIdx) {
170 var position = animate ? getInitialBarPos(i) : getBarPos(d, i), 170 var position = animate ? getInitialBarPos(i) : getBarPos(d, i),
171 length = animate ? 0 : getBarLength(d, i), 171 length = animate ? 0 : getBarLength(d, i),
172 radius = 172 radius = series.measures.elementAt(_reverseIdx(i)) == roundIdx
173 series.measures.elementAt(_reverseIdx(i)) == roundIdx ? RADIUS : 0, 173 ? RADIUS
174 : 0,
174 path = (length != 0) 175 path = (length != 0)
175 ? verticalBars 176 ? verticalBars
176 ? topRoundedRect(0, position, barWidth, length, radius) 177 ? topRoundedRect(0, position, barWidth, length, radius)
177 : rightRoundedRect(position, 0, length, barWidth, radius) 178 : rightRoundedRect(position, 0, length, barWidth, radius)
178 : ''; 179 : '';
179 e.attributes['data-offset'] = 180 e.attributes['data-offset'] =
180 verticalBars ? position.toString() : (position + length).toString(); 181 verticalBars ? position.toString() : (position + length).toString();
181 return path; 182 return path;
182 }; 183 };
183 184
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 root.selectAll('.stack-rdr-rowgroup').remove(); 255 root.selectAll('.stack-rdr-rowgroup').remove();
255 } 256 }
256 257
257 @override 258 @override
258 double get bandInnerPadding => 259 double get bandInnerPadding =>
259 area.theme.getDimensionAxisTheme().axisBandInnerPadding; 260 area.theme.getDimensionAxisTheme().axisBandInnerPadding;
260 261
261 @override 262 @override
262 Extent get extent { 263 Extent get extent {
263 assert(area != null && series != null); 264 assert(area != null && series != null);
264 var rows = area.data.rows, 265 var rows = area.data.rows, rowIndex = 0;
265 max = SMALL_INT_MIN, 266 num max = SMALL_INT_MIN;
266 min = SMALL_INT_MAX, 267 num min = SMALL_INT_MAX;
267 rowIndex = 0;
268 _lastMeasureWithData = new List.generate(rows.length, (i) => -1); 268 _lastMeasureWithData = new List.generate(rows.length, (i) => -1);
269 269
270 rows.forEach((row) { 270 rows.forEach((row) {
271 var bar = null; 271 num bar = null;
272 series.measures.forEach((idx) { 272 series.measures.forEach((idx) {
273 var value = row.elementAt(idx); 273 var value = row.elementAt(idx);
274 if (value != null && value.isFinite) { 274 if (value != null && value.isFinite) {
275 if (bar == null) bar = 0; 275 if (bar == null) bar = 0;
276 bar += value; 276 bar += value;
277 if (value.round() != 0 && _lastMeasureWithData[rowIndex] == -1) { 277 if (value.round() != 0 && _lastMeasureWithData[rowIndex] == -1) {
278 _lastMeasureWithData[rowIndex] = idx; 278 _lastMeasureWithData[rowIndex] = idx;
279 } 279 }
280 } 280 }
281 }); 281 });
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 var row = rowStr != null ? int.parse(rowStr) : null; 323 var row = rowStr != null ? int.parse(rowStr) : null;
324 controller.add(new DefaultChartEventImpl(scope.event, area, series, row, 324 controller.add(new DefaultChartEventImpl(scope.event, area, series, row,
325 series.measures.elementAt(_reverseIdx(index)), data)); 325 series.measures.elementAt(_reverseIdx(index)), data));
326 } 326 }
327 327
328 // Stacked bar chart renders items from bottom to top (first measure is at 328 // Stacked bar chart renders items from bottom to top (first measure is at
329 // the bottom of the stack). We use [_reversedIdx] instead of index to 329 // the bottom of the stack). We use [_reversedIdx] instead of index to
330 // match the color and order of what is displayed in the legend. 330 // match the color and order of what is displayed in the legend.
331 int _reverseIdx(int index) => series.measures.length - 1 - index; 331 int _reverseIdx(int index) => series.measures.length - 1 - index;
332 } 332 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698