Label above of bar error...

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mmm286
Posts: 9
Joined: Wed Oct 15, 2014 10:02 am
antibot: No, of course not.

Label above of bar error...

Post by mmm286 » Tue Feb 03, 2015 10:09 am

Hi
I'm trying to put label above my chart bar but I have these error:

Code: Select all

org.jfree.chart.plot.XYPlot cannot be cast to org.jfree.chart.plot.CategoryPlot
My code is:

Code: Select all

public static JPanel createDemoPanel(ArrayList<ponDiaDuracion> aInsertar) {
        JFreeChart chart = createChart(createDataset(aInsertar));
        // SI QUITAMOS ESTAS LINEAS SALE BIEN DESDE EL DIA QUE DEBE
        XYPlot xyplot = (XYPlot)chart.getPlot();
    	DateAxis dateaxis = new DateAxis();
        dateaxis = (DateAxis) xyplot.getDomainAxis();               
        dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
//        CategoryPlot plot = chart.getCategoryPlot();
       

        StackedBarRenderer renderer = new StackedBarRenderer(false);

    
        renderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator("{2}",NumberFormat.getCurrencyInstance(Locale.US)));

        renderer.setSeriesItemLabelsVisible(0, true);
        chart.getCategoryPlot().setRenderer(renderer);
        return new ChartPanel(chart);
    }
Many thanks

Locked