我似乎无法操纵图表本身。我无法更改大小,并chartPanel = createChartPanel(); 不断重写为chartPanel = javax.swing.panel();
chartPanel = createChartPanel();
chartPanel = javax.swing.panel();
我试图创建一个方法modificarGrafico,但是没有:
modificarGrafico
范例:http : //www.flickr.com/photos/63259070@N06/6371596517/
public JPanel createChartPanel(){ DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("Toyota", new Integer(10)); pieDataset.setValue("Nissan", new Integer(25)); pieDataset.setValue("Hummer", new Integer(5)); pieDataset.setValue("BMW", new Integer(10)); pieDataset.setValue("Honda", new Integer(30)); pieDataset.setValue("Ford", new Integer(20)); JFreeChart chart = ChartFactory.createPieChart3D("Ventas por Marca", pieDataset, true, true, true); return new ChartPanel(chart); } public void modificarGrafico(){ //JDesktopPane dtp = new JDesktopPane(); this.chartPanel.setSize(200,200); this.chartPanel.setVisible(rootPaneCheckingEnabled); }
您不必担心图表的大小,将面板的布局设置为GridBagLayout应该会有所帮助。