I did the coding to create a pie chart file in png format file,

the pie chart shows the percentage but in the bottom of the file,

I want the percentage to appear in the chart itself,

This is the codes I have used,

 String query = "SELECT name,flag from mawarid";

 JDBCPieDataset dataset = new JDBCPieDataset(
                         "jdbc:oracle:thin:@ 127.0.0.1:1521:XE", "oracle.jdbc.OracleDriver",
                        "", "");

        dataset.executeQuery(query);

        JFreeChart chart = ChartFactory.createPieChart("Test", dataset, true,
                        true, false);
 try{
             PiePlot plot = (PiePlot) chart.getPlot();
 plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}"));


            final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
            final File file1 = new File("Chart5.png");
            ChartUtilities.saveChartAsPNG(file1, chart,600 , 400,info);

        }
        catch(Exception e)
        {

        }

Hmm... You are using a library which is not a standard library? You may need to look at JFreeChart site for any information. I am sorry that I cannot help you because I don't use the library.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.