use of org.opennms.netmgt.config.charts.BarChart in project opennms by OpenNMS.
the class ChartUtils method getBarChartPNG.
/**
* Helper method that returns the JFreeChart to an output stream written in JPEG format.
*
* @param chartName a {@link java.lang.String} object.
* @param out a {@link java.io.OutputStream} object.
* @throws java.io.IOException if any.
* @throws java.sql.SQLException if any.
*/
public static void getBarChartPNG(String chartName, OutputStream out) throws IOException, SQLException {
ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
BarChart chartConfig = getBarChartConfigByName(chartName);
JFreeChart chart = getBarChart(chartName);
if (chartConfig.getChartBackgroundColor().isPresent()) {
setChartBackgroundColor(chartConfig, chart);
}
if (chartConfig.getPlotBackgroundColor().isPresent()) {
setPlotBackgroundColor(chartConfig, chart);
}
ImageSize imageSize = chartConfig.getImageSize();
int hzPixels;
int vtPixels;
if (imageSize == null) {
hzPixels = 400;
vtPixels = 400;
} else {
hzPixels = imageSize.getHzSize().getPixels();
vtPixels = imageSize.getVtSize().getPixels();
}
ChartUtilities.writeChartAsPNG(out, chart, hzPixels, vtPixels, false, 6);
}
Aggregations