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 /// Transforms the ChartData by transposing the columns and rows. A label colum
n | 11 /// Transforms the ChartData by transposing the columns and rows. A label colum
n |
12 /// index in the original data will need to be specified (default to 0), all | 12 /// index in the original data will need to be specified (default to 0), all |
13 /// values in the specified label column will be used as the label for the | 13 /// values in the specified label column will be used as the label for the |
14 /// transformed data, all the labels in the original Chart data columns will be | 14 /// transformed data, all the labels in the original Chart data columns will be |
15 /// populated in the label column as values of that column. | 15 /// populated in the label column as values of that column. |
16 /// | 16 /// |
17 /// All values in the data except for the data in the label column must have the | 17 /// All values in the data except for the data in the label column must have the |
18 /// same type; All columns except for the label column must have the same | 18 /// same type; All columns except for the label column must have the same |
19 /// formatter if a formatter exist for columns. | 19 /// formatter if a formatter exist for columns. |
20 class TransposeTransformer extends ChangeNotifier | 20 class TransposeTransformer extends Observable |
21 implements ChartDataTransform, ChartData { | 21 implements ChartDataTransform, ChartData { |
22 final SubscriptionsDisposer _dataSubscriptions = new SubscriptionsDisposer(); | 22 final SubscriptionsDisposer _dataSubscriptions = new SubscriptionsDisposer(); |
23 ObservableList<ChartColumnSpec> columns = new ObservableList(); | 23 ObservableList<ChartColumnSpec> columns = new ObservableList(); |
24 ObservableList<List> rows = new ObservableList(); | 24 ObservableList<List> rows = new ObservableList(); |
25 | 25 |
26 // If specified, this values of this column in the input chart data will be | 26 // If specified, this values of this column in the input chart data will be |
27 // used as labels of the transposed column label. Defaults to first column. | 27 // used as labels of the transposed column label. Defaults to first column. |
28 int _labelColumn; | 28 int _labelColumn; |
29 ChartData _data; | 29 ChartData _data; |
30 | 30 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 columns.add( | 111 columns.add( |
112 new ChartColumnSpec(type: type, label: label, formatter: formatter)); | 112 new ChartColumnSpec(type: type, label: label, formatter: formatter)); |
113 } | 113 } |
114 columns.insert( | 114 columns.insert( |
115 _labelColumn, | 115 _labelColumn, |
116 new ChartColumnSpec( | 116 new ChartColumnSpec( |
117 type: ChartColumnSpec.TYPE_STRING, | 117 type: ChartColumnSpec.TYPE_STRING, |
118 label: _data.columns.elementAt(_labelColumn).label)); | 118 label: _data.columns.elementAt(_labelColumn).label)); |
119 } | 119 } |
120 } | 120 } |
OLD | NEW |