| 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 library charted.demo.interactive; | 9 library charted.demo.interactive; |
| 10 | 10 |
| 11 import 'dart:html'; | 11 import 'dart:html'; |
| 12 import 'package:observe/observe.dart'; | 12 import 'package:observable/observable.dart'; |
| 13 import 'package:charted/charts/charts.dart'; | 13 import 'package:charted/charts/charts.dart'; |
| 14 | 14 |
| 15 import 'demo_charts.dart'; | 15 import 'demo_charts.dart'; |
| 16 | 16 |
| 17 const List<int> DIMENSION_COLUMNS = const <int>[0, 4]; | 17 const List<int> DIMENSION_COLUMNS = const <int>[0, 4]; |
| 18 | 18 |
| 19 int customSeriesCounter = 0; | 19 int customSeriesCounter = 0; |
| 20 | 20 |
| 21 Map RENDERERS = { | 21 Map RENDERERS = { |
| 22 'bar-chart': 'Bar chart', | 22 'bar-chart': 'Bar chart', |
| 23 'line-chart': 'Line chart', | 23 'line-chart': 'Line chart', |
| 24 'stacked-bar-chart': 'Stacked bar chart', | 24 'stacked-bar-chart': 'Stacked bar chart', |
| 25 'stacked-line-chart': 'Stacked line chart', |
| 25 'waterfall-chart': 'Waterfall chart', | 26 'waterfall-chart': 'Waterfall chart', |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 CartesianRenderer getRendererForType(String name) { | 29 CartesianRenderer getRendererForType(String name) { |
| 29 if (name == 'bar-chart') return new BarChartRenderer(); | 30 if (name == 'bar-chart') return new BarChartRenderer(); |
| 30 if (name == 'line-chart') return new LineChartRenderer(); | 31 if (name == 'line-chart') return new LineChartRenderer(); |
| 31 if (name == 'stacked-bar-chart') return new StackedBarChartRenderer(); | 32 if (name == 'stacked-bar-chart') return new StackedBarChartRenderer(); |
| 33 if (name == 'stacked-line-chart') return new StackedLineChartRenderer(); |
| 32 return new BarChartRenderer(); | 34 return new BarChartRenderer(); |
| 33 } | 35 } |
| 34 | 36 |
| 35 String getTypeForRenderer(CartesianRenderer renderer) { | 37 String getTypeForRenderer(CartesianRenderer renderer) { |
| 36 if (renderer is BarChartRenderer) return 'bar-chart'; | 38 if (renderer is BarChartRenderer) return 'bar-chart'; |
| 37 if (renderer is LineChartRenderer) return 'line-chart'; | 39 if (renderer is LineChartRenderer) return 'line-chart'; |
| 38 if (renderer is StackedBarChartRenderer) return 'stacked-bar-chart'; | 40 if (renderer is StackedBarChartRenderer) return 'stacked-bar-chart'; |
| 41 if (renderer is StackedLineChartRenderer) return 'stacked-line-chart'; |
| 39 return 'bar-chart'; | 42 return 'bar-chart'; |
| 40 } | 43 } |
| 41 | 44 |
| 42 main() { | 45 main() { |
| 43 List<List> DATA_SOURCE = ORDINAL_DATA; | 46 List<List> DATA_SOURCE = ORDINAL_DATA; |
| 44 ChartSeries activeSeries, | 47 ChartSeries activeSeries, |
| 45 defaultSeries = new ChartSeries("Default series", | 48 defaultSeries = new ChartSeries("Default series", |
| 46 new ObservableList.from([ 2, 3 ]), new BarChartRenderer()); | 49 new ObservableList.from([ 2, 3 ]), new BarChartRenderer()); |
| 47 | 50 |
| 48 var rows = new ObservableList<List>.from(DATA_SOURCE.sublist(0, 10)); | 51 var rows = new ObservableList<List>.from(DATA_SOURCE.sublist(0, 10)); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 251 |
| 249 | 252 |
| 250 /* | 253 /* |
| 251 * Update UI | 254 * Update UI |
| 252 */ | 255 */ |
| 253 | 256 |
| 254 updateColumnsList(); | 257 updateColumnsList(); |
| 255 updateRendererSelector(); | 258 updateRendererSelector(); |
| 256 updateSeriesSelector(); | 259 updateSeriesSelector(); |
| 257 } | 260 } |
| OLD | NEW |