List of usage examples for org.jfree.chart.axis NumberAxis setLowerMargin
public void setLowerMargin(double margin)
From source file:diet.gridr.g5k.gui.GanttChart.java
/** * Method creating the chart/*from w ww.ja va 2 s.c om*/ * * @param dataset dataset containing the data for the chart * @return a chart */ private JFreeChart createChart(XYZDataset dataset) { DateAxis xAxis = new DateAxis("Date"); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); xAxis.setDateFormatOverride(new SimpleDateFormat(durationsFormatterArray[this.visualizationDuration])); xAxis.setRange(Calendar.getInstance().getTime(), new Date(System.currentTimeMillis() + HistoryUtil.durationsTimesArray[visualizationDuration] - HistoryUtil.blockWidthsArray[visualizationDuration])); NumberAxis yAxis = new NumberAxis("Nodes"); yAxis.setAutoRangeIncludesZero(false); yAxis.setInverted(true); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); yAxis.setRange(1, numberOfNodes); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBlockRenderer renderer = new XYBlockRenderer(); LookupPaintScale paintScale = new LookupPaintScale(); for (int i = 0; i < jobsList.get(visualizationDuration).size(); i++) { // String jobId = jobsList.get(visualizationDuration).get(i).getId().substring(0,jobsList.get(visualizationDuration).get(i).getId().indexOf(".")); String jobId = jobsList.get(visualizationDuration).get(i).getParameterValue(GridJob.KEY_GRID_JOB_ID); int seed = Integer.parseInt(jobId); Random rng = new Random(seed); Color tempColor = Color.red; int red = tempColor.getRed(); int green = tempColor.getGreen(); int blue = tempColor.getBlue(); int redRNG = rng.nextInt(255); int greenRNG = rng.nextInt(255); int blueRNG = rng.nextInt(255); if (red == redRNG && green == greenRNG && blue == blueRNG) { tempColor = new Color(rng.nextInt(255), rng.nextInt(255), rng.nextInt(255)); } else { tempColor = new Color(redRNG, greenRNG, blueRNG); } if (seed == 0) tempColor = Color.red; paintScale.add(new Double(i), tempColor); } renderer.setBlockWidth(HistoryUtil.blockWidthsArray[visualizationDuration]); renderer.setBlockAnchor(RectangleAnchor.TOP_LEFT); renderer.setPaintScale(paintScale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); JFreeChart chart = new JFreeChart("Gantt Chart activity for cluster " + siteName, plot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); LoggingManager.log(Level.CONFIG, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "createChart", "Chart created"); return chart; }
From source file:org.owasp.benchmark.score.report.ScatterScores.java
private JFreeChart display(String title, int height, int width, List<Report> toolResults) { JFrame f = new JFrame(title); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries("Scores"); for (int i = 0; i < toolResults.size(); i++) { Report toolReport = toolResults.get(i); OverallResults overallResults = toolReport.getOverallResults(); series.add(overallResults.getFalsePositiveRate() * 100, overallResults.getTruePositiveRate() * 100); }//from www. j a v a 2 s .c om dataset.addSeries(series); chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset, PlotOrientation.VERTICAL, true, true, false); String fontName = "Arial"; DecimalFormat pctFormat = new DecimalFormat("0'%'"); theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme(); theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 24)); // title theme.setLargeFont(new Font(fontName, Font.PLAIN, 20)); // axis-title theme.setRegularFont(new Font(fontName, Font.PLAIN, 16)); theme.setSmallFont(new Font(fontName, Font.PLAIN, 12)); theme.setRangeGridlinePaint(Color.decode("#C0C0C0")); theme.setPlotBackgroundPaint(Color.white); theme.setChartBackgroundPaint(Color.white); theme.setGridBandPaint(Color.red); theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); theme.setBarPainter(new StandardBarPainter()); theme.setAxisLabelPaint(Color.decode("#666666")); theme.apply(chart); XYPlot xyplot = chart.getXYPlot(); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis(); xyplot.setOutlineVisible(true); rangeAxis.setRange(-5, 109.99); rangeAxis.setNumberFormatOverride(pctFormat); rangeAxis.setTickLabelPaint(Color.decode("#666666")); rangeAxis.setMinorTickCount(5); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setAxisLineVisible(true); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setTickMarksVisible(true); rangeAxis.setLowerMargin(10); rangeAxis.setUpperMargin(10); xyplot.setRangeGridlineStroke(new BasicStroke()); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setRangeMinorGridlinesVisible(true); domainAxis.setRange(-5, 105); domainAxis.setNumberFormatOverride(pctFormat); domainAxis.setTickLabelPaint(Color.decode("#666666")); domainAxis.setMinorTickCount(5); domainAxis.setTickUnit(new NumberTickUnit(10)); domainAxis.setAxisLineVisible(true); domainAxis.setTickMarksVisible(true); domainAxis.setMinorTickMarksVisible(true); domainAxis.setLowerMargin(10); domainAxis.setUpperMargin(10); xyplot.setDomainGridlineStroke(new BasicStroke()); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setDomainMinorGridlinesVisible(true); chart.setTextAntiAlias(true); chart.setAntiAlias(true); chart.removeLegend(); chart.setPadding(new RectangleInsets(20, 20, 20, 20)); xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7")); // // setup item labels // XYItemRenderer renderer = xyplot.getRenderer(); // Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 7.0f, 7.0f); // for ( int i = 0; i < dataset.getSeriesCount(); i++ ) { // renderer.setSeriesShape(i, circle); // renderer.setSeriesPaint(i, Color.blue); // String label = ""+((String)dataset.getSeries(i).getKey()); // int idx = label.indexOf( ':'); // label = label.substring( 0, idx ); // StandardXYItemLabelGenerator generator = new StandardXYItemLabelGenerator(label); // renderer.setSeriesItemLabelGenerator(i, generator); // renderer.setSeriesItemLabelsVisible(i, true); // ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER ); // renderer.setSeriesPositiveItemLabelPosition(i, position); // } makeDataLabels(toolResults, xyplot); makeLegend(toolResults, 57, 48, dataset, xyplot); Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 6, 3 }, 0); for (XYDataItem item : (List<XYDataItem>) series.getItems()) { double x = item.getX().doubleValue(); double y = item.getY().doubleValue(); double z = (x + y) / 2; XYLineAnnotation score = new XYLineAnnotation(x, y, z, z, dashed, Color.blue); xyplot.addAnnotation(score); } // // put legend inside plot // LegendTitle lt = new LegendTitle(xyplot); // lt.setItemFont(theme.getSmallFont()); // lt.setPosition(RectangleEdge.RIGHT); // lt.setItemFont(theme.getSmallFont()); // XYTitleAnnotation ta = new XYTitleAnnotation(.7, .55, lt, RectangleAnchor.TOP_LEFT); // ta.setMaxWidth(0.48); // xyplot.addAnnotation(ta); // draw guessing line XYLineAnnotation guessing = new XYLineAnnotation(-5, -5, 105, 105, dashed, Color.red); xyplot.addAnnotation(guessing); XYPointerAnnotation worse = makePointer(75, 5, "Worse than guessing", TextAnchor.TOP_CENTER, 90); xyplot.addAnnotation(worse); XYPointerAnnotation better = makePointer(25, 100, "Better than guessing", TextAnchor.BOTTOM_CENTER, 270); xyplot.addAnnotation(better); XYTextAnnotation stroketext = new XYTextAnnotation(" Random Guess", 88, 107); stroketext.setTextAnchor(TextAnchor.CENTER_RIGHT); stroketext.setBackgroundPaint(Color.white); stroketext.setPaint(Color.red); stroketext.setFont(theme.getRegularFont()); xyplot.addAnnotation(stroketext); XYLineAnnotation strokekey = new XYLineAnnotation(58, 107, 68, 107, dashed, Color.red); xyplot.setBackgroundPaint(Color.white); xyplot.addAnnotation(strokekey); ChartPanel cp = new ChartPanel(chart, height, width, 400, 400, 1200, 1200, false, false, false, false, false, false); f.add(cp); f.pack(); f.setLocationRelativeTo(null); // f.setVisible(true); return chart; }
From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java
/** * Creates a stacked XY area plot. The chart object returned by this * method uses an {@link XYPlot} instance as the plot, with a * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the * range axis, and a {@link StackedXYAreaRenderer2} as the renderer. * /* w w w . jav a 2 s.com*/ * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A stacked XY area chart. */ public static JFreeChart createStackedXYAreaChart(String title, String xAxisLabel, String yAxisLabel, TableXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(toolTipGenerator, urlGenerator); renderer.setOutline(true); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); plot.setRangeAxis(yAxis); // forces recalculation of the axis range JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void initialize() { final JFreeChart chart = chartNode.getChart(); final XYPlot plot = chart.getXYPlot(); // Do not set colors and strokes dynamically. They are instead provided // by the dataset and configured in configureRenderer() plot.setDrawingSupplier(null);// w w w . j av a2s .co m plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor)); plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor)); plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // chart properties chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); // legend properties LegendTitle legend = chart.getLegend(); // legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the X axis (m/z) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setLabel("m/z"); xAxis.setUpperMargin(0.03); xAxis.setLowerMargin(0.03); xAxis.setRangeType(RangeType.POSITIVE); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setLabel("Intensity"); yAxis.setRangeType(RangeType.POSITIVE); yAxis.setAutoRangeIncludesZero(true); // set the fixed number formats, because otherwise JFreeChart sometimes // shows exponent, sometimes it doesn't DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); xAxis.setNumberFormatOverride(mzFormat); DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); yAxis.setNumberFormatOverride(intensityFormat); chartTitle = chartNode.getChart().getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartNode.setCursor(Cursor.CROSSHAIR); // Remove the dataset if it is removed from the list datasets.addListener((Change<? extends MsSpectrumDataSet> c) -> { while (c.next()) { if (c.wasRemoved()) { for (MsSpectrumDataSet ds : c.getRemoved()) { int index = plot.indexOf(ds); plot.setDataset(index, null); } } } }); itemLabelsVisible.addListener((prop, oldVal, newVal) -> { for (MsSpectrumDataSet dataset : datasets) { int datasetIndex = plot.indexOf(dataset); XYItemRenderer renderer = plot.getRenderer(datasetIndex); renderer.setBaseItemLabelsVisible(newVal); } }); legendVisible.addListener((prop, oldVal, newVal) -> { legend.setVisible(newVal); }); }
From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java
private JFreeChart createLineChart(String title, String xLabel, String yLabel, XYDataset dataset, String other) {//from www. j a v a2 s . c o m // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); chart.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainGridlinePaint(Color.lightGray); //plot.setNoDataMessage("No data available"); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.02); rangeAxis.setLowerMargin(0.02); domainAxis.setUpperMargin(0.02); domainAxis.setLowerMargin(0.02); // customise the renderer... XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(true); renderer.setDrawOutlines(true); renderer.setBaseShapesFilled(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); if (other.toLowerCase().indexOf("noline") != -1) { renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(false); } if (other.toLowerCase().indexOf("noshape") != -1) { renderer.setBaseShapesVisible(false); renderer.setBaseLinesVisible(true); } if (other.toLowerCase().indexOf("excludeszero") != -1) { rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setAutoRangeIncludesZero(false); } return chart; }
From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java
private JFreeChart createLineChart(String title, String xLabel, String yLabel, XYDataset dataset, Color[] colors, String other) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );//from w w w . j a va 2 s . com XYPlot plot = chart.getXYPlot(); chart.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainGridlinePaint(Color.lightGray); //plot.setNoDataMessage("No data available"); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.02); rangeAxis.setLowerMargin(0.02); domainAxis.setUpperMargin(0.02); domainAxis.setLowerMargin(0.02); // customise the renderer... XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(true); renderer.setDrawOutlines(true); renderer.setBaseShapesFilled(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); for (int i = 0; i < colors.length; i++) { renderer.setSeriesPaint(i, colors[i]); } if (other.toLowerCase().indexOf("noline") != -1) { renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(false); } if (other.toLowerCase().indexOf("noshape") != -1) { renderer.setBaseShapesVisible(false); renderer.setBaseLinesVisible(true); } if (other.toLowerCase().indexOf("excludeszero") != -1) { rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setAutoRangeIncludesZero(false); } if (other.toLowerCase().indexOf("color") != -1) { renderer.setBaseShapesVisible(false); renderer.setBaseLinesVisible(true); } return chart; }
From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java
private JFreeChart createLineAndDotChart(String title, String xLabel, String yLabel, XYDataset dataset, int numberOfLines, Color[] lineColors, int numberOfDotsGroups, Color[] dotColors, String other) { boolean legend = true; if (other.toLowerCase().indexOf("noledend") != -1) { legend = false;//from w w w.ja v a 2s . c o m } // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation legend, // include legend true, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); chart.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainGridlinePaint(Color.lightGray); //plot.setNoDataMessage("No data available"); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.02); rangeAxis.setLowerMargin(0.02); domainAxis.setUpperMargin(0.02); domainAxis.setLowerMargin(0.02); // customise the renderer... XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); for (int i = 0; i < numberOfLines; i++) { renderer.setSeriesShapesVisible(i, false); renderer.setSeriesLinesVisible(i, true); } for (int i = numberOfLines; i < numberOfLines + numberOfDotsGroups; i++) { renderer.setSeriesShapesVisible(i, true); renderer.setSeriesLinesVisible(i, false); } // renderer.setDrawOutlines(true); // renderer.setBaseShapesFilled(true); // renderer.setUseFillPaint(true); // renderer.setFillPaint(Color.white); //set line color for (int i = 0; i < lineColors.length; i++) { renderer.setSeriesPaint(i, lineColors[i]); } // set dot color for (int i = 0; i < dotColors.length; i++) { renderer.setSeriesPaint(numberOfLines + i, dotColors[i]); } if (other.toLowerCase().indexOf("excludeszero") != -1) { rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setAutoRangeIncludesZero(false); } return chart; }
From source file:no.met.jtimeseries.chart.ChartPlotter.java
/** * Add normal bars in to the chart// w ww .ja v a 2s.co m * * @param dataset * The dataset to visualise * @param title * @param color * @param margin * Define the space between two bars */ public void addBarChart(XYDataset dataset, String title, Color color, double margin, double maxValue) { if (dataset.getItemCount(0) > 0) { XYBarRenderer renderer = new XYBarRenderer(margin); renderer.setSeriesPaint(0, color); renderer.setShadowVisible(false); renderer.setBaseItemLabelsVisible(false); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setSeriesVisibleInLegend(0, false); renderer.setDrawBarOutline(true); plot.mapDatasetToRangeAxis(plotIndex, rangeAxisIndex); plot.setDataset(plotIndex, dataset); plot.setRenderer(plotIndex, renderer); if (!title.equals("")) { // if title is not null then show the legend and label of the // bar NumberAxis numberAxis = new NumberAxis(title); numberAxis.setLowerMargin(LOWER_PLOT_MARGIN); double maxRange = calculateRangeMax(maxValue); numberAxis.setRangeWithMargins(new Range(0, maxRange), true, true); numberAxis.setLabelPaint(color); numberAxis.setTickLabelPaint(color); plot.setRangeAxis(rangeAxisIndex, numberAxis); } plotIndex++; rangeAxisIndex++; } }
From source file:KIDLYFactory.java
/** * Creates a stacked XY area plot. The chart object returned by this * method uses an {@link XYPlot} instance as the plot, with a * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the * range axis, and a {@link StackedXYAreaRenderer2} as the renderer. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A stacked XY area chart.//ww w.ja va 2 s. com */ public static JFreeChart createStackedXYAreaChart(String title, String xAxisLabel, String yAxisLabel, TableXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(toolTipGenerator, urlGenerator); renderer.setOutline(true); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); plot.setRangeAxis(yAxis); // forces recalculation of the axis range JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
From source file:ec.util.chart.swing.JTimeSeriesChart.java
private void growSubPlots(int size) { for (int i = 0; i < size; i++) { XYPlot plot = new XYPlot(); for (int rendererIndex = 0; rendererIndex < supportedRendererTypes.size(); rendererIndex++) { SeriesIndexResolver resolver = SeriesIndexResolver.create(plot, rendererIndex); JTimeSeriesRendererSupport support = new RendererSupport(resolver); plot.setRenderer(rendererIndex, support.createRenderer(supportedRendererTypes.get(rendererIndex))); }// w w w . j av a2 s . c o m NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setTickLabelInsets(new RectangleInsets(10, 5, 10, 2)); rangeAxis.setLowerMargin(0.02); rangeAxis.setUpperMargin(0.02); plot.setRangeAxis(rangeAxis); mainPlot.add(plot); onDatasetChange(plot); onColorSchemeSupportChange(plot); onValueFormatChange(plot); onNoDataMessageChange(plot); onElementVisibleChange(plot); onFontSupportChange(plot); } }