I'm not able to display the bar labels in the bar chart. I'm not very familiar with chart creation in java. This is the first time I'm working in this. I've searched for a solution many times. I'm not able to find any error in the code. I'm struck in this.
Expected output is here. And I'm getting this output.
The code is as follows:
public JFreeChart createBarChart_WM(String date)
{
String dateSplit[]=date.split("::");
String title="Application Availability ("+dateSplit[0]+" - "+dateSplit[dateSplit.length-1]+")\nP=Portal L=LPL CC=COMMISSIONS AND COMPENSATION BI=BROADRIDGE INVESTIGO IN=INFRASTRUCTURE SS=SUPPORTING SYSTEMS FP=FINANCIAL PLANNING CS=CRM SYSTEMS LS=LEGACY_SYSTEMS SR=SRS EP=eApp";
DefaultCategoryDataset dataSet=createDataset_WM(date);
JFreeChart chart = ChartFactory.createBarChart(title,"","",dataSet,PlotOrientation.VERTICAL, false, true, false);
CategoryPlot plot = chart.getCategoryPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAutoRangeIncludesZero(true);
rangeAxis.setRange(98.8,99.4);
rangeAxis.setTickUnit(new NumberTickUnit(0.1));
DecimalFormat df2 = new DecimalFormat( "00.00'%'" );
rangeAxis.setNumberFormatOverride(df2);
rangeAxis.setTickLabelPaint(Color.BLACK);
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
CustomBarRenderer renderer = new CustomBarRenderer();
chart.getCategoryPlot().setRenderer(renderer);
BarRenderer barRenderer=(BarRenderer) renderer;
CategoryItemLabelGenerator generator= new StandardCategoryItemLabelGenerator("{0}",NumberFormat.getInstance());
barRenderer.setBaseItemLabelGenerator(generator);
barRenderer.setBaseItemLabelPaint(Color.BLACK);
barRenderer.setBaseItemLabelFont(new Font("SansSerif", Font.PLAIN, 11));
barRenderer.setBaseItemLabelsVisible(true);
barRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER,TextAnchor.CENTER,-Math.PI/2));
barRenderer.setItemMargin(0);
barRenderer.setDrawBarOutline(true);
barRenderer.setBaseOutlinePaint(Color.BLACK);
barRenderer.setBarPainter(new StandardBarPainter());
barRenderer.setShadowVisible(false);
BarRenderer.setDefaultBarPainter(new StandardBarPainter());
BarRenderer.setDefaultShadowsVisible(true);
plot.setBackgroundPaint(Color.WHITE);
plot.setRangeGridlinePaint(Color.BLACK);
plot.setRangeGridlinesVisible(true);
plot.setOutlineVisible(false);
chart.setBorderPaint(Color.BLACK);
chart.setBorderVisible(true);
TextTitle title1 = chart.getTitle();
Font font=new Font("Dialog", Font.BOLD, 15);
title1.setBackgroundPaint(Color.white);
title1.setFrame(new org.jfree.chart.block.LineBorder(Color.RED, new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND), new RectangleInsets(3, 3, 3, 3)));
title1.setPaint(Color.BLACK);
title1.setFont(font);
title1.setMargin(new RectangleInsets(10, 10, 10, 10));
chart.setPadding(new RectangleInsets(10, 10, 10, 10));
return chart;
}
Can anybody please help me to sort out from this problem?