List of usage examples for org.jfree.chart.plot XYPlot setDomainAxis
public void setDomainAxis(ValueAxis axis)
From source file:net.sourceforge.processdash.ui.web.reports.snippets.EstErrorScatterChart.java
@Override public JFreeChart createChart() { JFreeChart chart = super.createChart(); // set minimum/maximum bounds on the two axes XYPlot xyPlot = chart.getXYPlot(); double cutoff = getPercentParam("cut", 100, 200, 5000); xyPlot.setDomainAxis(truncAxis(xyPlot.getDomainAxis(), cutoff)); xyPlot.setRangeAxis(truncAxis(xyPlot.getRangeAxis(), cutoff)); xyPlot.setRenderer(new TruncatedItemRenderer(xyPlot.getRenderer())); // add a box illustrating the target range if (data.numRows() > 0) { double box = getPercentParam("pct", 0, 50, 100); xyPlot.addAnnotation(new XYBoxAnnotation(-box, -box, box, box)); xyPlot.addAnnotation(new XYLineAnnotation(-box, 0, box, 0)); xyPlot.addAnnotation(new XYLineAnnotation(0, -box, 0, box)); }//from w w w . j ava 2 s . co m return chart; }
From source file:no.met.jtimeseries.netcdf.plot.SimplePlotProvider.java
@Override public XYPlot getPlot(List<NumberPhenomenon> dataList) { XYPlot plot = new XYPlot(); plot.setDomainAxis(getDomainAxis(dataList)); Map<String, Integer> axes = createRangeAxes(dataList, plot); for (int i = 0; i < dataList.size(); i++) { NumberPhenomenon phenomenon = dataList.get(i); //addTimeSeries(plot, phenomenon, i, colors[i % colors.length]); plot.setDataset(i, getTimeSeries(phenomenon)); plot.setRenderer(i, new XYSplineRenderer()); plot.getRenderer(i).setSeriesPaint(0, colors[i % colors.length]); plot.mapDatasetToRangeAxis(i, axes.get(phenomenon.getPhenomenonUnit())); }/*www .ja va 2s . com*/ return plot; }
From source file:org.sonar.server.charts.deprecated.SparkLinesChart.java
private void configurePlot() { XYPlot plot = (XYPlot) jfreechart.getPlot(); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setDataset(dataset);/*from ww w .j a v a2 s . c o m*/ plot.setDomainAxis(x); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(false); plot.setRangeAxis(y); plot.setRenderer(renderer); plot.setBackgroundAlpha(0.0f); }
From source file:org.jfree.chart.demo.XYAreaChartDemo2.java
/** * Creates a chart./*from w ww.j a v a 2 s . c om*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYAreaChart("XY Area Chart Demo 2", "Time", "Value", dataset, PlotOrientation.VERTICAL, true, // legend true, // tool tips false // URLs ); final XYPlot plot = chart.getXYPlot(); final ValueAxis domainAxis = new DateAxis("Time"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot.setDomainAxis(domainAxis); plot.setForegroundAlpha(0.5f); final XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("#,##0.00"))); return chart; }
From source file:org.jfree.chart.demo.XYLogAxesDemo.java
/** * Creates a new demo.//from w ww . j a va 2 s. c o m * * @param title the frame title. */ public XYLogAxesDemo(final String title) { super(title); //Object[][][] data = new Object[3][50][2]; final XYSeries s1 = new XYSeries("Series 1"); final XYSeries s2 = new XYSeries("Series 2"); final XYSeries s3 = new XYSeries("Series 3"); // for (int i = 1; i <= 50; i++) { // s1.add(i, 1000 * Math.pow(i, -2)); // s2.add(i, 1000 * Math.pow(i, -3)); // s3.add(i, 1000 * Math.pow(i, -4)); // } for (int i = 1; i <= 50; i++) { s1.add(i, 10 * Math.exp(i / 5.0)); s2.add(i, 20 * Math.exp(i / 5.0)); s3.add(i, 30 * Math.exp(i / 5.0)); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); dataset.addSeries(s3); final JFreeChart chart = ChartFactory.createXYLineChart("Log Axis Demo", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot plot = chart.getXYPlot(); final NumberAxis domainAxis = new NumberAxis("x"); final NumberAxis rangeAxis = new LogarithmicAxis("Log(y)"); plot.setDomainAxis(domainAxis); plot.setRangeAxis(rangeAxis); chart.setBackgroundPaint(Color.white); plot.setOutlinePaint(Color.black); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:playground.dgrether.analysis.charts.DgMixedModeSwitcherOnlyDeltaScoreIncomeModeChoiceChart.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]"); ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]"); plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis);/*from ww w .j a v a2 s . c om*/ DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true); renderer1.setSeriesPaint(0, colorScheme.COLOR3B); renderer1.setSeriesPaint(1, colorScheme.COLOR4B); plot.setDataset(0, this.inomeModeChoiceDs); plot.setRenderer(0, renderer1); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); plot.setDataset(1, this.avgDeltaScoreIncomeDs); for (int i = 2; i <= 3; i++) { renderer2.setSeriesStroke(i - 2, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(i - 2, new BasicStroke(3.0f)); renderer2.setSeriesPaint(i - 2, colorScheme.getColor(i + 1, "a")); } plot.setRenderer(1, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); return chart; }
From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsModeGroupChart.java
@Override public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]"); ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]"); plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis);//from w w w.j a v a2 s. c o m DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); plot.setDataset(0, this.dataset); for (int i = 0; i <= 3; i++) { renderer2.setSeriesStroke(i, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f)); renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a")); } plot.setRenderer(0, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); return chart; }
From source file:com.googlecode.logVisualizer.chart.LineChartBuilder.java
private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart(getTitle(), xLable, yLable, dataset, PlotOrientation.VERTICAL, isIncludeLegend(), true, false); final XYPlot plot = (XYPlot) chart.getPlot(); double lastXValue = 0; if (dataset.getSeriesCount() > 0) lastXValue = dataset.getXValue(0, dataset.getItemCount(0) - 1); plot.setDomainAxis(new FixedZoomNumberAxis(lastXValue)); plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setNoDataMessage("No data available"); if (dataset.getSeriesCount() > 0) ((NumberAxis) plot.getDomainAxis()).setUpperBound(lastXValue); ((NumberAxis) plot.getRangeAxis()).setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesShapesVisible(i, false); renderer.setSeriesStroke(i, new BasicStroke(2)); }// w w w . jav a 2 s . c om renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(renderer); return chart; }
From source file:playground.artemc.socialCost.MeanTravelTimeWriter.java
/** * @return a graphic showing the number of agents in the evacuated area *//*w w w . j a v a 2s . c o m*/ private JFreeChart getGraphic(String modeName, double data[]) { final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries dataSerie = new XYSeries("mean trip travel time", false, true); for (int i = 0; i < data.length; i++) { dataSerie.add(i, data[i]); } xyData.addSeries(dataSerie); // final JFreeChart chart = ChartFactory.createXYStepChart( final JFreeChart chart = ChartFactory.createXYLineChart("mean travel time, " + modeName, "iteration", "travel time", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); return chart; }
From source file:playground.artemc.socialCost.MeanTravelTimeWriter.java
/** * @return a graphic showing the number of agents in the evacuated area *///from ww w . j a v a 2 s . com private JFreeChart getGraphic(String[] modeNames, double data[][]) { final XYSeriesCollection xyData = new XYSeriesCollection(); for (int j = 0; j < modeNames.length; j++) { String modeName = modeNames[j]; double[] d = data[j]; XYSeries dataSerie = new XYSeries(modeName, false, true); for (int i = 0; i < d.length; i++) { dataSerie.add(i, d[i]); } xyData.addSeries(dataSerie); } // final JFreeChart chart = ChartFactory.createXYStepChart( final JFreeChart chart = ChartFactory.createXYLineChart("mean trip travel time, all transport modes modes", "iteration", "travel time", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); return chart; }