BrightSide Workbench Full Report + Source Code
DWWebChart.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2016 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.dossier.dw;
20 
21 import java.util.List;
22 import org.turro.charts.Chart;
23 import org.turro.charts.Data;
24 import org.turro.charts.Series;
25 import org.turro.elephant.context.IConstructor;
26 import org.turro.i18n.I_;
27 
32 public class DWWebChart extends Chart {
33 
35  super(constructor);
36  }
37 
38  protected void setData(String title, List<Object[]> list) {
39  Series s = addSeries(title);
40  for(Object[] obj : list) {
41  if(obj[0] instanceof Enum) {
42  Data data = s.addData(I_.byKey(((Enum) obj[0]).toString()));
43  onCreate(data, obj);
44  for(int i = 1; i < obj.length; i++) {
45  data.addValue(((Number) obj[i]).doubleValue());
46  }
47  } else {
48  Data data = s.addData(I_.byKey((String) obj[0]));
49  onCreate(data, obj);
50  for(int i = 1; i < obj.length; i++) {
51  data.addValue(((Number) obj[i]).doubleValue());
52  }
53  }
54  }
55  }
56 
57  protected void onCreate(Data data, Object[] pars) {}
58 
59 }
60 
IConstructor constructor
Definition: Chart.java:32
Series addSeries(String name)
Definition: Chart.java:44
void addValue(Object value)
Definition: Data.java:61
Data addData(String name)
Definition: Series.java:53
void setData(String title, List< Object[]> list)
Definition: DWWebChart.java:38
DWWebChart(IConstructor constructor)
Definition: DWWebChart.java:34
void onCreate(Data data, Object[] pars)
Definition: DWWebChart.java:57
static String byKey(String key)
Definition: I_.java:83