Pie3dChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Antonio Lopes

Pie3dChart

Post by Antonio Lopes » Tue Oct 29, 2002 7:02 pm

David,

I'm using Pie3dChart in an applet I wrote sending 3 values on a series (10.0 for Java, 1.0 for Visual Basic and 1.0 for C/C++).

I detected a problem: this source shows a vertical bar over the pie as it were part of another graphic. I'm sending the source code I used to show the pie graphic.

Could you please help me finding why this bar code appears ??

Best regards,

Antonio Lopes



/ * --------------------
* Pie3DChartDemo1.java
* --------------------
*
*/

package com.jrefinery.chart.demo;

import java.awt.Color;
import com.jrefinery.data.DefaultPieDataset;
import com.jrefinery.chart.JFreeChart;
import com.jrefinery.chart.ChartFactory;
import com.jrefinery.chart.ChartPanel;
import com.jrefinery.chart.Pie3DPlot;
import com.jrefinery.ui.ApplicationFrame;
import com.jrefinery.ui.RefineryUtilities;

/**
* A simple demonstration application showing how to create a pie chart using data from a
* DefaultPieDataset.
*
* @author DG
*/
public class Pie3DChartDemo1 extends ApplicationFrame {

/**
* Creates a new demo.
*
* @param title the frame title.
*/
public Pie3DChartDemo1(String title) {

super(title);

// create a dataset...
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Java", new Double(10.0));
data.setValue("Visual Basic", new Double(1.0));
data.setValue("C/C++", new Double(1.0));
// data.setValue("PHP", new Double(32.5));
// data.setValue("Perl", new Double(12.5));

// create the chart...
JFreeChart chart = ChartFactory.createPie3DChart("Pie Chart 3D Demo 1", // chart title
data, // data
true // include legend
);

// set the background color for the chart...
chart.setBackgroundPaint(Color.yellow);
Pie3DPlot plot = (Pie3DPlot) chart.getPlot();
plot.setStartAngle(270);
plot.setDirection(Pie3DPlot.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
// add the chart to a panel...
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);

}

/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {

Pie3DChartDemo1 demo = new Pie3DChartDemo1("Pie Chart 3D Demo 1");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}

Dave Gilbert

Re: Pie3dChart

Post by Dave Gilbert » Wed Oct 30, 2002 10:08 am

Hi Antonio,

Thanks for reporting this bug. You can fix it by inserting the following line:

side2.intersect(front);

...between lines 439 and 440 of the Pie3DPlot.java source file. That is, right before the line:

g2.fill(side2);

Regards,

DG.

Antonio Lopes

Re: Pie3dChart

Post by Antonio Lopes » Thu Oct 31, 2002 1:23 pm

Hi David,

Thank you for you answer... It really solved my problem. Actually I've found another problem and I'd like to know if you can help me again :

When I pass a "Series Value" equal to zero I get an exception while the applet execution.

This exception doesn't occur in the PieChart Graphic and the legend in this case shows the Series valued Zero.

Shouldn't both of graphics have the same functionality ?

Thank's

Antonio Lopes

Dave Gilbert

Re: Pie3dChart

Post by Dave Gilbert » Fri Nov 01, 2002 9:57 am

Hi Antonio,

I'll try to take a look at that today. Yes, both charts should behave in a similar way.

Regards,

DG.

Locked