List of usage examples for org.jfree.chart ChartUtilities writeChartAsPNG
public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height) throws IOException
From source file:org.apache.struts2.dispatcher.ChartResult.java
/** * Executes the result. Writes the given chart as a PNG or JPG to the servlet output stream. * * @param invocation an encapsulation of the action execution state. * @throws Exception if an error occurs when creating or writing the chart to the servlet output stream. *//* ww w .j a va 2 s. co m*/ public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { initializeProperties(invocation); if (!chartSet) // if our chart hasn't been set (by the testcase), we'll look it up in the value stack chart = (JFreeChart) invocation.getStack().findValue(value, JFreeChart.class); if (chart == null) // we need to have a chart object - if not, blow up throw new NullPointerException("No JFreeChart object found on the stack with name " + value); // make sure we have some value for the width and height if (height == null) throw new NullPointerException("No height parameter was given."); if (width == null) throw new NullPointerException("No width parameter was given."); // get a reference to the servlet output stream to write our chart image to HttpServletResponse response = ServletActionContext.getResponse(); OutputStream os = response.getOutputStream(); try { // check the type to see what kind of output we have to produce if ("png".equalsIgnoreCase(type)) { response.setContentType("image/png"); ChartUtilities.writeChartAsPNG(os, chart, getIntValueFromString(width), getIntValueFromString(height)); } else if ("jpg".equalsIgnoreCase(type) || "jpeg".equalsIgnoreCase(type)) { response.setContentType("image/jpg"); ChartUtilities.writeChartAsJPEG(os, chart, getIntValueFromString(width), getIntValueFromString(height)); } else throw new IllegalArgumentException( type + " is not a supported render type (only JPG and PNG are)."); } finally { if (os != null) os.flush(); } }
From source file:ca.myewb.frame.servlet.GraphServlet.java
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { Logger log = Logger.getLogger(this.getClass()); try {/*from w w w .j av a2s. c om*/ Session s = HibernateUtil.currentSession(); HttpSession httpSession = req.getSession(); UserModel currentUser = WrapperServlet.getUser(Helpers.getDefaultURL(), log, s, httpSession); String url = req.getRequestURI(); if (!currentUser.isMember(Helpers.getGroup("Exec"))) { log.warn(currentUser.getUsername() + "tried to access GraphServlet!"); httpSession.setAttribute("message", new ErrorMessage("You can't access the graphs!")); throw new RedirectionException(Helpers.getDefaultURL()); } JFreeChart chart = null; if (url.contains("genderpie")) { chart = getGenderPie(s); } else if (url.contains("languagepie")) { chart = getLanguagePie(s); } else if (url.contains("studentpie")) { chart = getStudentPie(s); } else if (url.contains("chapterrankpie")) { chart = getChapterRankPie(s, url); } else if (url.contains("rankpie")) { chart = getRankPie(); } else if (url.contains("nochapterpie")) { chart = getNoChapterPie(); } else if (url.contains("chapterpie")) { chart = getChapterPie(s); } else if (url.contains("postpie")) { chart = getPostPie(s); } else if (url.contains("post2pie")) { chart = getPost2Pie(s); } else if (url.contains("post3pie")) { chart = getPost3Pie(s); } else if (url.contains("provincepie")) { chart = getProvincePie(s); } else if (url.contains("lastlogin")) { chart = getLastLogin(s); } else if (url.contains("daily4stats")) { chart = getDailyStats(s); } else if (url.contains("daily2stats")) { chart = getDaily2Stats(s); } else if (url.contains("daily3stats")) { chart = getDaily3Stats(s); } else if (url.contains("dailyintegratedstats")) { chart = getDailyIntegratedStats(s); } else if (url.contains("logins")) { chart = getLogins(s); } else if (url.contains("dailynewstats")) { chart = getNewDailyStats(s); } else if (url.contains("birthyears")) { chart = getBirthyears(s); } else if (url.contains("listmemberships") || url.contains("chaptermemberships")) { chart = getListMemberships(s, Integer.parseInt(url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'))), currentUser); } res.setContentType("image/png"); OutputStream out = res.getOutputStream(); if (url.contains("listmemberships")) { ChartUtilities.writeChartAsPNG(out, chart, 700, 500); } else { ChartUtilities.writeChartAsPNG(out, chart, 800, 600); } } catch (RedirectionException re) { log.info("Clean redirect: " + re.getTargetURL()); res.sendRedirect(re.getTargetURL()); } catch (Exception e) { log.error("graph servlet error", e); res.sendError(500, e.toString()); } }
From source file:org.matsim.contrib.analysis.vsp.traveltimedistance.TravelTimeValidationRunner.java
private void writeTravelTimeValidation(String folder, List<CarTrip> trips) { BufferedWriter bw = IOUtils.getBufferedWriter(folder + "/validated_trips.csv"); XYSeriesCollection times = new XYSeriesCollection(); XYSeriesCollection distances = new XYSeriesCollection(); XYSeries distancess = new XYSeries("distances", true, true); XYSeries timess = new XYSeries("times", true, true); times.addSeries(timess);//from w w w.j a va 2 s. c o m distances.addSeries(distancess); try { bw.append( "agent;departureTime;fromX;fromY;toX;toY;traveltimeActual;traveltimeValidated;traveledDistance;validatedDistance"); for (CarTrip trip : trips) { if (trip.getValidatedTravelTime() != null) { bw.newLine(); bw.append(trip.toString()); timess.add(trip.getActualTravelTime(), trip.getValidatedTravelTime()); distancess.add(trip.getTravelledDistance(), trip.getValidatedTravelDistance()); } } bw.flush(); bw.close(); final JFreeChart chart2 = ChartFactory.createScatterPlot("Travel Times", "Simulated travel time [s]", "Validated travel time [s]", times); final JFreeChart chart = ChartFactory.createScatterPlot("Travel Distances", "Simulated travel distance [m]", "Validated travel distance [m]", distances); NumberAxis yAxis = (NumberAxis) ((XYPlot) chart2.getPlot()).getRangeAxis(); NumberAxis xAxis = (NumberAxis) ((XYPlot) chart2.getPlot()).getDomainAxis(); NumberAxis yAxisd = (NumberAxis) ((XYPlot) chart.getPlot()).getRangeAxis(); NumberAxis xAxisd = (NumberAxis) ((XYPlot) chart.getPlot()).getDomainAxis(); yAxisd.setUpperBound(xAxisd.getUpperBound()); yAxis.setUpperBound(xAxis.getUpperBound()); yAxis.setTickUnit(new NumberTickUnit(500)); xAxis.setTickUnit(new NumberTickUnit(500)); XYAnnotation diagonal = new XYLineAnnotation(xAxis.getRange().getLowerBound(), yAxis.getRange().getLowerBound(), xAxis.getRange().getUpperBound(), yAxis.getRange().getUpperBound()); ((XYPlot) chart2.getPlot()).addAnnotation(diagonal); XYAnnotation diagonald = new XYLineAnnotation(xAxisd.getRange().getLowerBound(), yAxisd.getRange().getLowerBound(), xAxisd.getRange().getUpperBound(), yAxisd.getRange().getUpperBound()); ((XYPlot) chart.getPlot()).addAnnotation(diagonald); ChartUtilities.writeChartAsPNG(new FileOutputStream(folder + "/validated_traveltimes" + ".png"), chart2, 1500, 1500); ChartUtilities.writeChartAsPNG(new FileOutputStream(folder + "/validated_traveldistances.png"), chart, 1500, 1500); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:net.commerce.zocalo.freechart.ChartGenerator.java
private static File writeChartAsPNG(int chartWidth, int chartHeight, JFreeChart chart, File existingPngFile) throws IOException { if (!existingPngFile.getParentFile().exists()) { existingPngFile.getParentFile().mkdirs(); }//from w w w.j a va 2 s .co m File pngFile = new File(existingPngFile.getAbsolutePath() + ".next"); OutputStream pngStream = new FileOutputStream(pngFile); ChartUtilities.writeChartAsPNG(pngStream, chart, chartWidth, chartHeight); pngStream.close(); if (pngFile.renameTo(existingPngFile)) { return existingPngFile; } else { return pngFile; } }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException { log.debug("In MeasurementGraphAction2"); String userrole = (String) request.getSession().getAttribute("userrole"); if (userrole == null) { response.sendRedirect("../logout.jsp"); }/*from ww w . ja v a2 s. c o m*/ String demographicNo = request.getParameter("demographic_no"); String typeIdName = request.getParameter("type"); String typeIdName2 = request.getParameter("type2"); String patientName = oscar.oscarDemographic.data.DemographicNameAgeString.getInstance() .getNameAgeString(demographicNo); String chartTitle = "Data Graph for " + patientName; int width = 800; int height = 400; String method = request.getParameter("method"); log.debug("Creating graph for demo " + demographicNo + " type1 :" + typeIdName + " type2 :" + typeIdName2); JFreeChart chart = null; if (method == null) { log.debug("Calling DefaultChart"); chart = defaultChart(demographicNo, typeIdName, typeIdName2, patientName, chartTitle); } else if (method.equals("inclRef")) { chart = referenceRangeChart(demographicNo, typeIdName, typeIdName2, patientName, chartTitle); } else if (method.equals("rxincl")) { chart = rxAndLabChart(demographicNo, typeIdName, typeIdName2, patientName, chartTitle); } else if (method.equals("lab")) { chart = labChart(demographicNo, typeIdName, typeIdName2, patientName, chartTitle); } else if (method.equals("labRef")) { chart = labChartRef(demographicNo, typeIdName, typeIdName2, patientName, chartTitle); } else if (method.equals("actualLab")) { String labType = request.getParameter("labType"); String identifier = request.getParameter("identifier"); String testName = request.getParameter("testName"); String drugs[] = request.getParameterValues("drug"); if (drugs == null) { chart = actualLabChartRef(demographicNo, labType, identifier, testName, patientName, chartTitle); } else { chart = actualLabChartRefPlusMeds(demographicNo, labType, identifier, testName, patientName, chartTitle, drugs); } } else if (method.equals("ChartMeds")) { String drugs[] = request.getParameterValues("drug"); chart = ChartMeds(demographicNo, patientName, chartTitle, drugs); if (drugs != null && drugs.length > 10) { height = (drugs.length * 30); } } else { chart = defaultChart(demographicNo, typeIdName, typeIdName2, patientName, chartTitle); } response.setContentType("image/png"); OutputStream o = response.getOutputStream(); ChartUtilities.writeChartAsPNG(o, chart, width, height); o.close(); return null; }
From source file:Servlet3.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {//from www . java 2 s . com System.out.println("inside servlet"); String a = request.getParameter("countryf"); String c = request.getParameter("submit"); String b = request.getParameter("paramf"); String CurentUID = request.getParameter("UIDvalue2f"); String URLRequest = request.getRequestURL().append('?').append(request.getQueryString()).toString(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 1); SimpleDateFormat format1 = new SimpleDateFormat("EEE MMM dd hh:mm:ss yyyy"); String date1 = cal.getTime().toString(); System.out.println("inside servlet"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:server"); // To Insert data to UserActivity table for Recent Activities Tab Statement sthistoryinsert3 = con.createStatement(); String insertstring = "Insert into UserActivity values('" + CurentUID + "','" + date1 + "','Future Data Forecast','" + a + "','" + b + "','" + URLRequest + "')"; sthistoryinsert3.executeUpdate(insertstring); sthistoryinsert3.close(); System.out.println("\n Step 1"); Statement st = con.createStatement(); XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries(b); String query = "SELECT [2000],[2012] FROM country where CountryName='" + a + "' AND SeriesName='" + b + "'"; System.out.println(query); ResultSet rs = st.executeQuery(query); if (rs == null) System.out.println("\n no rows "); else System.out.println("Rows present "); rs.next(); Double start = Double.parseDouble(rs.getString(1)); Double end = Double.parseDouble(rs.getString(2)); Double period = 13.0; Double growth = Math.pow((end / start), (1 / period)) - 1; System.out.println("growth percentage =" + growth); rs.close(); String query2 = "select [2011],[2012] from country where CountryName='" + a + "' AND SeriesName='" + b + "'"; rs = st.executeQuery(query2); rs.next(); series.add(2011, Double.parseDouble(rs.getString(1))); Double second = Double.parseDouble(rs.getString(2)); series.add(2012, second); Double growthvalue = second + (second * growth); series.add(2013, growthvalue); for (int i = 2014; i <= 2016; i++) { System.out.println("actual growth value = " + growthvalue); series.add((i++), (growthvalue + growthvalue * growth)); growthvalue = growthvalue + growthvalue * growth; } rs.close(); dataset.addSeries(series); DecimalFormat format_2Places = new DecimalFormat("0.00"); growth = growth * 100; growth = Double.valueOf(format_2Places.format(growth)); JFreeChart chart = ChartFactory.createXYLineChart( "Energy forecasting for " + a + " based on " + b + " with growth value estimated at " + growth + "% ", "Year", "Energy consumed in millions", dataset, PlotOrientation.VERTICAL, true, true, false); ByteArrayOutputStream bos = new ByteArrayOutputStream(); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(2, false); renderer.setSeriesShapesVisible(2, false); plot.setRenderer(renderer); // To insert colored Pie Chart into the PDF file using // iText now if (c.equals("View Graph in Browser")) { ChartUtilities.writeChartAsPNG(bos, chart, 700, 500); response.setContentType("image/png"); OutputStream out = new BufferedOutputStream(response.getOutputStream()); out.write(bos.toByteArray()); out.flush(); out.close(); } else { int width = 640; /* Width of our chart */ int height = 480; /* Height of our chart */ Document PieChart = new Document(new com.itextpdf.text.Rectangle(width, height)); java.util.Date date = new java.util.Date(); String chartname = "My_Colored_Chart" + date.getTime() + ".pdf"; PdfWriter writer = PdfWriter.getInstance(PieChart, new FileOutputStream(chartname)); PieChart.open(); PieChart.addTitle("Pie-Chart"); PieChart.addAuthor("MUurugappan"); PdfContentByte Add_Chart_Content = writer.getDirectContent(); PdfTemplate template_Chart_Holder = Add_Chart_Content.createTemplate(width, height); Graphics2D Graphics_Chart = template_Chart_Holder.createGraphics(width, height, new DefaultFontMapper()); Rectangle2D Chart_Region = new Rectangle2D.Double(0, 0, 540, 380); chart.draw(Graphics_Chart, Chart_Region); Graphics_Chart.dispose(); Add_Chart_Content.addTemplate(template_Chart_Holder, 0, 0); PieChart.close(); PdfReader reader = new PdfReader(chartname); PdfStamper stamper = null; try { stamper = new PdfStamper(reader, bos); } catch (DocumentException e) { e.printStackTrace(); } try { stamper.close(); } catch (DocumentException e) { e.printStackTrace(); } // set response headers to view PDF response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setContentType("application/pdf"); response.setContentLength(bos.size()); OutputStream os = response.getOutputStream(); bos.writeTo(os); os.flush(); os.close(); } } catch (Exception i) { i.printStackTrace(); } }
From source file:org.lsug.quota.portlet.SitesQuotaPortlet.java
@Override public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); StringBundler sb = new StringBundler(5); String type = ParamUtil.getString(resourceRequest, "type", "sites"); JFreeChart jFreeChart = null;//from w ww. j a va 2 s. c o m DefaultPieDataset pieDataset = new DefaultPieDataset(); try { long[] classNameIds = null; if ("sites".equals(type)) { classNameIds = new long[] { PortalUtil.getClassNameId(Group.class.getName()), PortalUtil.getClassNameId(Organization.class.getName()) }; } else { classNameIds = new long[] { PortalUtil.getClassNameId(User.class.getName()) }; } // OrderByComparator String orderByCol = "quotaUsed"; String orderByType = "desc"; OrderByComparator orderByComparator = QuotaUtil.getQuotaOrderByComparator(orderByCol, orderByType); List<Quota> siteQuotas = QuotaLocalServiceUtil.getQuotaByCompanyIdClassNameIds( themeDisplay.getCompanyId(), classNameIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, orderByComparator); for (Quota siteQuota : siteQuotas) { if (siteQuota.isEnabled()) { Group group = GroupLocalServiceUtil.getGroup(siteQuota.getClassPK()); pieDataset.setValue(group.getDescriptiveName(themeDisplay.getLocale()), siteQuota.getQuotaUsed()); } } sb.append(QuotaUtil.getResource(resourceRequest, "sites-quota-enabled-sites-used-diagram-title")); jFreeChart = getCurrentSizeJFreeChart(sb.toString(), pieDataset); resourceResponse.setContentType(ContentTypes.IMAGE_PNG); OutputStream outputStream = null; try { outputStream = resourceResponse.getPortletOutputStream(); ChartUtilities.writeChartAsPNG(outputStream, jFreeChart, 400, 200); } finally { if (outputStream != null) { outputStream.close(); } } } catch (Exception e) { LOGGER.error(e); throw new PortletException(e); } }
From source file:org.jfree.eastwood.ChartServlet.java
/** * Process a GET request.//ww w . j a v a 2 s . c o m * * @param request the request. * @param response the response. * * @throws ServletException if there is a servlet related problem. * @throws IOException if there is an I/O problem. */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { OutputStream out = response.getOutputStream(); try { Map params = Parameters.parseQueryString(request.getQueryString()); JFreeChart chart = ChartEngine.buildChart(params, this.font); if (chart != null) { response.setContentType("image/png"); // *** CHART SIZE *** String[] size = (String[]) params.get("chs"); int[] dims = new int[2]; if (size != null) { dims = parseChartDimensions(size[0]); } else { dims = new int[] { 200, 125 }; } ChartUtilities.writeChartAsPNG(out, chart, dims[0], dims[1]); } } catch (Exception e) { e.printStackTrace(); } finally { out.close(); } }
From source file:org.jboss.console.plugins.monitor.ManageSnapshotServlet.java
protected void doit(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String action = req.getParameter("action"); if (action == null) { error("unknown action: ", req, resp); return;/*from w w w . j av a 2 s . c om*/ } action = action.trim(); MBeanServer mbeanServer = MBeanServerLocator.locateJBoss(); ObjectName monitorObjectName; String attribute = null; try { monitorObjectName = new ObjectName(req.getParameter("monitorObjectName")); attribute = (String) mbeanServer.getAttribute(monitorObjectName, "ObservedAttribute"); } catch (Exception ex) { error("Malformed Monitor ObjectName: " + req.getParameter("monitorObjectName"), req, resp); return; } if (action.equals("Start Snapshot")) { Object[] nullArgs = {}; String[] nullSig = {}; try { mbeanServer.invoke(monitorObjectName, "startSnapshot", nullArgs, nullSig); } catch (Exception ex) { error("Problem invoking startSnapshot: " + ex.toString(), req, resp); return; } req.getRequestDispatcher("/manageSnapshot.jsp").forward(req, resp); return; } else if (action.equals("Stop Snapshot")) { Object[] nullArgs = {}; String[] nullSig = {}; try { mbeanServer.invoke(monitorObjectName, "endSnapshot", nullArgs, nullSig); } catch (Exception ex) { error("Problem invoking endSnapshot: " + ex.toString(), req, resp); return; } req.getRequestDispatcher("/manageSnapshot.jsp").forward(req, resp); return; } else if (action.equals("Clear Dataset")) { Object[] nullArgs = {}; String[] nullSig = {}; try { mbeanServer.invoke(monitorObjectName, "clearData", nullArgs, nullSig); } catch (Exception ex) { error("Problem invoking clearData: " + ex.toString(), req, resp); return; } req.setAttribute("error", "Dataset Cleared!"); req.getRequestDispatcher("/manageSnapshot.jsp").forward(req, resp); return; } else if (action.equals("Remove Snapshot")) { try { log.debug("removing snapshot: " + monitorObjectName.toString()); mbeanServer.unregisterMBean(monitorObjectName); req.getRequestDispatcher("/ServerInfo.jsp").forward(req, resp); } catch (Exception ex) { error("Failed to Remove Monitor: " + ex.toString(), req, resp); } return; } else if (action.equals("Show Dataset")) { ArrayList data = null; long start, end = 0; try { data = (ArrayList) mbeanServer.getAttribute(monitorObjectName, "Data"); start = ((Long) mbeanServer.getAttribute(monitorObjectName, "StartTime")).longValue(); end = ((Long) mbeanServer.getAttribute(monitorObjectName, "EndTime")).longValue(); } catch (Exception ex) { error("Problem invoking getData: " + ex.toString(), req, resp); return; } resp.setContentType("text/html"); PrintWriter writer = resp.getWriter(); writer.println("<html>"); writer.println("<body>"); writer.println("<b>Start Time:</b> " + start + "ms<br>"); writer.println("<b>End Time:</b> " + end + "ms<br>"); writer.println("<b>Total Time:</b> " + (end - start) + "ms<br>"); writer.println("<br><table border=\"0\">"); for (int i = 0; i < data.size(); i++) { writer.println("<tr><td>" + data.get(i) + "</td></tr"); } writer.println("</table></body></html>"); return; } else if (action.equals("Graph Dataset")) { ArrayList data = null; long start, end = 0; try { data = (ArrayList) mbeanServer.getAttribute(monitorObjectName, "Data"); start = ((Long) mbeanServer.getAttribute(monitorObjectName, "StartTime")).longValue(); end = ((Long) mbeanServer.getAttribute(monitorObjectName, "EndTime")).longValue(); } catch (Exception ex) { error("Problem invoking getData: " + ex.toString(), req, resp); return; } XYSeries set = new XYSeries(attribute, false, false); for (int i = 0; i < data.size(); i++) { set.add(new Integer(i), (Number) data.get(i)); } DefaultTableXYDataset dataset = new DefaultTableXYDataset(false); dataset.addSeries(set); JFreeChart chart = ChartFactory.createXYLineChart("JMX Attribute: " + attribute, "count", attribute, dataset, PlotOrientation.VERTICAL, true, true, false); resp.setContentType("image/png"); OutputStream out = resp.getOutputStream(); ChartUtilities.writeChartAsPNG(out, chart, 400, 300); out.close(); return; } error("Unknown Action", req, resp); return; }
From source file:org.matsim.contrib.drt.analysis.DrtRequestAnalyzer.java
public void writeAndPlotWaitTimeEstimateComparison(String plotFileName, String textFileName) { BufferedWriter bw = IOUtils.getBufferedWriter(textFileName); XYSeries times = new XYSeries("waittimes", true, true); try {/*w w w. j ava 2 s . co m*/ bw.append("RequestId;actualWaitTime;estimatedWaitTime;deviate"); for (Entry<Id<Request>, Tuple<Double, Double>> e : this.waitTimeCompare.entrySet()) { bw.newLine(); double first = e.getValue().getFirst(); double second = e.getValue().getSecond(); bw.append(e.getKey().toString() + ";" + first + ";" + second + ";" + (first - second)); times.add(first, second); } bw.flush(); bw.close(); final JFreeChart chart2 = DensityScatterPlots.createPlot("Wait times", "Actual wait time [s]", "Initially planned wait time [s]", times, Pair.of(0., drtCfg.getMaxWaitTime())); // xAxis.setLowerBound(0); // yAxis.setLowerBound(0); ChartUtilities.writeChartAsPNG(new FileOutputStream(plotFileName), chart2, 1500, 1500); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }