// Layout der Achsen
Color gray = getColor(new RGB(230,230,230));
// X-Achse
{
IAxis axis = this.chart.getAxisSet().getXAxis(0);
axis.getTitle().setForeground(GUI.getDisplay().getSystemColor(SWT.COLOR_WHITE)); // wenn wir den auch ausblenden, geht die initiale Skalierung kaputt. Scheint ein Bug zu sein
IGrid grid = axis.getGrid();
grid.setStyle(LineStyle.DOT);
grid.setForeground(gray);
axis.getTick().setForeground(GUI.getDisplay().getSystemColor(SWT.COLOR_BLACK));
}
// Y-Achse
{
IAxis axis = this.chart.getAxisSet().getYAxis(0);
axis.getTitle().setVisible(false);
IGrid grid = axis.getGrid();
grid.setStyle(LineStyle.DOT);
grid.setForeground(gray);
IAxisTick tick = axis.getTick();
tick.setFormat(HBCI.DECIMALFORMAT);
tick.setForeground(GUI.getDisplay().getSystemColor(SWT.COLOR_BLACK));
}
//
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Neu zeichnen
List<ChartData> data = getData();
for (int i=0;i<data.size();++i)
{
final List<String> labelLine = new LinkedList<String>();
final List<Number> dataLine = new LinkedList<Number>();
ChartData cd = (ChartData) data.get(i);
List list = cd.getData();
String dataAttribute = cd.getDataAttribute();
String labelAttribute = cd.getLabelAttribute();
if (list == null || list.size() == 0 || dataAttribute == null || labelAttribute == null)
{
Logger.debug("skipping data line, contains no data");
dataLine.add(new Double(0));
labelLine.add("");
}
else
{
for (Object o:list)
{
Object value = BeanUtil.get(o,dataAttribute);
Object label = BeanUtil.get(o,labelAttribute);
if (label == null || value == null || !(value instanceof Number))
continue;
Number n = (Number) value;
if (Math.abs(n.doubleValue()) < 0.01d)
continue; // ueberspringen, nix drin
dataLine.add(n);
labelLine.add(label.toString());
}
}
if (dataLine.size() == 0)
continue; // wir haben gar keine Werte
IAxis axis = this.chart.getAxisSet().getXAxis(0);
axis.setCategorySeries(labelLine.toArray(new String[labelLine.size()]));
axis.enableCategory(true);
IBarSeries barSeries = (IBarSeries) this.chart.getSeriesSet().createSeries(SeriesType.BAR,Integer.toString(i));
barSeries.setYSeries(toArray(dataLine));
//////////////////////////////////////////////////////////////////////////