我使用了这些代码
DefaultPieDataset my_pie_chart_data = new DefaultPieDataset();
for(int i =1; i<9; i++) {
row = my_sheet.getRow(0);
cell = row.getCell(i);
chart_label=cell.getStringCellValue();
row = my_sheet.getRow(1);
cell = row.getCell(i);
chart_data=cell.getNumericCellValue();
my_pie_chart_data.setValue(chart_label,chart_data);
}
JFreeChart myPieChart=ChartFactory.createPieChart("PIE",my_pie_chart_data,true,true,false);
int width=640; /* Width of the chart */
int height=480; /* Height of the chart */
float quality=1; /* Quality factor */
ByteArrayOutputStream chart_out = new ByteArrayOutputStream();
ChartUtilities.writeChartAsJPEG(chart_out,quality,myPieChart,width,height);
int my_picture_id = my_workbook.addPicture(chart_out.toByteArray(), Workbook.PICTURE_TYPE_JPEG);
chart_out.close();
XSSFDrawing drawing = my_sheet.createDrawingPatriarch();
ClientAnchor my_anchor = new XSSFClientAnchor();
my_anchor.setCol1(4);
my_anchor.setRow1(5);
XSSFPicture my_picture = drawing.createPicture(my_anchor, my_picture_id);
my_picture.resize();
chart_file_input.close();
}
结果图表上带有这些标签,这很容易混淆,特别是当值较小时,因为它们都引用同一部分。我可以接受下面的图例定义。 有人知道如何删除它们吗?