List of usage examples for org.jfree.chart.plot XYPlot setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:compecon.dashboard.panel.AbstractChartsPanel.java
protected void configureChart(JFreeChart chart) { chart.setBackgroundPaint(Color.white); 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)); DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); dateAxis.setDateFormatOverride(new SimpleDateFormat("dd-MMM")); valueAxis.setAutoRangeIncludesZero(true); valueAxis.setUpperMargin(0.15);//from w w w. j a v a2 s . c om valueAxis.setLowerMargin(0.15); }
From source file:gov.sandia.umf.platform.ui.jobs.Plot.java
public JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );//from ww w . j a v a 2s . co m chart.setBackgroundPaint(Color.white); LegendTitle legend = chart.getLegend(); legend.setVisible(dataset.getSeriesCount() <= 5); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainPannable(true); plot.setRangePannable(true); ValueAxis axis = plot.getRangeAxis(); if (axis instanceof NumberAxis) ((NumberAxis) axis).setAutoRangeIncludesZero(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < dataset.getSeriesCount(); i++) renderer.setSeriesShapesVisible(i, false); plot.setRenderer(renderer); return chart; }
From source file:sanger.team16.gui.genevar.eqtl.gene.RegionalPlot.java
private JFreeChart createChart(String geneChromosome, int geneStart, int distanceToTSS, double threshold, XYDataset dataset) {/*from w w w. j a v a 2s . co m*/ JFreeChart chart = ChartFactory.createScatterPlot(null, "Position on chromosome " + geneChromosome + " (bp)", "-log10(P)", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.lightGray); //plot.setRangeGridlinePaint(Color.lightGray); //plot.setRangeCrosshairVisible(true); //NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); //domainAxis.setRange(geneStart - distance, geneStart + distance); //domainAxis.setUpperMargin(1000); //domainAxis.setLowerMargin(1000); //ValueAxis rangeAxis = plot.getRangeAxis(); //rangeAxis.setUpperMargin(dataset.getYValue(0, 0)/5); //rangeAxis.setLowerBound(0); XYItemRenderer renderer = plot.getRenderer(); int size = dataset.getSeriesCount(); for (int i = 0; i < size; i++) { //int scale = (int) Math.round((255 - (255 * dataset.getYValue(i, 0)) / top) / 1.4); //renderer.setSeriesPaint(i, new Color(255, scale, scale)); renderer.setSeriesPaint(i, new Color(255, 0, 0)); renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3)); renderer.setBaseSeriesVisibleInLegend(false); } ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold)); upperMarker.setPaint(Color.gray); //upperMarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); //upperMarker.setLabel("-log10(10E-4)"); //upperMarker.setLabelPaint(Color.red); //upperMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); //upperMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); float[] f = { 4, 3, 4, 3 }; upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f)); plot.addRangeMarker(upperMarker); ValueMarker marker = new ValueMarker(0.0); marker.setPaint(Color.lightGray); plot.addRangeMarker(marker); XYSeries series = new XYSeries("Range"); series.add(geneStart - distanceToTSS, -0.05); series.add(geneStart + distanceToTSS, -0.05); ((XYSeriesCollection) dataset).addSeries(series); renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false); return chart; }
From source file:sanger.team16.gui.genevar.mqtl.gene.RegionalPlot.java
private JFreeChart createChart(String geneChromosome, int geneStart, int distanceToTSS, double threshold, XYDataset dataset) {//from ww w .ja v a2s . c om JFreeChart chart = ChartFactory.createScatterPlot(null, "Position on chromosome " + geneChromosome + " (bp)", "-log10(P)", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.lightGray); //plot.setRangeGridlinePaint(Color.lightGray); //plot.setRangeCrosshairVisible(true); //NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); //domainAxis.setRange(geneStart - distance, geneStart + distance); //domainAxis.setUpperMargin(1000); //domainAxis.setLowerMargin(1000); //ValueAxis rangeAxis = plot.getRangeAxis(); //rangeAxis.setUpperMargin(dataset.getYValue(0, 0)/5); //rangeAxis.setLowerBound(0); XYItemRenderer renderer = plot.getRenderer(); int size = dataset.getSeriesCount(); for (int i = 0; i < size; i++) { //int scale = (int) Math.round((255 - (255 * dataset.getYValue(i, 0)) / top) / 1.4); //renderer.setSeriesPaint(i, new Color(255, scale, scale)); renderer.setSeriesPaint(i, new Color(50, 205, 50)); renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3)); renderer.setBaseSeriesVisibleInLegend(false); } ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold)); upperMarker.setPaint(Color.gray); //upperMarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); //upperMarker.setLabel("-log10(10E-4)"); //upperMarker.setLabelPaint(Color.red); //upperMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); //upperMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); float[] f = { 4, 3, 4, 3 }; upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f)); plot.addRangeMarker(upperMarker); ValueMarker marker = new ValueMarker(0.0); marker.setPaint(Color.lightGray); plot.addRangeMarker(marker); XYSeries series = new XYSeries("Range"); series.add(geneStart - distanceToTSS, -0.05); series.add(geneStart + distanceToTSS, -0.05); ((XYSeriesCollection) dataset).addSeries(series); renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false); return chart; }
From source file:fr.paris.lutece.plugins.form.utils.FormUtils.java
/** * create a JFreeChart Graph function of the statistic form submit * @param listStatistic the list of statistic of form submit * @param strLabelX the label of axis x/* w ww .j av a 2 s. c o m*/ * @param strLableY the label of axis x * @param strTimesUnit the times unit of axis x(Day,Week,Month) * @return a JFreeChart Graph function of the statistic form submit */ public static JFreeChart createXYGraph(List<StatisticFormSubmit> listStatistic, String strLabelX, String strLableY, String strTimesUnit) { XYDataset xyDataset = createDataset(listStatistic, strTimesUnit); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(EMPTY_STRING, strLabelX, strLableY, xyDataset, false, false, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = jfreechart.getXYPlot(); //xyplot.setBackgroundPaint(Color.gray); //xyplot.setRangeGridlinesVisible(true); xyplot.setBackgroundPaint(Color.white); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); // DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis( ); // dateaxis.setLowerMargin(0); // DateFormat formatter = new SimpleDateFormat("d-MMM-yyyy"); // dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY,7,formatter)); //dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY,7)); //dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY,7)); //dateaxis.setMinimumDate((Date)listStatistic.get(0).getTimesUnit()); //dateaxis.setMaximumDate((Date)listStatistic.get(listStatistic.size()-1).getTimesUnit()); //dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH,1)); //dateaxis.setTickUnit(new DateTickUnit(1, 1, DateFormat.getDateInstance(DateFormat.SHORT, Locale.FRENCH))); //dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1, new SimpleDateFormat("MM/YY"))); //dateaxis.setVerticalTickLabels( true ); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesFillPaint(0, Color.RED); renderer.setUseFillPaint(true); // renderer.setToolTipGenerator( new StandardXYToolTipGenerator( "{0} {1} {2}", // DateFormat.getDateInstance( DateFormat.SHORT, Locale.FRENCH ), NumberFormat.getInstance( ) ) ); // // ChartRenderingInfo info = new ChartRenderingInfo( new StandardEntityCollection( ) ); return jfreechart; }
From source file:org.jfree.chart.demo.XYAreaChartDemo.java
/** * Creates a chart./*from w w w. j av a 2s . co m*/ * * @param dataset the dataset. * * @return A chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYAreaChart("XY Area Chart Demo", "Domain (X)", "Range (Y)", dataset, PlotOrientation.VERTICAL, true, // legend true, // tool tips false // URLs ); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); //plot.setOutlinePaint(Color.black); plot.setBackgroundPaint(Color.lightGray); plot.setForegroundAlpha(0.65f); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickMarkPaint(Color.black); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); final ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setTickMarkPaint(Color.black); return chart; }
From source file:Utils.GeneradorDeGraficas.java
public JFreeChart graficarCostos(DeterministaGeneral general, String unidad) { XYDataset dataset;//from w w w. ja v a 2s . com dataset = createDatasetCosto(general, unidad); JFreeChart chart = ChartFactory.createXYLineChart("Anlisis de Costo de Inventario por " + unidad, "Cantidad de pedido", "Costo", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(4, black, true); renderer.setSeriesPaint(3, black, true); /* renderer.setShapesFilled(true); renderer.setShapesVisible(true);*/ XYPlot plot2 = chart.getXYPlot(); NumberAxis rangeAxis = (NumberAxis) plot2.getRangeAxis(); rangeAxis.setAutoRange(false); rangeAxis.setUpperBound(general.calcularCostoGrafica(general.calcularCantidadOptimaOrdenar()) * 2); return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperNormalDistributionChart.java
/** * Creates a chart.//w ww. ja v a 2s.co m * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.jfree.chart.demo.PlotOrientationDemo.java
/** * Creates a sample chart.//from ww w . j a va2s . c om * * @param index the chart index. * @param dataset the dataset. * * @return A chart. */ private JFreeChart createChart(int index, XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart("Chart " + (index + 1), // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend false, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPlotShapes(true); renderer.setShapesFilled(true); // change the auto tick unit selection to integer units only... ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:de.fhffm.jad.demo.view.LineChartPanel.java
/** * Creates a sample chart.// w ww . j ava 2s. com * * @param dataset a dataset. * * @return The chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Realtime Anomaly Detection", // chart title "Time", // x axis label "Percent", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }