List of usage examples for org.jfree.chart.plot XYPlot setDomainGridlinePaint
public void setDomainGridlinePaint(Paint paint)
From source file:loadmaprenderer.ChartTest.java
private JFreeChart makeChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart("Cost/Year Chart", "Year", "Cost", dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLUE); plot.setRangeGridlinePaint(Color.BLUE); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer);/*from w w w .j av a 2s .c o m*/ NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRange(rootPaneCheckingEnabled); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(rootPaneCheckingEnabled); return chart; }
From source file:org.jfree.chart.demo.LineChart.java
private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/*from ww w. j ava 2 s . c o m*/ chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:Charts.LineChart.java
@Override protected JFreeChart createChart(String title, String x, String y) { JFreeChart lineChart = this.makeJFreeChart(title, x, y); // Custom chart.. lineChart.setBackgroundPaint(Color.white); final XYPlot plot = lineChart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesShapesVisible(0, false); plot.setRenderer(renderer);//from ww w.j a va2 s . com return lineChart; }
From source file:ch.unibe.iam.scg.archie.ui.charts.ConsultationMoneyChart.java
/** * @see ch.unibe.iam.scg.archie.ui.charts.AbstractChartComposite# * initializeChart()//from www . j a v a 2 s. c o m */ @Override protected JFreeChart initializeChart() { JFreeChart chart = ChartFactory.createTimeSeriesChart(ConsultationMoneyChart.CHART_TITLE, // title "", // x-axis label "Amount", // y-axis label (XYDataset) this.creator.getDataset(), // data true, // create legend? true, // generate tooltips? false // generate URLs? ); // Set chart background color to it's parents background chart.setBackgroundPaint(new Color(this.parent.getBackground().getRed(), this.parent.getBackground().getGreen(), this.parent.getBackground().getBlue())); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:TradeMonitorGui.java
private XYPlot createChartFrame(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Average Stock Price over 1 minute", "Time", "Price in USD", dataset, true, true, false); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(new Color(245, 245, 245)); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); final JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Trade Monitor"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { avgPrices.removeEntryListener(listenerId); }/*w w w .j a va2s .c o m*/ }); frame.setVisible(true); return plot; }
From source file:ws.moor.bt.gui.charts.RawDownloadRate.java
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Download Rate", "Time", "KB/s", dataset, false, false, false);//from w ww . jav a2 s . c o m chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }
From source file:org.ala.spatial.web.services.GDMWSController.java
public static void generateChart5(String outputdir, String plotName, String plotData) { try {/*from w w w .j a v a 2s . c o m*/ CSVReader csv = new CSVReader(new FileReader(plotData)); List<String[]> rawdata = csv.readAll(); double[][] dataCht = new double[2][rawdata.size() - 1]; for (int i = 1; i < rawdata.size(); i++) { String[] row = rawdata.get(i); dataCht[0][i - 1] = Double.parseDouble(row[0]); dataCht[1][i - 1] = Double.parseDouble(row[1]); } DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("", dataCht); System.out.println("Setting up jChart for " + plotName); //generateChartByType(plotName, plotName, "f("+plotName+")", null, outputdir, "xyline", plotName); JFreeChart jChart = ChartFactory.createXYLineChart(plotName, plotName, "f(" + plotName + ")", dataset, PlotOrientation.VERTICAL, false, false, false); jChart.getTitle().setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14)); XYPlot plot = (XYPlot) jChart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlineStroke(new BasicStroke(0.5F, 0, 1)); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlineStroke(new BasicStroke(0.5F, 0, 1)); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setAutoRangeIncludesZero(false); domain.setAxisLineVisible(false); domain.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setAutoRangeIncludesZero(false); range.setAxisLineVisible(false); range.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); System.out.println("Writing image...."); ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/" + plotName + ".png"), jChart, 500, 500); ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/" + plotName + "_thumb.png"), jChart, 210, 140); } catch (Exception e) { System.out.println("Unable to generate charts 2 and 3:"); e.printStackTrace(System.out); } }
From source file:app.Plot.java
public void plotDesign(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesPaint(0, Color.black); plot.setRenderer(renderer);/*from w w w .j a v a 2s. co m*/ }
From source file:ws.moor.bt.gui.charts.RemotePeerCompletion.java
private JFreeChart createChart(HistogramDataset dataset) { JFreeChart chart = ChartFactory.createHistogram("Remote Peer Completion", "Completion %", "Peers", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setRange(0.0, 100.0); return chart; }
From source file:com.graphhopper.jsprit.analysis.toolbox.XYLineChartBuilder.java
/** * Builds and returns JFreeChart.//from w ww . ja v a2 s . co m * * @return */ public JFreeChart build() { XYSeriesCollection collection = new XYSeriesCollection(); for (XYSeries s : seriesMap.values()) { collection.addSeries(s); } JFreeChart chart = ChartFactory.createXYLineChart(chartName, xDomain, yDomain, collection, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); return chart; }