Search in sources :

Example 1 with Chart

use of org.krysalis.jcharts.Chart in project activityinfo by bedatadriven.

the class ChartRendererJC method renderImage.

public BufferedImage renderImage(PivotChartReportElement element, boolean includeTitle, int width, int height, int dpi) {
    try {
        Chart chart = createChart(element, includeTitle, width, height, dpi);
        BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        chart.setGraphics2D(bufferedImage.createGraphics());
        chart.render();
        return bufferedImage;
    } catch (IOException e) {
        throw new ReportModelException(e, element);
    } catch (ChartDataException e) {
        throw new ReportModelException(e, element);
    } catch (PropertyException e) {
        throw new ReportModelException(e, element);
    }
}
Also used : ReportModelException(org.activityinfo.legacy.shared.exception.ReportModelException) ChartDataException(org.krysalis.jcharts.chartData.ChartDataException) IOException(java.io.IOException) AxisChart(org.krysalis.jcharts.axisChart.AxisChart) Chart(org.krysalis.jcharts.Chart) BufferedImage(com.google.code.appengine.awt.image.BufferedImage)

Example 2 with Chart

use of org.krysalis.jcharts.Chart in project activityinfo by bedatadriven.

the class ChartRendererJC method renderToUrl.

public String renderToUrl(PivotChartReportElement element, boolean includeTitle, StorageProvider istorageProvider, int width, int height, int dpi) throws IOException {
    try {
        Chart chart = createChart(element, includeTitle, width, height, dpi);
        GeneratedResource storage = istorageProvider.create(null, "activityinfo.jpg");
        JPEGEncoder.encode(chart, 0.75f, storage.openOutputStream());
        return storage.getDownloadUri();
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : GeneratedResource(org.activityinfo.server.generated.GeneratedResource) AxisChart(org.krysalis.jcharts.axisChart.AxisChart) Chart(org.krysalis.jcharts.Chart) ChartDataException(org.krysalis.jcharts.chartData.ChartDataException) ReportModelException(org.activityinfo.legacy.shared.exception.ReportModelException) IOException(java.io.IOException)

Example 3 with Chart

use of org.krysalis.jcharts.Chart in project activityinfo by bedatadriven.

the class ChartRendererJC method render.

public void render(PivotChartReportElement element, boolean includeTitle, Graphics2D g2d, int width, int height, int dpi) {
    try {
        Chart chart = createChart(element, includeTitle, width, height, dpi);
        chart.setGraphics2D(g2d);
        chart.render();
    } catch (Exception e) {
        throw new RuntimeException("Rendering of chart entitled '" + element.getTitle() + "' failed", e);
    }
}
Also used : AxisChart(org.krysalis.jcharts.axisChart.AxisChart) Chart(org.krysalis.jcharts.Chart) ChartDataException(org.krysalis.jcharts.chartData.ChartDataException) ReportModelException(org.activityinfo.legacy.shared.exception.ReportModelException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)3 ReportModelException (org.activityinfo.legacy.shared.exception.ReportModelException)3 Chart (org.krysalis.jcharts.Chart)3 AxisChart (org.krysalis.jcharts.axisChart.AxisChart)3 ChartDataException (org.krysalis.jcharts.chartData.ChartDataException)3 BufferedImage (com.google.code.appengine.awt.image.BufferedImage)1 GeneratedResource (org.activityinfo.server.generated.GeneratedResource)1