JFree Chart background color & labels

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
andromeda
Posts: 1
Joined: Tue Apr 28, 2015 6:57 am
antibot: No, of course not.

JFree Chart background color & labels

Post by andromeda » Tue Apr 28, 2015 7:23 am

I am testing JFree chart

I have this code ..

Code: Select all

                DefaultPieDataset myServletPieChart = new DefaultPieDataset();
                myServletPieChart.setValue("Maths", 74);
                myServletPieChart.setValue("Physics", 87);
                myServletPieChart.setValue("Chemistry", 62);
                myServletPieChart.setValue("Biology", 92);
                myServletPieChart.setValue("English", 51);        
                JFreeChart mychart = ChartFactory.createPieChart("",myServletPieChart,true,true,false);  
                mychart.setBack
                response.setContentType("image/png"); /* Set the HTTP Response Type */
                ChartUtilities.writeChartAsPNG(out, mychart, 400, 300);

I want to change the color of each slices of my choice.
Could you please tell how to achieve this ?
I dont like default color of slices.

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: JFree Chart background color & labels

Post by John Matthews » Tue Apr 28, 2015 3:56 pm

You can use setSectionPaint(), suggested here, or a custom DrawingSupplier, illustrated here.

Locked