List of usage examples for org.jfree.chart JFreeChart getXYPlot
public XYPlot getXYPlot()
From source file:chart.statistic.HistogramChart.java
public JFreeChart createChart() { JFreeChart chart = ChartFactory.createHistogram(mr.getLabel(), null, null, dataset, PlotOrientation.VERTICAL, false, // legende false, false);// www. ja v a 2s . c om chart.getXYPlot().setForegroundAlpha(0.75f); return chart; }
From source file:org.jfree.chart.demo.MultipleAxisDemo2.java
/** * Creates the demo chart.//from w w w . j a va 2 s .c o m * * @return The chart. */ private JFreeChart createChart() { final XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 2", "Time of Day", "Primary Range Axis", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPaint(Color.black); // DOMAIN AXIS 2 final NumberAxis xAxis2 = new NumberAxis("Domain Axis 2"); xAxis2.setAutoRangeIncludesZero(false); plot.setDomainAxis(1, xAxis2); // RANGE AXIS 2 final NumberAxis yAxis2 = new NumberAxis("Range Axis 2"); plot.setRangeAxis(1, yAxis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); final XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToDomainAxis(1, 1); plot.mapDatasetToRangeAxis(1, 1); return chart; }
From source file:net.sf.jasperreports.customizers.shape.LineDotShapeCustomizer.java
@Override public void customize(JFreeChart jfc, JRChart jrc) { Plot plot = jfc.getPlot();//from w w w.j a v a2s .c o m ItemsCounter itemsCounter = null; SeriesNameProvider seriesNameProvider = null; Object renderer = null; if (plot instanceof XYPlot) { XYPlot xyPlot = jfc.getXYPlot(); renderer = xyPlot.getRenderer(); itemsCounter = new XYPlotSeriesCounter(xyPlot); seriesNameProvider = new XYPlotSeriesNameProvider(xyPlot); } else if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = jfc.getCategoryPlot(); renderer = categoryPlot.getRenderer(); itemsCounter = new CategoryCounter(categoryPlot); seriesNameProvider = new CategorySeriesNameProvider(categoryPlot); } Integer seriesItemIndex = CustomizerUtil.resolveIndex(this, itemsCounter, seriesNameProvider); if (seriesItemIndex != null && renderer instanceof AbstractRenderer) { ShapeSetter shapeSetter = new AbstractRendererSeriesShapeSetter((AbstractRenderer) renderer); if (seriesItemIndex == -1) { updateItems(itemsCounter, shapeSetter); } else { updateItem(itemsCounter, shapeSetter, seriesItemIndex); } } }
From source file:net.footballpredictions.footballstats.swing.LeaguePositionGraph.java
/** * Plot league positions by date.// w w w . ja v a 2 s. c om */ public void updateGraph(Object[] teams, LeagueSeason data) { assert teams.length > 0 : "Must be at least one team selected."; TimeSeriesCollection dataSet = new TimeSeriesCollection(); for (Object team : teams) { String teamName = (String) team; TimeSeries positionSeries = new TimeSeries(teamName); SortedMap<Date, Integer> positions = data.getTeam(teamName).getLeaguePositions(); for (Map.Entry<Date, Integer> entry : positions.entrySet()) { positionSeries.add(new Day(entry.getKey()), entry.getValue()); } dataSet.addSeries(positionSeries); } JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // Title messageResources.getString("graphs.date"), messageResources.getString("combo.GraphType.LEAGUE_POSITION"), dataSet, true, // Legend. false, // Tooltips. false); // URLs. chart.getXYPlot().getRangeAxis().setInverted(true); chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chart.getXYPlot().getRangeAxis().setRangeWithMargins(1, data.getTeamNames().size()); chart.getLegend().setPosition(legendPosition); setChart(chart); }
From source file:greenapi.ui.charts.LineChartPanelSupport.java
@Override public JFreeChart createChart() { this.timeSeries = new TimeSeriesCollection(); this.dataset = new TranslatingXYDataset(this.timeSeries); JFreeChart chart = ChartFactory.createTimeSeriesChart(this.getTitle(), null, this.getAxisLabel(), this.dataset, true, true, false); chart.setBackgroundPaint(getBackground()); XYPlot xyPlot = chart.getXYPlot(); xyPlot.setOrientation(PlotOrientation.VERTICAL); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.BLACK.darker()); xyPlot.setRangeGridlinePaint(Color.BLACK.darker()); xyPlot.setAxisOffset(new RectangleInsets(5.0D, 5.0D, 5.0D, 5.0D)); xyPlot.setDomainCrosshairLockedOnData(true); xyPlot.setRangeCrosshairVisible(true); chart.setAntiAlias(true);// w ww.j a v a 2 s .c o m return chart; }
From source file:cv.mikusher.freechart.XYLineChart.java
public XYLineChart(String applicationTitle, String chartTitle) { super(applicationTitle); setDefaultCloseOperation(ApplicationFrame.EXIT_ON_CLOSE); JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", createDataset(), PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(xylineChart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); final XYPlot plot = xylineChart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.YELLOW); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); plot.setRenderer(renderer);//from w ww . jav a 2 s .c o m setContentPane(chartPanel); }
From source file:serverrobot.DynamicGraph.java
public JFreeChart createChart(XYDataset dataset, String pos, double minRange, double maxRange) { final JFreeChart chart = ChartFactory.createTimeSeriesChart(pos, "Time (ms)", "Displacement", dataset, true, true, false);/*w w w.j a va2 s. c o m*/ final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(new Color(232, 232, 232)); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); plot.getRenderer().setSeriesPaint(0, Color.BLUE); plot.getRenderer().setSeriesPaint(1, Color.RED); ValueAxis axis = plot.getDomainAxis(); //axis.setAutoRange(true); axis.setFixedAutoRange(20000.0); // 60 seconds axis = plot.getRangeAxis(); axis.setRange(minRange, maxRange); chart.setBackgroundPaint(Color.white); return chart; }
From source file:com.compomics.cell_coord.gui.controller.summary.VisualizeTracksController.java
/** * Scale the axes to the experiment coordinates ranges. * * @param chart//from w w w .j a v a 2 s . co m */ private void scaleAxes(JFreeChart chart, boolean useRawData) { XYPlot xYPlot = chart.getXYPlot(); Double[][] coordinatesRanges; if (useRawData) { coordinatesRanges = coordRanges; } else { coordinatesRanges = shiftedCoordRange; } Double[] xCoords = coordinatesRanges[0]; Double[] yCoords = coordinatesRanges[1]; xYPlot.getDomainAxis().setRange(new Range(yCoords[0], yCoords[1])); xYPlot.getRangeAxis().setRange(new Range(xCoords[0], xCoords[1])); }
From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java
private XYPlot createPlotArea(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); showCrosshairsOnAxes(plot);/*from ww w. j a v a 2 s . c o m*/ configureDomainAxis(plot); showGridlinesOnChart(plot); configureTimeAxis(plot); configureTitle(chart); addNotice(chart); return plot; }
From source file:org.jfree.chart.demo.DifferenceChartDemo.java
/** * Creates a chart./*from w ww . j a v a2s. c om*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Difference Chart Demo", "Time", "Value", dataset, true, // legend true, // tool tips false // URLs ); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setRenderer(new XYDifferenceRenderer(Color.green, Color.red, false)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); final ValueAxis domainAxis = new DateAxis("Time"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot.setDomainAxis(domainAxis); plot.setForegroundAlpha(0.5f); return chart; }