[]
        
(Showing Draft Content)

帕累托图

GcExcel支持帕累托图,也称为帕累托分布图。它是一个垂直条形图,值从左到右,按相对频率递减的顺序绘制。帕累托图对任务排序很有用。这个图表给出了对给定系统有最大影响的变量的提示。

帕累托图可以用来从一组给定的因素中突出最重要的因素。例如,质量控制、库存控制和客户不满处理是一些帕累托图表分析可以使用的领域。

用例代码

参考以下代码添加帕累托图:

private static void ParetoChart() {
    // Initialize workbook
    Workbook workbook = new Workbook();
    // Fetch default worksheet
    IWorksheet worksheet = workbook.getWorksheets().get(0);

    // Prepare data for chart
    worksheet.getRange("A1:B11")
            .setValue(new Object[][] { 
                { "Complaint", "Count" }, 
                { "Too noisy", 27 }, 
                { "Overpriced", 789 },
                { "Food is tasteless", 65 }, 
                { "Food is not fresh", 19 }, 
                { "Food is too salty", 15 },
                { "Not clean", 30 }, 
                { "Unfriendly staff", 12 }, 
                { "Wait time", 109 }, 
                { "No atmosphere", 45 },
                { "Small portions", 621 } });
    worksheet.getRange("A:B").getColumns().autoFit();
    // Add Pareto Chart
    IShape paretochartShape = worksheet.getShapes().addChart(ChartType.Pareto, 300, 30, 300, 250);

    // Set range"A1:B11" as the pareto chart series
    paretochartShape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B11"));

    // Configure Chart Title
    paretochartShape.getChart().getChartTitle().setText("Pareto Chart");

    // Saving workbook to Xlsx
    workbook.save("31-ParetoChart.xlsx", SaveFileFormat.Xlsx);