List of usage examples for org.jfree.chart.plot XYPlot setRangeGridlinePaint
public void setRangeGridlinePaint(Paint paint)
From source file:org.jfree.chart.demo.XYBarChartDemo5.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("US Budget Deficit", "Year", true, "$ Billion", intervalxydataset, PlotOrientation.VERTICAL, false, false, false); TextTitle texttitle = new TextTitle("Source: http://www.cbo.gov/showdoc.cfm?index=1821&sequence=0#table12"); texttitle.setFont(new Font("Dialog", 0, 8)); texttitle.setPosition(RectangleEdge.BOTTOM); texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT); jfreechart.addSubtitle(texttitle);/*from ww w. j a v a2 s . c o m*/ jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0")); xyitemrenderer.setBaseToolTipGenerator(standardxytooltipgenerator); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.white); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateaxis.setLowerMargin(0.01D); dateaxis.setUpperMargin(0.01D); return jfreechart; }
From source file:org.jfree.chart.demo.BoxAndWhiskerChartDemo2.java
private static JFreeChart createChart(BoxAndWhiskerXYDataset boxandwhiskerxydataset) { DateAxis dateaxis = new DateAxis("Day"); NumberAxis numberaxis = new NumberAxis("Value"); XYBoxAndWhiskerRenderer xyboxandwhiskerrenderer = new XYBoxAndWhiskerRenderer(); XYPlot xyplot = new XYPlot(boxandwhiskerxydataset, dateaxis, numberaxis, xyboxandwhiskerrenderer); xyplot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart jfreechart = new JFreeChart("Box-and-Whisker Chart Demo 2", xyplot); jfreechart.setBackgroundPaint(Color.white); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setDomainGridlinesVisible(true); xyplot.setRangeGridlinePaint(Color.white); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:grisu.frontend.view.swing.files.preview.fileViewers.JobStatusGridFileViewer.java
private static ChartPanel createChart(String title, String y_axis, XYDataset dataset, boolean createLegend) { final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title "Date", // x-axis label y_axis, // y-axis label dataset, // data createLegend, // create legend? true, // generate tooltips? false // generate URLs? );//from w w w. ja v a2 s . c o m chart.setBackgroundPaint(Color.white); final XYPlot plot = (XYPlot) chart.getPlot(); 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); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); final XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd.MM. HH:mm")); return new ChartPanel(chart); }
From source file:org.gephi.statistics.plugin.ChartUtils.java
public static void decorateChart(JFreeChart chart) { XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(0, 0, 2, 2)); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainGridlinePaint(java.awt.Color.GRAY); plot.setRangeGridlinePaint(java.awt.Color.GRAY); plot.setRenderer(renderer);/*from ww w. ja v a 2 s .co m*/ }
From source file:org.gephi.ui.utils.ChartsUtils.java
/** * Build new Scatter plot. Appearance can be changed later with the other methods of ChartsUtils. * @param data Data for the plot/*from w w w . j a va 2 s . c om*/ * @param title Title for the chart * @param xLabel Text for x label * @param yLabel Text for y label * @param useLines Indicates if lines have to be drawn instead of shapes * @param useLinearRegression Indicates if the scatter plot has to have linear regreesion line drawn * @return Scatter plot for the data and appearance options */ public static JFreeChart buildScatterPlot(final XYSeriesCollection data, final String title, final String xLabel, final String yLabel, final boolean useLines, final boolean useLinearRegression) { JFreeChart scatterPlot = ChartFactory.createXYLineChart(title, xLabel, yLabel, data, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) scatterPlot.getPlot(); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainGridlinePaint(java.awt.Color.GRAY); plot.setRangeGridlinePaint(java.awt.Color.GRAY); setScatterPlotLinesEnabled(scatterPlot, useLines); setScatterPlotLinearRegressionEnabled(scatterPlot, useLinearRegression); return scatterPlot; }
From source file:org.jfree.chart.demo.XYBarChartDemo7.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("XYBarChartDemo7", "Date", true, "Y", intervalxydataset, PlotOrientation.VERTICAL, true, false, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainAxis(new DateAxis("Date")); SymbolAxis symbolaxis = new SymbolAxis("Series", new String[] { "S1", "S2", "S3" }); symbolaxis.setGridBandsVisible(false); xyplot.setRangeAxis(symbolaxis);//w w w . jav a 2 s. c o m XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setUseYInterval(true); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); return jfreechart; }
From source file:Data.java
/** * Creates a chart.// w w w . j a v a2s. com * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Graphique des tempratures et humidits", // title "Date", // x-axis label "Temperture/Humidit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); 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); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("d.M.yy HH:mm:ss")); return chart; }
From source file:umberto.WeightedClusterCoefficient.ChartUtils.java
public static void decorateChart(JFreeChart chart) { XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(0, 0, 3, 3)); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainGridlinePaint(java.awt.Color.GRAY); plot.setRangeGridlinePaint(java.awt.Color.GRAY); plot.setRenderer(renderer);// ww w. ja v a2 s .c o m }
From source file:com.leonarduk.finance.chart.CandlestickChart.java
public static void displayCandlestickChart(final Stock stock) throws IOException { final TimeSeries series = TimeseriesUtils.getTimeSeries(stock, 1); /**//from w w w. jav a 2 s.c o m * Creating the OHLC dataset */ final OHLCDataset ohlcDataset = CandlestickChart.createOHLCDataset(series); /** * Creating the additional dataset */ final TimeSeriesCollection xyDataset = CandlestickChart.createAdditionalDataset(series); /** * Creating the chart */ final JFreeChart chart = ChartFactory.createCandlestickChart(stock.getName() + " price", "Time", stock.getCurrency(), ohlcDataset, true); // Candlestick rendering final CandlestickRenderer renderer = new CandlestickRenderer(); renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); final XYPlot plot = chart.getXYPlot(); plot.setRenderer(renderer); // Additional dataset final int index = 1; plot.setDataset(index, xyDataset); plot.mapDatasetToRangeAxis(index, 0); final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); renderer2.setSeriesPaint(index, Color.blue); plot.setRenderer(index, renderer2); // Misc plot.setRangeGridlinePaint(Color.lightGray); plot.setBackgroundPaint(Color.white); final NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); numberAxis.setAutoRangeIncludesZero(false); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); /** * Displaying the chart */ ChartDisplay.displayChartInFrame(chart, 740, 300, "Candlestick Chart"); }
From source file:org.jfree.chart.demo.ThumbnailDemo1.java
private static JFreeChart createChart4(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Projected Values - Test", "Date", "Index Projection", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setInsets(new RectangleInsets(5D, 5D, 5D, 20D)); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); DeviationRenderer deviationrenderer = new DeviationRenderer(true, false); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesFillPaint(0, new Color(255, 200, 200)); deviationrenderer.setSeriesFillPaint(1, new Color(200, 200, 255)); xyplot.setRenderer(deviationrenderer); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }