PieChart - Background of the ChartPanel

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Kerze
Posts: 1
Joined: Thu Dec 11, 2014 10:32 am
antibot: No, of course not.

PieChart - Background of the ChartPanel

Post by Kerze » Thu Dec 11, 2014 10:42 am

Hey,
I am using the PieChart from the ChartFactory.createPieChart(). When I am looking at the PieChartDemo1.java, then the Background of the Chart is White and the Background of the ChartPanel is Grey, but when I use the same code in my own Programm the Colors are vice versa.
With plot.setBackgroundPaint(Color.white) I only get Access to the Background of the Chart, but I dont know how I get Access to the Background of the ChartPanel (The Background of the Title...).
Can anybody help me?

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: PieChart - Background of the ChartPanel

Post by remiohead » Thu Dec 11, 2014 4:13 pm

ChartPanel extends from JPanel which extends from JComponent. The method to use is:

Code: Select all

setBackground(java.awt.Color)
In conjunction with

Code: Select all

setOpaque(boolean isOpaque)

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: PieChart - Background of the ChartPanel

Post by david.gilbert » Sun Dec 14, 2014 7:05 pm

The JFreeChart class also has a setBackgroundPaint() method. This is the whole area in the chart panel (titles, legend, axes, data area, everything). The plot background doesn't include the titles or legend, just axes (if any) and the data area.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked