Example usage for org.jfree.chart ChartUtilities saveChartAsPNG

List of usage examples for org.jfree.chart ChartUtilities saveChartAsPNG

Introduction

In this page you can find the example usage for org.jfree.chart ChartUtilities saveChartAsPNG.

Prototype

public static void saveChartAsPNG(File file, JFreeChart chart, int width, int height) throws IOException 

Source Link

Document

Saves a chart to the specified file in PNG format.

Usage

From source file:org.miloss.fgsms.services.rs.impl.reports.os.OpenFilesByProcess.java

@Override
public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files,
        TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx)
        throws IOException {

    Connection con = Utility.getPerformanceDBConnection();
    try {/*  w ww .j  a v  a2  s  .  c om*/
        PreparedStatement cmd = null;
        ResultSet rs = null;
        JFreeChart chart = null;

        data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>");
        data.append(GetHtmlFormattedHelp() + "<br />");
        data.append(
                "<table class=\"table table-hover\"><tr><th>URI</th><th>Average Open File Handles Count</th></tr>");
        TimeSeriesCollection col = new TimeSeriesCollection();
        for (int i = 0; i < urls.size(); i++) {
            if (!isPolicyTypeOf(urls.get(i), PolicyType.PROCESS)) {
                continue;
            }
            //https://github.com/mil-oss/fgsms/issues/112
            if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(i), classification, ctx)) {
                continue;
            }
            String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(i)));
            data.append("<tr><td>").append(url).append("</td>");
            double average = 0;
            try {
                cmd = con.prepareStatement(
                        "select avg(openfiles) from rawdatamachineprocess where uri=? and utcdatetime > ? and utcdatetime < ?;");
                cmd.setString(1, urls.get(i));
                cmd.setLong(2, range.getStart().getTimeInMillis());
                cmd.setLong(3, range.getEnd().getTimeInMillis());

                rs = cmd.executeQuery();

                if (rs.next()) {
                    average = rs.getDouble(1);

                }
            } catch (Exception ex) {
                log.log(Level.WARN, null, ex);
            } finally {
                DBUtils.safeClose(rs);
                DBUtils.safeClose(cmd);
            }

            data.append("<td>").append(average + "").append("</td></tr>");
            TimeSeries ts = new TimeSeries(url, Millisecond.class);
            try {
                //ok now get the raw data....
                cmd = con.prepareStatement(
                        "select utcdatetime, openfiles from rawdatamachineprocess where uri=? and utcdatetime > ? and utcdatetime < ?;");
                cmd.setString(1, urls.get(i));
                cmd.setLong(2, range.getStart().getTimeInMillis());
                cmd.setLong(3, range.getEnd().getTimeInMillis());

                rs = cmd.executeQuery();

                while (rs.next()) {

                    GregorianCalendar gcal = new GregorianCalendar();
                    gcal.setTimeInMillis(rs.getLong(1));
                    Millisecond m = new Millisecond(gcal.getTime());
                    ts.addOrUpdate(m, rs.getLong(2));

                }
            } catch (Exception ex) {
                log.log(Level.WARN, null, ex);
            } finally {
                DBUtils.safeClose(rs);
                DBUtils.safeClose(cmd);
            }

            col.addSeries(ts);

        }

        chart = org.jfree.chart.ChartFactory.createTimeSeriesChart(GetDisplayName(), "Timestamp", "Count", col,
                true, false, false);

        data.append("</table>");
        try {
            // if (set.getRowCount() != 0) {
            ChartUtilities.saveChartAsPNG(new File(
                    path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart,
                    1500, 400);
            data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">");
            files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png");
            //}
        } catch (IOException ex) {
            log.log(Level.ERROR, "Error saving chart image for request", ex);
        }
    } catch (Exception ex) {
        log.log(Level.ERROR, null, ex);
    } finally {
        DBUtils.safeClose(con);
    }
}

From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedAAView.java

public void saveImage(File file, Dimension d) throws IOException {
    if (d == null)
        d = new Dimension(_albumChartPanel.getWidth(), _albumChartPanel.getHeight());
    ChartUtilities.saveChartAsPNG(file, _albumChart, d.width, d.height);
}

From source file:de.suse.swamp.modules.scheduledjobs.Statistics.java

/**
 * Generating the graphs that show the amount of running finished wfs over the time.
 *///from  www  .j  a v  a  2  s. c om
protected void generateWorkflowGraph(String templateName, Date startDate, Date endDate) throws Exception {
    List stats = StatisticStorage.loadStats(templateName, startDate, endDate);
    // only generate if we have stats: 
    if (stats != null && stats.size() > 0) {
        TimeSeriesCollection dataset = new TimeSeriesCollection();
        TimeSeriesCollection avgdataset = new TimeSeriesCollection();
        TimeSeries serie = new TimeSeries("running workflows", Day.class);
        TimeSeries avgserie = new TimeSeries("average age", Day.class);
        for (Iterator datait = stats.iterator(); datait.hasNext();) {
            Dbstatistics statisticItem = (Dbstatistics) datait.next();
            serie.addOrUpdate(new Day(statisticItem.getDate()), statisticItem.getRunningcount());
            avgserie.addOrUpdate(new Day(statisticItem.getDate()), statisticItem.getAvgage() / (3600 * 24));
        }
        dataset.addSeries(serie);
        avgdataset.addSeries(avgserie);

        JFreeChart chart = ChartFactory.createTimeSeriesChart("Running " + templateName + " workflows", "Date",
                "running workflows", dataset, false, false, false);

        // modify chart appearance
        chart.setBackgroundImageAlpha(0.5f);
        XYPlot plot = chart.getXYPlot();
        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
        plot.getRangeAxis().setLabelPaint(Color.blue);

        // add the second line: 
        final NumberAxis axis2 = new NumberAxis("Avg. age in days");
        axis2.setLabelPaint(Color.red);
        plot.setRangeAxis(1, axis2);
        plot.setDataset(1, avgdataset);
        plot.mapDatasetToRangeAxis(1, 1);

        final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
        renderer2.setDrawOutlines(false);
        renderer2.setDrawSeriesLineAsPath(true);
        renderer2.setBaseShapesVisible(false);
        plot.setRenderer(1, renderer2);

        File image = new File(statPath + fs + templateName + ".png");
        if (image.exists())
            image.delete();
        try {
            ChartUtilities.saveChartAsPNG(image, chart, 750, 200);
        } catch (Exception e) {
            Logger.ERROR("Error generating graph for " + templateName + ", e: " + e.getMessage());
            e.printStackTrace();
            throw e;
        }
    }
}

From source file:org.miloss.fgsms.services.rs.impl.reports.os.ThreadCount.java

@Override
public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files,
        TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx)
        throws IOException {

    Connection con = Utility.getPerformanceDBConnection();
    try {/*from   w w w  .j  a va 2 s .  c o  m*/
        PreparedStatement cmd = null;
        ResultSet rs = null;
        JFreeChart chart = null;

        data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>");
        data.append(GetHtmlFormattedHelp() + "<br />");
        data.append("<table class=\"table table-hover\"><tr><th>URI</th><th>Average Thread Count</th></tr>");

        TimeSeriesCollection col = new TimeSeriesCollection();
        for (int i = 0; i < urls.size(); i++) {
            if (!isPolicyTypeOf(urls.get(i), PolicyType.MACHINE)
                    && !isPolicyTypeOf(urls.get(i), PolicyType.PROCESS)) {
                continue;
            }
            //https://github.com/mil-oss/fgsms/issues/112
            if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(i), classification, ctx)) {
                continue;
            }
            String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(i)));
            data.append("<tr><td>").append(url).append("</td>");
            double average = 0;
            try {

                cmd = con.prepareStatement(
                        "select avg(threads) from rawdatamachineprocess where uri=? and utcdatetime > ? and utcdatetime < ?;");
                cmd.setString(1, urls.get(i));
                cmd.setLong(2, range.getStart().getTimeInMillis());
                cmd.setLong(3, range.getEnd().getTimeInMillis());
                rs = cmd.executeQuery();
                if (rs.next()) {
                    average = rs.getDouble(1);
                }
            } catch (Exception ex) {
                log.log(Level.WARN, null, ex);
            } finally {
                DBUtils.safeClose(rs);
                DBUtils.safeClose(cmd);
            }

            data.append("<td>").append(average + "").append("</td></tr>");
            TimeSeries ts = new TimeSeries(urls.get(i), Millisecond.class);
            try {
                //ok now get the raw data....
                cmd = con.prepareStatement(
                        "select threads,utcdatetime from rawdatamachineprocess where uri=? and utcdatetime > ? and utcdatetime < ?;");
                cmd.setString(1, urls.get(i));
                cmd.setLong(2, range.getStart().getTimeInMillis());
                cmd.setLong(3, range.getEnd().getTimeInMillis());
                rs = cmd.executeQuery();

                while (rs.next()) {
                    GregorianCalendar gcal = new GregorianCalendar();
                    gcal.setTimeInMillis(rs.getLong(2));
                    Millisecond m = new Millisecond(gcal.getTime());

                    ts.addOrUpdate(m, rs.getLong(1));
                }
            } catch (Exception ex) {
                log.log(Level.WARN, null, ex);
            } finally {
                DBUtils.safeClose(rs);
                DBUtils.safeClose(cmd);
            }
            col.addSeries(ts);
        }

        data.append("</table>");
        chart = org.jfree.chart.ChartFactory.createTimeSeriesChart(GetDisplayName(), "Timestamp", "Count", col,
                true, false, false);

        try {
            //if (set.getRowCount() != 0) {
            ChartUtilities.saveChartAsPNG(new File(
                    path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart,
                    1500, 400);
            data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">");
            files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png");
            // }
        } catch (IOException ex) {
            log.log(Level.ERROR, "Error saving chart image for request", ex);
        }
    } catch (Exception ex) {
        log.log(Level.ERROR, null, ex);
    } finally {
        DBUtils.safeClose(con);
    }
}

From source file:MSUmpire.DIA.RTMappingExtLib.java

private void GenerateRTMapPNG(XYSeriesCollection xySeriesCollection, XYSeries series, float R2)
        throws IOException {
    String pngfile = FilenameUtils.getFullPath(TargetLCMS.mzXMLFileName) + "/"
            + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "_" + libManager.LibID + "_RTMap.png";
    FileWriter writer = new FileWriter(FilenameUtils.getFullPath(TargetLCMS.mzXMLFileName) + "/"
            + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "_" + libManager.LibID + "_RTMap.txt");

    XYSeries smoothline = new XYSeries("RT fitting curve");
    for (XYZData data : regression.PredictYList) {
        smoothline.add(data.getX(), data.getY());
        writer.write(data.getX() + "\t" + data.getY() + "\n");
    }//from w  w  w  .j a v a2s . c  o m
    writer.close();
    xySeriesCollection.addSeries(smoothline);
    xySeriesCollection.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot("Retention time mapping: R2=" + R2,
            "Normalized RT (" + libManager.LibID + ")",
            "RT:" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName), xySeriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(1, Color.blue);
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    xyPlot.setBackgroundPaint(Color.white);
    ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
}

From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedDGView.java

public void saveImageExtra(File file, Dimension d) throws IOException {
    if (d == null)
        d = new Dimension(_genreChartPanel.getWidth(), _genreChartPanel.getHeight());
    ChartUtilities.saveChartAsPNG(file, _genreChart, d.width, d.height);
}

From source file:org.miloss.fgsms.services.rs.impl.reports.ws.SuccessFailureCountByService.java

/**
 * {@inheritDoc}//from  w  ww  . j ava2s.  c o  m
 */
@Override
public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files,
        TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx)
        throws IOException {

    Connection con = Utility.getPerformanceDBConnection();
    try {
        PreparedStatement cmd = null;
        ResultSet rs = null;
        DefaultCategoryDataset set = new DefaultCategoryDataset();
        JFreeChart chart = null;
        data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>");
        data.append("This represents service invocation by success and failure rates.<br />");
        data.append(
                "<table  class=\"table table-hover\"><tr><th>URL</th><th>Successes</th><th>Failures</th></tr>");
        try {

            for (int i = 0; i < urls.size(); i++) {
                if (!isPolicyTypeOf(urls.get(i), PolicyType.TRANSACTIONAL)) {
                    continue;
                }
                //https://github.com/mil-oss/fgsms/issues/112
                if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(i), classification,
                        ctx)) {
                    continue;
                }
                String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(i)));
                data.append("<tr><td>").append(url).append("</td>");
                int success = 0;
                int failures = 0;
                //could this use the raw data tally table instead?
                try {
                    cmd = con.prepareStatement(
                            "select count(*) from RawData where uri=? and success=false and UTCdatetime > ? and UTCdatetime < ?;");
                    cmd.setString(1, urls.get(i));
                    cmd.setLong(2, range.getStart().getTimeInMillis());
                    cmd.setLong(3, range.getEnd().getTimeInMillis());
                    rs = cmd.executeQuery();
                    try {
                        rs.next();
                        failures = rs.getInt(1);
                    } catch (Exception ex) {
                        log.log(Level.DEBUG, null, ex);
                    }
                } catch (Exception ex) {
                    log.log(Level.WARN, null, ex);
                } finally {
                    DBUtils.safeClose(rs);
                    DBUtils.safeClose(cmd);
                }
                try {
                    cmd = con.prepareStatement(
                            "select count(*) from RawData where uri=? and success=true and UTCdatetime > ? and UTCdatetime < ?;");
                    cmd.setString(1, urls.get(i));
                    cmd.setLong(2, range.getStart().getTimeInMillis());
                    cmd.setLong(3, range.getEnd().getTimeInMillis());
                    rs = cmd.executeQuery();
                    try {
                        rs.next();
                        success = rs.getInt(1);
                    } catch (Exception ex) {
                        log.log(Level.DEBUG, null, ex);
                    }
                } catch (Exception ex) {
                    log.log(Level.WARN, null, ex);
                } finally {
                    DBUtils.safeClose(rs);
                    DBUtils.safeClose(cmd);
                }

                data.append("<td>").append(success + "").append("</td>");
                data.append("<td>").append(failures + "").append("</td></tr>");
                set.addValue(success, url + " Success", url + " Success");
                set.addValue(failures, url + " Failures", url + " Failures");

            }
        } catch (Exception ex) {
            log.log(Level.ERROR, "Error generating chart information.", ex);
        }
        chart = org.jfree.chart.ChartFactory.createBarChart(GetDisplayName(), "Services", "", set,
                PlotOrientation.HORIZONTAL, true, false, false);
        data.append("</table>");
        try {
            ChartUtilities.saveChartAsPNG(new File(
                    path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart,
                    1500, pixelHeightCalc(set.getRowCount()));
        } catch (IOException ex) {
            log.log(Level.ERROR, "Error saving chart image for request", ex);
        }

        data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">");
        files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png");
    } catch (Exception ex) {
        log.log(Level.ERROR, null, ex);
    } finally {
        DBUtils.safeClose(con);
    }
}

From source file:org.remus.marketplace.scheduling.GenerateStatisticsJob.java

private void createClickStatistics(Integer id, File folder, Node node, Calendar instance) {
    Map<Date, Integer> map = new HashMap<Date, Integer>();
    for (int i = 0, n = month; i < n; i++) {
        Calendar instance2 = Calendar.getInstance();
        instance2.setTime(new Date());
        instance2.add(Calendar.MONTH, i * -1);
        map.put(instance2.getTime(), 0);
    }//from  w w w  .  j  a  va2 s. co  m
    AdvancedCriteria criteria = new AdvancedCriteria()
            .addRestriction(Restrictions.between(Clickthrough.TIME, instance.getTime(), new Date()))
            .addRestriction(Restrictions.eq(Clickthrough.NODE, node));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.count(Clickthrough.NODE));

    projectionList
            .add(Projections.sqlGroupProjection("month({alias}.time) as month, year({alias}.time) as year",
                    "month({alias}.time), year({alias}.time)", new String[] { "month", "year" },
                    new Type[] { Hibernate.INTEGER, Hibernate.INTEGER }));
    criteria.setProjection(projectionList);

    List<Object> query = clickthroughDao.query(criteria);
    for (Object object : query) {
        Object[] data = (Object[]) object;
        Integer count = (Integer) data[0];
        Integer month = (Integer) data[1];
        Integer year = (Integer) data[2];
        Set<Date> keySet = map.keySet();
        for (Date date : keySet) {
            Calendar instance2 = Calendar.getInstance();
            instance2.setTime(date);
            if (instance2.get(Calendar.YEAR) == year && instance2.get(Calendar.MONTH) == month - 1) {
                map.put(date, count);
            }
        }

    }

    DefaultCategoryDataset data = new DefaultCategoryDataset();
    List<Date> keySet = new ArrayList<Date>(map.keySet());
    Collections.sort(keySet, new Comparator<Date>() {

        @Override
        public int compare(Date o1, Date o2) {
            return o1.compareTo(o2);
        }
    });
    for (Date date : keySet) {
        Integer integer = map.get(date);
        Calendar instance2 = Calendar.getInstance();
        instance2.setTime(date);
        int year = instance2.get(Calendar.YEAR);
        int month = instance2.get(Calendar.MONTH) + 1;
        data.addValue(integer, "Column1", month + "-" + year);
    }

    JFreeChart createBarChart = ChartFactory.createBarChart("Clicks", "Month", "", data,
            PlotOrientation.VERTICAL, false, false, false);

    File file = new File(folder, "clicks_" + id + ".png");
    if (file.exists()) {
        file.delete();
    }
    try {
        ChartUtilities.saveChartAsPNG(file, createBarChart, 500, 300);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedAAView.java

public void saveImageExtra(File file, Dimension d) throws IOException {
    if (d == null)
        d = new Dimension(_artistChartPanel.getWidth(), _artistChartPanel.getHeight());
    ChartUtilities.saveChartAsPNG(file, _artistChart, d.width, d.height);
}

From source file:org.miloss.fgsms.services.rs.impl.reports.os.MemoryUsageReport.java

@Override
public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files,
        TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx)
        throws IOException {

    Connection con = Utility.getPerformanceDBConnection();
    try {//from  ww w.  j av  a  2  s  . c o  m
        PreparedStatement cmd = null;
        ResultSet rs = null;
        JFreeChart chart = null;

        data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>");
        data.append(GetHtmlFormattedHelp() + "<br />");
        data.append("<table class=\"table table-hover\"><tr><th>URI</th><th>Average Memory Usage (bytes)</tr>");
        TimeSeriesCollection col = new TimeSeriesCollection();
        for (int i = 0; i < urls.size(); i++) {
            if (!isPolicyTypeOf(urls.get(i), PolicyType.MACHINE)
                    && !isPolicyTypeOf(urls.get(i), PolicyType.PROCESS)) {
                continue;
            }
            //https://github.com/mil-oss/fgsms/issues/112
            if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(i), classification, ctx)) {
                continue;
            }
            String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(i)));
            try {
                data.append("<tr><td>").append(url).append("</td>");
                double average = 0;
                try {
                    cmd = con.prepareStatement(
                            "select avg(memoryused) from rawdatamachineprocess where uri=? and utcdatetime > ? and utcdatetime < ?;");
                    cmd.setString(1, urls.get(i));
                    cmd.setLong(2, range.getStart().getTimeInMillis());
                    cmd.setLong(3, range.getEnd().getTimeInMillis());
                    rs = cmd.executeQuery();
                    if (rs.next()) {
                        average = rs.getDouble(1);
                    }
                } catch (Exception ex) {
                    log.log(Level.WARN, null, ex);
                } finally {
                    DBUtils.safeClose(rs);
                    DBUtils.safeClose(cmd);
                }

                data.append("<td>").append(average + "").append("</td></tr>");

                TimeSeries ts = new TimeSeries(url, Millisecond.class);
                try {
                    //ok now get the raw data....
                    cmd = con.prepareStatement(
                            "select memoryused,utcdatetime from rawdatamachineprocess where uri=? and utcdatetime > ? and utcdatetime < ?;");
                    cmd.setString(1, urls.get(i));
                    cmd.setLong(2, range.getStart().getTimeInMillis());
                    cmd.setLong(3, range.getEnd().getTimeInMillis());
                    rs = cmd.executeQuery();

                    while (rs.next()) {
                        GregorianCalendar gcal = new GregorianCalendar();
                        gcal.setTimeInMillis(rs.getLong(2));
                        Millisecond m = new Millisecond(gcal.getTime());
                        ts.addOrUpdate(m, rs.getDouble(1));
                    }
                } catch (Exception ex) {
                    log.log(Level.WARN, null, ex);
                } finally {
                    DBUtils.safeClose(rs);
                    DBUtils.safeClose(cmd);
                }
                col.addSeries(ts);

            } catch (Exception ex) {
                log.log(Level.ERROR, "Error opening or querying the database.", ex);
            }

        }
        chart = org.jfree.chart.ChartFactory.createTimeSeriesChart(GetDisplayName(), "Timestamp", "Bytes", col,
                true, false, false);

        data.append("</table>");
        try {
            //if (set.getRowCount() != 0) {
            ChartUtilities.saveChartAsPNG(new File(
                    path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart,
                    1500, 400);
            data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">");
            files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png");
            // }
        } catch (IOException ex) {
            log.log(Level.ERROR, "Error saving chart image for request", ex);
        }
    } catch (Exception ex) {
        log.log(Level.ERROR, null, ex);
    } finally {
        DBUtils.safeClose(con);
    }
}