Java CartesianChartModel数据库值

Java CartesianChartModel数据库值,java,jsf,primefaces,Java,Jsf,Primefaces,在本文中,通过硬编码输入,我们可以生成图表。现在,我想查询数据库,获取具有活动状态的请求的总和,而不是设置男孩和女孩的值。我可以这样做,但我如何在这里提供的图表中对此进行建模 类似的事? 您需要自己添加数据库查询逻辑 private void createCategoryModel() { categoryModel = new CartesianChartModel(); ChartSeries active_chart = new ChartSeries();

在本文中,通过硬编码输入,我们可以生成图表。现在,我想查询数据库,获取具有活动状态的请求的总和,而不是设置男孩和女孩的值。我可以这样做,但我如何在这里提供的图表中对此进行建模

类似的事? 您需要自己添加数据库查询逻辑

private void createCategoryModel() {  
    categoryModel = new CartesianChartModel();  

    ChartSeries active_chart = new ChartSeries();  
    active_chart.setLabel("ACTIVE");  

    int total = 250;
    int active = 100;
    int non_active = total - active;

    active_chart.set("Bar_Lablel", active);  


    ChartSeries non_active_chart = new ChartSeries();  
    non_active_chart.setLabel("NON ACTIVE ");  

    non_active_chart.set("Bar_Lablel", non_active);  


    categoryModel.addSeries(active_chart);  
    categoryModel.addSeries(non_active_chart);  
}