List of usage examples for org.jfree.chart.plot XYPlot setAxisOffset
public void setAxisOffset(RectangleInsets offset)
From source file:gui.grafica.estadisticas.PanelGrafica.java
/** * Crea un objeto JFreechart con el titulo pasado por parametro con * leyenda en el eje X siendo el tiempo y la leyenda de eje Y la velocidad. * La grafica creada es vaca./*from www . ja v a 2 s. c o m*/ * * @param title. Titulo de la grafica. * * @return A chart. */ private JFreeChart createChart() { JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title LEYENDA_X, // x-axis label LEYENDA_Y, // 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.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); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("h:mm")); chartSet = chart; return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperIndexChart.java
/** * Creates a chart./*from w ww . j a 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.HORIZONTAL, !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.mwc.cmap.grideditor.chart.ChartBuilder.java
public JFreeChart buildChart() { final ValueAxis xAxis = myManager.createXAxis(); final ValueAxis yAxis = myManager.createYAxis(); final XYDataset data = myManager.getXYDataSet(); final XYLineAndShapeRenderer renderer = new ColorRenderer(); final XYPlot xyplot = new XYPlot(data, xAxis, yAxis, renderer); xyplot.setOrientation(PlotOrientation.HORIZONTAL); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); final JFreeChart result = new JFreeChart(myManager.getChartTitle(), JFreeChart.DEFAULT_TITLE_FONT, xyplot, false);/*from w ww.ja va2s . c o m*/ ChartUtilities.applyCurrentTheme(result); return result; }
From source file:org.n52.oxf.render.sos.TimeSeriesChartRenderer.java
/** * // www .j a va2s .c om * @param dataset * @param width * @param height * @return */ private JFreeChart drawChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title "Date", // x-axis label phenomenon, // 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(2.0, 2.0, 2.0, 2.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat()); return chart; }
From source file:com.view.TimeSeriesChartView.java
public JFreeChart getVendorTimeSeriesChart(Excel theExcel, String vendor) { int vendorCode = Integer.parseInt(vendor); ArrayList<Receiving> theReceiving = theExcel.getSheetReceiving(); // HashMap<Month, Integer> item1Map = new HashMap<>(); // HashMap<Month, Integer> item2Map = new HashMap<>(); // HashMap<Month, Integer> item3Map = new HashMap<>(); Set vendorItem = new HashSet(); for (int i = 0; i < theReceiving.size(); i++) { vendorItem.add(theReceiving.get(i).getItem()); }/*from ww w . jav a 2 s. co m*/ TimeSeries data[] = new TimeSeries[vendorItem.size()]; HashMap<Month, Integer> itemMap[] = new HashMap[vendorItem.size()]; for (int i = 0; i < vendorItem.size(); i++) { String itemName = "item" + i; data[i] = new TimeSeries(itemName); itemMap[i] = new HashMap<>(); } Calendar cal = Calendar.getInstance(); for (int i = 0; i < theReceiving.size(); i++) { cal.setTime(theReceiving.get(i).getDate()); int month = cal.get(Calendar.MONTH) + 1; int year = cal.get(Calendar.YEAR); int quantity = 0; if (theReceiving.get(i).getVendor() == vendorCode) { quantity = theReceiving.get(i).getQuantity(); Month theMonth = new Month(month, year); int itemNum = theReceiving.get(i).getItem() - 1; itemMap[itemNum].put(theMonth, updateItemMap(itemMap[itemNum], theMonth, quantity)); } } TimeSeriesCollection my_data_series = new TimeSeriesCollection(); for (int i = 0; i < vendorItem.size(); i++) { for (Map.Entry<Month, Integer> entry : itemMap[i].entrySet()) { data[i].add(entry.getKey(), entry.getValue()); } my_data_series.addSeries(data[i]); } JFreeChart chart = ChartFactory.createTimeSeriesChart("Receiving", "Month", "Quantity", my_data_series, true, true, false); chart.setBackgroundPaint(Color.YELLOW); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.GREEN); plot.setRangeGridlinePaint(Color.orange); plot.setAxisOffset(new RectangleInsets(50, 0, 20, 5)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MM.yyyy")); return chart; }
From source file:com.rapidminer.gui.viewer.ROCChartPlotter.java
private JFreeChart createChart(XYDataset dataset) { // create the chart... 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 );/* w ww .j a v a 2s . c o m*/ chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); ValueAxis valueAxis = plot.getRangeAxis(); valueAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD); valueAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD); domainAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT); DeviationRenderer renderer = new DeviationRenderer(true, false); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); if (dataset.getSeriesCount() == 1) { renderer.setSeriesStroke(0, stroke); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesFillPaint(0, Color.RED); } else if (dataset.getSeriesCount() == 2) { renderer.setSeriesStroke(0, stroke); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesFillPaint(0, Color.RED); renderer.setSeriesStroke(1, stroke); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesFillPaint(1, Color.BLUE); } else { for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, stroke); Color color = colorProvider.getPointColor((double) i / (double) (dataset.getSeriesCount() - 1)); renderer.setSeriesPaint(i, color); renderer.setSeriesFillPaint(i, color); } } renderer.setAlpha(0.12f); plot.setRenderer(renderer); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(PlotterAdapter.LABEL_FONT); } return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.CrosshairDemo3.java
protected JFreeChart createChart(XYDataset dataset) { JFreeChart c = ChartFactory.createTimeSeriesChart(chartTitle, // "Legal & General Unit Trust Prices", domainLabel, rangeLabel, // "Date", "Price Per Unit", dataset, !legendPanelOn, true, false); c.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) c.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); XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer rr = (XYLineAndShapeRenderer) renderer; rr.setBaseShapesVisible(true);/* ww w.java 2s . c o m*/ rr.setBaseShapesFilled(true); } renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); //setXSummary(dataset) X is time; return c; }
From source file:org.infoglue.deliver.util.charts.TimeSeriesDiagram.java
/** * Creates a chart./*from ww w . j ava 2 s .com*/ * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart(header, axisXHeader, axisYHeader, dataset, true, true, false); chart.setBackgroundPaint(Color.white); LegendTitle legend = chart.getLegend(); //legend.set .setDisplaySeriesShapes(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; //rr.setPlotShapes(true); rr.setShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); if (this.timeGranulariry.equalsIgnoreCase("Week")) { DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat(this.dateFormat)); axis.setTickUnit(unit); axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat)); } else { axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat)); } /* DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat)); */ return chart; }
From source file:org.rioproject.examples.hospital.ui.PatientStatsPanel.java
private JFreeChart createTimeSeriesChart(TimeSeriesCollection dataSet, Color color) { JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", dataSet, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.getRenderer().setSeriesPaint(0, color); 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); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setRange(0, 150);/*from w w w . j a v a 2s . c o m*/ ValueAxis xAxis = plot.getDomainAxis(); xAxis.setAutoRange(true); xAxis.setFixedAutoRange(5 * MINUTE); return 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);//from ww w.j av a 2 s.co m return chart; }