From: <pve...@ic...> - 2003-08-13 22:13:45
|
Thanks Nathaniel, but I haven't fix the problem yet. I'm using the code below as an example. The problem with this code is that, if you maximize, minimize or resize the frame, the chart disappear. I guess the problem is with the paint(Graphics) method at Charts class, I tried overwritting that method as you said, but it didn't work. I don't know what to do. Please give me some advises. pavel import javax.swing.JPanel; import javax.swing.*; import java.awt.*; import org.jCharts.chartData.*; import org.jCharts.properties.*; import org.jCharts.axisChart.*; import org.jCharts.nonAxisChart.*; import org.jCharts.types.ChartType; import org.jCharts.test.TestDataGenerator; import org.jCharts.axisChart.customRenderers.axisValue.renderers.*; public class Charts extends JPanel { LegendProperties lp = null; ChartProperties cp = null; BarChartProperties ctp = null; PieChart2D chart = null ; AxisProperties ap = null; public Charts() { /// ************** PIE CHART DATASET ************************ try { double[] data = { 81d, 55d, 39d, 20.6d}; String[] labels = { "BMW M5", "BMW M3", "Viper GTS-R", "Corvette Z06"}; Paint[] paints = { Color.lightGray, Color.green, Color.blue, Color.red}; PieChart2DProperties pieChart2DProperties = new PieChart2DProperties(); PieChartDataSet pieChartDataSet = new PieChartDataSet("Cars That Own", data, labels, paints, pieChart2DProperties); chart = new PieChart2D(pieChartDataSet, new LegendProperties(), new ChartProperties(), 350, 350); } catch(Exception e){ System.out.println(e); } } public static void main(String args[]) throws Exception { JFrame frame = new JFrame("CHART TEST"); frame.setSize( 400, 400 ); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //uncomment this line to do not lose the chart when you resize the frame //frame.setResizable(false); Charts pieChart = new Charts(); frame.getContentPane().add(pieChart); pieChart.setBackground(Color.white); frame.setVisible(true); pieChart.chart.setGraphics2D((Graphics2D)pieChart.getGraphics()); pieChart.chart.render(); } } ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ |