plot.setBackgroundPaint(color);
plot.setRangeGridlinePaint(Color.white);
plot.setDomainGridlinePaint(Color.white);
plot.setDomainGridlinesVisible(true);
GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer();
KeyToGroupMap map = new KeyToGroupMap("G1");
int numElForGroup = 0;
for (int idx=0; idx < numGroups.intValue(); idx++){
for (int j=0; j < numSerieForGroup.intValue(); j++ ){
try{
String tmpSubCat = (String)subCategoryNames.get(j+idx*numSerieForGroup.intValue());
map.mapKeyToGroup(tmpSubCat, "G"+(idx+1));
}
catch (Exception e) {
logger.error("out of range error in inserting in stacked bar group: continue anayway", e);
}
}
}
renderer.setSeriesToGroupMap(map);
renderer.setItemMargin(0.0);
renderer.setDrawBarOutline(false);
renderer.setBaseItemLabelsVisible(true);
if (percentageValue)
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", new DecimalFormat("#,##.#%")));
else
renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
if(maxBarWidth!=null){
renderer.setMaximumBarWidth(maxBarWidth.doubleValue());
}
boolean document_composition=false;
if(mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION))document_composition=true;
/*
MyCategoryUrlGenerator mycatUrl=new MyCategoryUrlGenerator(rootUrl);
mycatUrl.setDocument_composition(document_composition);
mycatUrl.setCategoryUrlLabel(categoryUrlName);
mycatUrl.setSerieUrlLabel(serieUrlname);
renderer.setItemURLGenerator(mycatUrl);
*/
TextTitle title = setStyleTitle(name, styleTitle);
chart.setTitle(title);
if(subName!= null && !subName.equals("")){
TextTitle subTitle =setStyleTitle(subName, styleSubTitle);
chart.addSubtitle(subTitle);
}
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
// set the background color for the chart...
chart.setBackgroundPaint(color);
NumberFormat nf = NumberFormat.getNumberInstance(locale);
// set the range axis to display integers only...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
rangeAxis.setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());
rangeAxis.setNumberFormatOverride(nf);
if(rangeIntegerValues==true){
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
}
if(rangeAxisLocation != null) {
if(rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) {
plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);
} else if(rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) {
plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT);
}else if(rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) {
plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT);
} else if(rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) {
plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT);
}
}
int seriesN=dataset.getRowCount();
int numSerieColored = 0;
if(orderColorVector != null && orderColorVector.size()>0){
logger.debug("color serie by SERIES_ORDER_COLORS template specification");
for (int i = 0; i < seriesN; i++) {
if( orderColorVector.get(i)!= null){
Color color = orderColorVector.get(i);
renderer.setSeriesPaint(i, color);
}
}
}
else
if(colorMap!=null){
while (numSerieColored < seriesN){
for (int i=1; i <= colorMap.size();i++){
Color color=(Color)colorMap.get("SER"+i);
Color gradient=new Color(Integer.decode("#FFFFFF").intValue());
if (gradientMap != null)
gradient=(Color)gradientMap.get("SER"+i);
if(color!=null){
Paint p = new GradientPaint(
0.0f, 0.0f, color, 0.0f, 0.0f, gradient);
//renderer.setSeriesPaint(numSerieColored, color);
renderer.setSeriesPaint(numSerieColored, p);
}
numSerieColored++;
}
}
}
renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
MyStandardCategoryItemLabelGenerator generator=null;
if(additionalLabels){
generator = new MyStandardCategoryItemLabelGenerator(catSerLabels,"{1}", NumberFormat.getInstance());
double orient=(-Math.PI / 2.0);
if(styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")){
orient=0.0;
}
renderer.setBaseItemLabelFont(new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
renderer.setBaseItemLabelPaint(styleValueLabels.getColor());
renderer.setBaseItemLabelGenerator(generator);
renderer.setBaseItemLabelsVisible(true);
//vertical labels
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER,
orient));
renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER,
orient));
//horizontal labels
/*