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);
}
チャートを適切に作成するのを手伝ってもらえますか?
PS @Ravi によって提案されたコードから、次のチャートを取得します。