List of usage examples for org.jfree.chart.renderer.xy StandardXYItemRenderer LINES
int LINES
To view the source code for org.jfree.chart.renderer.xy StandardXYItemRenderer LINES.
Click Source Link
From source file:org.jfree.chart.demo.ImageMapDemo3.java
/** * Starting point for the demo./*from w ww . ja va 2 s.com*/ * * @param args ignored. * * @throws ParseException if there is a problem parsing dates. */ public static void main(final String[] args) throws ParseException { // Create a sample dataset final SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy"); final XYSeries dataSeries = new XYSeries("Curve data"); final ArrayList toolTips = new ArrayList(); dataSeries.add(sdf.parse("01-Jul-2002").getTime(), 5.22); toolTips.add("1D - 5.22"); dataSeries.add(sdf.parse("02-Jul-2002").getTime(), 5.18); toolTips.add("2D - 5.18"); dataSeries.add(sdf.parse("03-Jul-2002").getTime(), 5.23); toolTips.add("3D - 5.23"); dataSeries.add(sdf.parse("04-Jul-2002").getTime(), 5.15); toolTips.add("4D - 5.15"); dataSeries.add(sdf.parse("05-Jul-2002").getTime(), 5.22); toolTips.add("5D - 5.22"); dataSeries.add(sdf.parse("06-Jul-2002").getTime(), 5.25); toolTips.add("6D - 5.25"); dataSeries.add(sdf.parse("07-Jul-2002").getTime(), 5.31); toolTips.add("7D - 5.31"); dataSeries.add(sdf.parse("08-Jul-2002").getTime(), 5.36); toolTips.add("8D - 5.36"); final XYSeriesCollection xyDataset = new XYSeriesCollection(dataSeries); final CustomXYToolTipGenerator ttg = new CustomXYToolTipGenerator(); ttg.addToolTipSeries(toolTips); // Create the chart final StandardXYURLGenerator urlg = new StandardXYURLGenerator("xy_details.jsp"); final ValueAxis timeAxis = new DateAxis(""); final NumberAxis valueAxis = new NumberAxis(""); valueAxis.setAutoRangeIncludesZero(false); // override default final XYPlot plot = new XYPlot(xyDataset, timeAxis, valueAxis, null); final StandardXYItemRenderer sxyir = new StandardXYItemRenderer( StandardXYItemRenderer.LINES + StandardXYItemRenderer.SHAPES, ttg, urlg); sxyir.setShapesFilled(true); plot.setRenderer(sxyir); final JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("xychart100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("xychart100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"xychart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } return; }
From source file:bzstats.chart.KillRatioHistoryChart.java
protected JFreeChart getChart() { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); fillDataset(dataset);/*from w w w . j av a2s. co m*/ XYPlot plot = new XYPlot(); NumberAxis xaxis = new NumberAxis("Time"); xaxis.setTickLabelsVisible(false); NumberAxis yaxis = new NumberAxis("Killratio"); plot.setDomainAxis(xaxis); plot.setRangeAxis(yaxis); plot.setDataset(dataset); plot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); JFreeChart chart = new JFreeChart("Killratio", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.addSubtitle(new TextTitle("kills/deaths")); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.sonar.server.charts.deprecated.SparkLinesChart.java
private void configureRenderer() { renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakAnnotationReportPanel.java
protected void initComponents() { setLayout(new BorderLayout()); // create chart theDataset = new DefaultXYDataset(); theChart = org.jfree.chart.ChartFactory.createScatterPlot("Annotation", "Count", "Intensity", theDataset, org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false); thePlot = (XYPlot) theChart.getPlot(); thePlot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); theChartPanel = new ChartPanel(theChart); theChartPanel.setDomainZoomable(true); theChartPanel.setRangeZoomable(false); //theChartPanel.setPopupMenu(null); add(theChartPanel, BorderLayout.CENTER); // create toolbar theToolBar = createToolBar();// w w w .j a v a 2 s . c o m add(theToolBar, BorderLayout.SOUTH); }
From source file:domainhealth.frontend.graphics.JFreeChartGraphImpl.java
/** * Write a PNG image representation of the Graph to the given output * stream/*from ww w . j av a 2 s . co m*/ * * @param out The output stream to write the PNG bytes to * @throws IOException Indicates a problem writing to the output stream */ public void writeGraphImage(int numServersDisplayed, OutputStream out) throws IOException { ValueAxis xAxis = new DateAxis(MonitorProperties.units(DATE_TIME)); NumberAxis yAxis = new NumberAxis(yAxisUnits); yAxis.setAutoRangeIncludesZero(true); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYPlot xyPlotLine = new XYPlot(xySeriesCollection, xAxis, yAxis, new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, xyPlotLine, true); chart.setBackgroundPaint(java.awt.Color.white); // Increase size of graph height to accommodate large legends for when many servers in the domain int graphAdditionalHeight = GRAPH_INCREMENT_HEIGHT * ((int) (numServersDisplayed / GRAPH_INCREMENT_SERVER_RATIO)); BufferedImage graphImage = chart.createBufferedImage(GRAPH_WIDTH, INITIAL_GRAPH_HEIGHT + graphAdditionalHeight, new ChartRenderingInfo(new StandardEntityCollection())); addNoDataLogoIfEmpty(graphImage); ChartUtilities.writeBufferedImageAsPNG(out, graphImage); // Could try extra two PNG related params: encodeAlpha and compression }
From source file:com.unicornlabs.kabouter.reporting.PowerReport.java
public static void GeneratePowerReport(Date startDate, Date endDate) { try {//w ww .j a v a 2 s. com Historian theHistorian = (Historian) BusinessObjectManager.getBusinessObject(Historian.class.getName()); ArrayList<String> powerLogDeviceIds = theHistorian.getPowerLogDeviceIds(); Document document = new Document(PageSize.A4, 50, 50, 50, 50); File outputFile = new File("PowerReport.pdf"); outputFile.createNewFile(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile)); document.open(); document.add(new Paragraph("Power Report for " + startDate.toString() + " to " + endDate.toString())); document.newPage(); DecimalFormat df = new DecimalFormat("#.###"); for (String deviceId : powerLogDeviceIds) { ArrayList<Powerlog> powerlogs = theHistorian.getPowerlogs(deviceId, startDate, endDate); double total = 0; double max = 0; Date maxTime = startDate; double average = 0; XYSeries series = new XYSeries(deviceId); XYDataset dataset = new XYSeriesCollection(series); for (Powerlog log : powerlogs) { total += log.getPower(); if (log.getPower() > max) { max = log.getPower(); maxTime = log.getId().getLogtime(); } series.add(log.getId().getLogtime().getTime(), log.getPower()); } average = total / powerlogs.size(); document.add(new Paragraph("\nDevice: " + deviceId)); document.add(new Paragraph("Average Power Usage: " + df.format(average))); document.add(new Paragraph("Maximum Power Usage: " + df.format(max) + " at " + maxTime.toString())); document.add(new Paragraph("Total Power Usage: " + df.format(total))); //Create a custom date axis to display dates on the X axis DateAxis dateAxis = new DateAxis("Date"); //Make the labels vertical dateAxis.setVerticalTickLabels(true); //Create the power axis NumberAxis powerAxis = new NumberAxis("Power"); //Set both axes to auto range for their values powerAxis.setAutoRange(true); dateAxis.setAutoRange(true); //Create the tooltip generator StandardXYToolTipGenerator ttg = new StandardXYToolTipGenerator("{0}: {2}", new SimpleDateFormat("yyyy/MM/dd HH:mm"), NumberFormat.getInstance()); //Set the renderer StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES, ttg, null); //Create the plot XYPlot plot = new XYPlot(dataset, dateAxis, powerAxis, renderer); //Create the chart JFreeChart myChart = new JFreeChart(deviceId, JFreeChart.DEFAULT_TITLE_FONT, plot, true); PdfContentByte pcb = writer.getDirectContent(); PdfTemplate tp = pcb.createTemplate(480, 360); Graphics2D g2d = tp.createGraphics(480, 360, new DefaultFontMapper()); Rectangle2D r2d = new Rectangle2D.Double(0, 0, 480, 360); myChart.draw(g2d, r2d); g2d.dispose(); pcb.addTemplate(tp, 0, 0); document.newPage(); } document.close(); JOptionPane.showMessageDialog(null, "Report Generated."); Desktop.getDesktop().open(outputFile); } catch (FileNotFoundException fnfe) { JOptionPane.showMessageDialog(null, "Unable To Open File For Writing, Make Sure It Is Not Currently Open"); } catch (IOException ex) { Logger.getLogger(PowerReport.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(PowerReport.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:net.sourceforge.processdash.ui.web.reports.XYChart.java
private void addTrendLine(JFreeChart chart, XYDataset dataset) { XYPlot plot = chart.getXYPlot();// w w w .ja v a2s. c o m plot.setDataset(1, dataset); plot.setRenderer(1, new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); }
From source file:com.projity.pm.graphic.chart.ChartHelper.java
public static JFreeChart createBarLineChart(final XYDataset barDataset, final XYDataset lineDataset) { JFreeChart chart = createBarChart(barDataset); XYItemRenderer lineRenderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES); chart.getXYPlot().setDataset(1, lineDataset); chart.getXYPlot().setRenderer(1, lineRenderer); chart.getXYPlot().setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); chart.getXYPlot().setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // draw the line after the bar so it's superimposed return chart; }
From source file:genj.chart.Chart.java
/** * Constructor for a chart with x/y series of data shown on a 2d pane * as one plot per series. Note: The difference between this and * the first constructor is that of indexed series (where all x-values * are shared indexes) and arbitrary series. * @param title the title of the chart/*from w ww . j a v a2 s .c om*/ * @param labelAxisX a label for the x-axis * @param labelAxisY a label for the y-axis * @param series one or more x/y series to show * @param format a number format to use for x-values * @param shapes whether to show little shape indicators for each x/y pair additionally to the plot */ public Chart(String title, String labelAxisX, String labelAxisY, XYSeries[] series, NumberFormat format, boolean shapes) { // prepare chart setup NumberAxis xAxis = new NumberAxis(labelAxisX); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(labelAxisY); yAxis.setNumberFormatOverride(format); XYItemRenderer renderer = new StandardXYItemRenderer( shapes ? StandardXYItemRenderer.SHAPES_AND_LINES : StandardXYItemRenderer.LINES); XYPlot plot = new XYPlot(XYSeries.toXYDataset(series), xAxis, yAxis, renderer); // init init(title, plot, true); // done }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java
protected void initComponents() { setLayout(new BorderLayout()); // create chart theDataset = new DefaultXYDataset(); theIsotopesDataset = new DefaultXYDataset(); theChart = org.jfree.chart.ChartFactory.createScatterPlot("Spectrum", "m/z ratio", "Intensity", theDataset, org.jfree.chart.plot.PlotOrientation.VERTICAL, false, false, false); thePlot = (XYPlot) theChart.getPlot(); thePlot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); thePlot.setDataset(1, theIsotopesDataset); thePlot.setRenderer(1, new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); theChartPanel = new ChartPanel(theChart); theChartPanel.setDomainZoomable(false); theChartPanel.setRangeZoomable(false); theChartPanel.setPopupMenu(null);/*from w w w. ja v a 2 s.co m*/ //TODO: PAINT-RESTORE add(theChartPanel, BorderLayout.CENTER); // create toolbar theToolBar = createToolBar(); //TODO: PAINT-RESTORE add(theToolBar, BorderLayout.SOUTH); }