表示饼图的不同部分的标签彼此重叠

时间:2015-04-01 10:45:55

标签: javafx pie-chart

我正在开发一个 JaxaFX 应用程序,它通过从 MySQL 数据库中获取数据来生成报告。我在使用饼图时遇到了一个问题。每当提取的数据为0时,显示的标签会与饼图中的其他标签重叠,从而难以阅读。

Overlapping labels in a piechart

代码的相关位:

获取数据:

Get_data_from_pos_basket_for_reporting getreportPaymentPaidUnpaidNoClass=new Get_data_from_pos_basket_for_reporting();
        getreportPaymentPaidUnpaidNoClass.getreportPaymentPaidUnpaidNo(fromDate, untilDate);
      double amountPaid,amountUnpaid;
      int totalPaid,totalUnpaid;
      amountPaid=getreportPaymentPaidUnpaidNoClass.getAmountPaid();
      amountUnpaid= getreportPaymentPaidUnpaidNoClass.getAmountUnpaid();
      totalPaid=getreportPaymentPaidUnpaidNoClass.getTotalPaid();
      totalUnpaid=getreportPaymentPaidUnpaidNoClass.getTotalUnpaid();
      double totalamountPaidUnpaid=amountPaid+paymentSystem+amountUnpaid;
      double totalNoPaidUnpaid=totalPaid+totalUnpaid;
     // DecimalFormat df = new DecimalFormat("0.00");

      double percentagePaidAmount=((amountPaid/totalamountPaidUnpaid)*100);
      double percentageUnpaidAmount=((amountUnpaid/totalamountPaidUnpaid)*100);
      double percentagePaidTotal=((totalPaid/totalNoPaidUnpaid)*100);
      double percentageUnpaidTotal=((totalUnpaid/totalNoPaidUnpaid)*100);

设置饼图:

ObservableList<PieChart.Data> pieChartData3 =
                FXCollections.observableArrayList(
                new PieChart.Data("Paid\n"+(df.format(percentagePaidAmount))+"%", amountPaid),
                new PieChart.Data("Unpaid\n"+(df.format(percentageUnpaidAmount))+"%", amountUnpaid));

         PieChart chart3 = new PieChart(pieChartData3);



        chart3.getStyleClass().add("chart-legend");       
        chart3.setTitle("Payment Details[Total Amount]");
        VBox vBoxPie3= new VBox();
        vBoxPie3.getChildren().addAll(chart3);

请建议一个解决方案,使标签不会相互重叠。

0 个答案:

没有答案