* strings and displayed too.
* @return
* @throws SQLException
*/
public static JFreeChart createPieChart(List<List<Object>> series, int numberOfCategories, ResultSetMetaData metadata, int column) throws SQLException {
DefaultPieDataset dataset = new DefaultPieDataset();
HashMap<String, Integer> map = new HashMap<String, Integer>();
List<String> stringsInRS = new ArrayList<String>();
List<Double> extremes = getExtremeNumbers(series.get(0));
for (Object o : series.get(0)) {
if (o instanceof Number) {
stringsInRS.add(convertToString((Number) o, extremes,numberOfCategories));
} else if(o != null && o instanceof String){
stringsInRS.add((String) o);
}
}
/* counting frequency of strings */
for (String s : stringsInRS) {
if (map.containsKey(s)) {
map.put(s, map.get(s) + 1);
} else {
map.put(s, new Integer(1));
}
}
Set<String> keys = map.keySet();
String[] keyArray = keys.toArray(new String[0]);
Arrays.sort(keyArray);
for (String key : keyArray) {
dataset.setValue(key, map.get(key));
}
return ChartFactory.createPieChart(metadata.getColumnName(column + 1), dataset, true, true, false);
}