Color bg = backgroundcolor==null?databackgroundcolor:backgroundcolor;
if(font==null)font=getFont();
LegendTitle legend = legendMultiLine?
new LegendTitle(plot,new ColumnArrangement(), new ColumnArrangement()):
new LegendTitle(plot);
legend.setBackgroundPaint(bg);
legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
legend.setFrame(new LineBorder());
legend.setPosition(RectangleEdge.BOTTOM);
legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
legend.setWidth(chartwidth-20);// geht nicht
legend.setItemFont(font);
legend.setItemPaint(foregroundcolor);
//RectangleInsets labelPadding;
legend.setItemLabelPadding(new RectangleInsets(2,2,2,2));
legend.setBorder(0,0,0,0);
legend.setLegendItemGraphicLocation(RectangleAnchor.TOP_LEFT);
legend.setLegendItemGraphicPadding(new RectangleInsets(8,10,0,0));
chart.addLegend(legend);
}