use of org.ff4j.audit.chart.PieChart in project ff4j by ff4j.
the class OperationsController method graphFeatureUsageHitCountasJson.
/**
* Generation of JSON to render Features.
*
* @param req
* current request
* @param res
* current response
* @throws IOException
*/
private void graphFeatureUsageHitCountasJson(HttpServletRequest req, HttpServletResponse res) throws IOException {
res.setContentType(CONTENT_TYPE_JSON);
String[] pathParts = req.getPathInfo().split("/");
EventQueryDefinition query = parseQuery(req);
if (pathParts.length > 3) {
String graphName = pathParts[3];
if (GRAPH_PIE_HITRATIO.equalsIgnoreCase(graphName)) {
PieChart pc = getFf4j().getEventRepository().getFeatureUsagePieChart(query);
res.getWriter().println(pc.toJson());
} else if (GRAPH_BAR_HITRATIO.equalsIgnoreCase(graphName)) {
BarChart bc = getFf4j().getEventRepository().getFeatureUsageBarChart(query);
res.getWriter().println(bc.toJson());
} else if (GRAPH_PIE_HOST.equalsIgnoreCase(graphName)) {
PieChart pc = getFf4j().getEventRepository().getHostPieChart(query);
res.getWriter().println(pc.toJson());
} else if (GRAPH_PIE_SOURCE.equalsIgnoreCase(graphName)) {
PieChart pc = getFf4j().getEventRepository().getSourcePieChart(query);
res.getWriter().println(pc.toJson());
} else if (GRAPH_PIE_USER.equalsIgnoreCase(graphName)) {
PieChart pc = getFf4j().getEventRepository().getUserPieChart(query);
res.getWriter().println(pc.toJson());
}
}
}
use of org.ff4j.audit.chart.PieChart in project ff4j by ff4j.
the class AbstractEventRepository method renderPieChart.
/**
* Convert hicount into pieChart.
*
* @param hitRatio
* current hist ratio
* @return
* pie chart
*/
private PieChart renderPieChart(String title, Map<String, MutableHitCount> hitRatio, List<String> colors) {
PieChart pieChart = new PieChart(title);
int idxColor = 0;
for (String key : hitRatio.keySet()) {
Serie<Integer> ps = new Serie<Integer>(key, hitRatio.get(key).get(), colors.get(idxColor));
pieChart.getSectors().add(ps);
idxColor++;
}
return pieChart;
}
use of org.ff4j.audit.chart.PieChart in project ff4j by ff4j.
the class AuditBeanTest method testPieChart.
@Test
public void testPieChart() {
PieChart bc = new PieChart("p1");
Serie<Integer> s1 = new Serie<Integer>("s1", 12);
Serie<Integer> s2 = new Serie<Integer>("s2", 14);
bc.getSectors().add(s1);
bc.getSectors().add(s2);
Assert.assertNotNull(bc.getSectors());
Assert.assertNotNull(bc.toString());
}
Aggregations