params.put(BaseChartWeb.CHART_PARAM_OUTLINE_RANGEGRIDLINES_VISIBLE, request.getParameter(BaseChartWeb.CHART_PARAM_OUTLINE_RANGEGRIDLINES_VISIBLE));
params.put(BaseChartWeb.CHART_PARAM_OUTLINE_VISIBLE, request.getParameter(BaseChartWeb.CHART_PARAM_OUTLINE_VISIBLE));
String chartType = params.get(BaseChartWeb.CHART_PARAM_TYPE);
DeprecatedChart chart = null;
if (BaseChartWeb.BAR_CHART_HORIZONTAL.equals(chartType) || BaseChartWeb.BAR_CHART_VERTICAL.equals(chartType) || BaseChartWeb.STACKED_BAR_CHART.equals(chartType)) {
chart = new BarChart(params);
} else if (BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM.equals(chartType)) {
chart = new CustomBarChart(params);
} else if (BaseChartWeb.PIE_CHART.equals(chartType)) {
chart = new PieChart(params);
} else if (BaseChartWeb.SPARKLINES_CHART.equals(chartType)) {
chart = new SparkLinesChart(params);
}
if (chart != null) {
OutputStream out = null;
try {
out = response.getOutputStream();
response.setContentType("image/png");
chart.exportChartAsPNG(out);
} catch (Exception e) {
LOG.error("Generating chart " + chart.getClass().getName(), e);
} finally {
Closeables.closeQuietly(out);
}
}
}