0
我想实现Primefaces图表。但我无法正确设置图表的传说:无法正确实现Primefaces图表
这是我用它来构建图表代码:
<h:form>
<p:barChart id="basic" value="#{DashboardController.categoryModel}" legendPosition="ne"
title="Accounts and Groups" min="0" max="#{DashboardController.chartMaxSize}" style="height:400px"
shadow="true" barPadding="90" seriesColors="4D94FF, 1975FF, 005CE6, 0047B2"
yaxisLabel="Size"/>
</h:form>
Java代码:
private void createCategoryModel() throws SQLException, Exception
{
categoryModel = new CartesianChartModel();
// Active Accounts
ChartSeries chart = new ChartSeries();
chart.setLabel("Active Accounts");
chart.set("Active Accounts", countDBActiveAccounts());
// Blocked Accounts
chart.setLabel("Blocked Accounts");
chart.set("Blocked Accounts", countDBBlockedAccounts());
// Active Groups
chart.setLabel("Active Groups");
chart.set("Active Groups", countDBActiveGroups());
// Blocked Groups
chart.setLabel("Blocked Groups");
chart.set("Blocked Groups", countDBBlockedGroups());
categoryModel.addSeries(chart);
}
你能帮我正确构建图表吗?
P.S从@Ravi提出的代码我得到这个图表:
我测试了你提出的代码。列的名称不正确 - 它们共享一个名称。我想像第一张照片一样单独命名它们。 – user1285928 2012-08-01 09:23:50
@ user1285928,我不知道这是否是正确的做法。但我已经更新它来满足您的要求。如果我得到比这更好的解决方案,我会再次发布。 – Ravi 2012-08-02 14:18:32