use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class EventVisualizationController method generateChart.
@GetMapping(value = { "/{uid}/data", "/{uid}/data.png" })
void generateChart(@PathVariable("uid") String uid, @RequestParam(value = "date", required = false) Date date, @RequestParam(value = "ou", required = false) String ou, @RequestParam(value = "width", defaultValue = "800", required = false) int width, @RequestParam(value = "height", defaultValue = "500", required = false) int height, @RequestParam(value = "attachment", required = false) boolean attachment, HttpServletResponse response) throws IOException, WebMessageException {
// TODO no acl?
final EventVisualization eventVisualization = eventVisualizationService.getEventVisualization(uid);
if (eventVisualization == null) {
throw new WebMessageException(notFound("Event visualization does not exist: " + uid));
}
doesNotAllowPivotAndReportChart(eventVisualization);
final OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit(ou) : null;
final JFreeChart jFreeChart = chartService.getJFreeChart(new PlotData(eventVisualization), date, unit, i18nManager.getI18nFormat());
final String filename = filenameEncode(eventVisualization.getName()) + ".png";
contextUtils.configureResponse(response, CONTENT_TYPE_PNG, RESPECT_SYSTEM_SETTING, filename, attachment);
writeChartAsPNG(response.getOutputStream(), jFreeChart, width, height);
}
Aggregations