png
我进行了编码以在格式文件中创建饼图文件;饼图显示百分比,但它位于文件的底部。我希望百分比出现在图表本身中。这是我使用的代码:
String query = "SELECT name,flag from mawarid";
JDBCPieDataset dataset = new JDBCPieDataset(
"jdbc:oracle:thin:@ 127.0.0.1:1521:XE", "oracle.jdbc.OracleDriver", "", "");
dataset.executeQuery(query);
JFreeChart chart = ChartFactory.createPieChart(
"Test", dataset, true, true, false);
try {
PiePlot plot = (PiePlot) chart.getPlot();
plot.setLegendLabelGenerator(
new StandardPieSectionLabelGenerator("{0} {2}"));
final ChartRenderingInfo info = new ChartRenderingInfo(
new StandardEntityCollection());
final File file1 = new File("Chart5.png");
ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
} catch (Exception e) {
// log exception
}