List of usage examples for org.jfree.chart.plot XYPlot setAxisOffset
public void setAxisOffset(RectangleInsets offset)
From source file:wattsup.jsdk.ui.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 av a 2 s . c o m return chart; }
From source file:kardex.graficakardex.java
public graficakardex() { datosxy.removeAllSeries();/* w w w . j ava 2 s. com*/ //sxy.add(x[0], y[0]); y = new double[kardex.valor.length]; y = kardex.valor; int n = y.length; for (int i = 0; i < n; i++) { sxy.add(i, y[i]); // System.out.print(x[i]+"-"+i+" "); } datosxy.addSeries(sxy); graficaxy = ChartFactory.createXYLineChart("Grafica de Stock de Producto", "transacciones", "cantidades", datosxy, PlotOrientation.VERTICAL, true, true, true); graficaxy.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) graficaxy.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); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); configurarDomainAxis(domainAxis); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } }
From source file:entrenamiento.grafica.java
public grafica() { XYSeries sxy = new XYSeries("pesos"); datosxy.removeAllSeries();//ww w . j a va2 s. co m //sxy.add(x[0], y[0]); y = new double[Entrenamiento.valor.length]; y = Entrenamiento.valor; int n = y.length; for (int i = 0; i < n; i++) { sxy.add(i, y[i]); // System.out.print(x[i]+"-"+i+" "); } datosxy.addSeries(sxy); graficaxy = ChartFactory.createXYLineChart("Grafica de Progreso", "tiempo", "RM-pesos", datosxy, PlotOrientation.VERTICAL, true, true, true); graficaxy.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) graficaxy.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); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); configurarDomainAxis(domainAxis); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } }
From source file:entrenamiento.grafica2.java
public grafica2() { XYSeries sxy = new XYSeries("pesos"); datosxy.removeAllSeries();/* www. j a v a 2s . c om*/ //sxy.add(x[0], y[0]); y = new double[Entrenamiento2.valor.length]; y = Entrenamiento2.valor; int n = y.length; for (int i = 0; i < n; i++) { sxy.add(i, y[i]); // System.out.print(x[i]+"-"+i+" "); } datosxy.addSeries(sxy); graficaxy = ChartFactory.createXYLineChart("Grafica de Progreso", "tiempo", "RM-pesos", datosxy, PlotOrientation.VERTICAL, true, true, true); graficaxy.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) graficaxy.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); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); configurarDomainAxis(domainAxis); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } }
From source file:CargarEntrenamiento.grafica2.java
public grafica2() { datosxy.removeAllSeries();// ww w.j av a 2 s . co m XYSeries sxy = new XYSeries("pesos"); //sxy.add(x[0], y[0]); y = new double[cargarEntreno.valorentreno.length]; y = cargarEntreno.valorentreno; int n = y.length; for (int i = 0; i < n; i++) { sxy.add(i, y[i]); // System.out.print(x[i]+"-"+i+" "); } datosxy.addSeries(sxy); graficaxy = ChartFactory.createXYLineChart("Grafica de Progreso", "tiempo", "RM-pesos", datosxy, PlotOrientation.VERTICAL, true, true, true); graficaxy.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) graficaxy.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); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); configurarDomainAxis(domainAxis); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } }
From source file:atencionurgencia.evolucion.grafic_sVitales.java
private void graficar() { final TimeSeriesCollection dataset1 = axisTaFC.createDatasetTA(); final JFreeChart chart2 = ChartFactory.createTimeSeriesChart("", // chart title "HORA", // domain axis label "Tensin Arterial - TA (ppm)", // range axis label dataset1, // data true, // include legend true, // tooltips? false // URL generator? Not required... );// w ww. j a va2s . c om chart2.setBackgroundPaint(Color.white); final XYPlot plot = chart2.getXYPlot(); plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF)); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); 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); } // plot.set // //// final CategoryDataset dataset2 = axisTaFC.createDatasetFC(); //// plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 0); // // final DateAxis domainAxis = (DateAxis) plot.getDomainAxis(); // domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); //// final ValueAxis axis2 = new NumberAxis("Frecuencia Cardiaca - FC (ppm)"); //// plot.setRangeAxis(1, axis2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); // // // final ChartPanel chartPanel = new ChartPanel(chart2); chartPanel.setPreferredSize(new java.awt.Dimension(444, 358));//[598, 358][444, 358] jPanel4.removeAll(); jPanel4.setLayout(new BorderLayout()); jPanel4.add(chartPanel, BorderLayout.NORTH); jPanel4.repaint(); }
From source file:br.usp.icmc.gazetteer.SemanticSearchTest.Grafico.java
public ChartPanel criaGrafico() { // create the chart... JFreeChart graf = ChartFactory.createXYLineChart("MAP ENTRE AS QUERYS", // chart title "QUERY", // x axis label "MAP", // y axis label createDataset1(), // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );//from www . j av a2 s. c o m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... graf.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) graf.getPlot(); plot.setDataset(1, createDataset2()); 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.setShapesVisible(false); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); plot.setRenderer(1, renderer2); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. ChartPanel myChartPanel = new ChartPanel(graf, true); return myChartPanel; }
From source file:com.rapidminer.gui.plotter.charts.MultipleSeriesChartPlotter.java
private JFreeChart createChart() { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title null, // x axis label null, // y axis label null, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls );//from w w w .j av a2 s . c om chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customization... 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); // domain axis if ((indexAxis >= 0) && (!dataTable.isNominal(indexAxis))) { if ((dataTable.isDate(indexAxis)) || (dataTable.isDateTime(indexAxis))) { DateAxis domainAxis = new DateAxis(dataTable.getColumnName(indexAxis)); domainAxis.setTimeZone(Tools.getPreferredTimeZone()); chart.getXYPlot().setDomainAxis(domainAxis); } } else { plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US)); ((NumberAxis) plot.getDomainAxis()).setAutoRangeStickyZero(false); ((NumberAxis) plot.getDomainAxis()).setAutoRangeIncludesZero(false); } ValueAxis xAxis = plot.getDomainAxis(); if (indexAxis > -1) { xAxis.setLabel(getDataTable().getColumnName(indexAxis)); } else { xAxis.setLabel(SERIESINDEX_LABEL); } xAxis.setAutoRange(true); xAxis.setLabelFont(LABEL_FONT_BOLD); xAxis.setTickLabelFont(LABEL_FONT); xAxis.setVerticalTickLabels(isLabelRotating()); if (indexAxis > 0) { if (getRangeForDimension(indexAxis) != null) { xAxis.setRange(getRangeForDimension(indexAxis)); } } else { if (getRangeForName(SERIESINDEX_LABEL) != null) { xAxis.setRange(getRangeForName(SERIESINDEX_LABEL)); } } // renderer and range axis synchronized (dataTable) { int numberOfSelectedColumns = 0; for (int c = 0; c < dataTable.getNumberOfColumns(); c++) { if (getPlotColumn(c)) { if (dataTable.isNumerical(c)) { numberOfSelectedColumns++; } } } int columnCount = 0; for (int c = 0; c < dataTable.getNumberOfColumns(); c++) { if (getPlotColumn(c)) { if (dataTable.isNumerical(c)) { // YIntervalSeries series = new // YIntervalSeries(this.dataTable.getColumnName(c)); XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries(dataTable.getColumnName(c)); Iterator<DataTableRow> i = dataTable.iterator(); int index = 1; while (i.hasNext()) { DataTableRow row = i.next(); double value = row.getValue(c); if ((indexAxis >= 0) && (!dataTable.isNominal(indexAxis))) { double indexValue = row.getValue(indexAxis); series.add(indexValue, value); } else { series.add(index++, value); } } dataset.addSeries(series); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); Color color = getColorProvider().getPointColor(1.0d); if (numberOfSelectedColumns > 1) { color = getColorProvider() .getPointColor(columnCount / (double) (numberOfSelectedColumns - 1)); } renderer.setSeriesPaint(0, color); renderer.setSeriesStroke(0, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setSeriesShapesVisible(0, false); NumberAxis yAxis = new NumberAxis(dataTable.getColumnName(c)); if (getRangeForDimension(c) != null) { yAxis.setRange(getRangeForDimension(c)); } else { yAxis.setAutoRange(true); yAxis.setAutoRangeStickyZero(false); yAxis.setAutoRangeIncludesZero(false); } yAxis.setLabelFont(LABEL_FONT_BOLD); yAxis.setTickLabelFont(LABEL_FONT); if (numberOfSelectedColumns > 1) { yAxis.setAxisLinePaint(color); yAxis.setTickMarkPaint(color); yAxis.setLabelPaint(color); yAxis.setTickLabelPaint(color); } plot.setRangeAxis(columnCount, yAxis); plot.setRangeAxisLocation(columnCount, AxisLocation.TOP_OR_LEFT); plot.setDataset(columnCount, dataset); plot.setRenderer(columnCount, renderer); plot.mapDatasetToRangeAxis(columnCount, columnCount); columnCount++; } } } } chart.setBackgroundPaint(Color.white); return chart; }
From source file:CargarEntrenamiento.grafica2.java
public void grafica1() { s1.add(new Month(2, 2001), 181.8); //s1.add(new Week(1, 1), null); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeries s3 = new TimeSeries("andres2255"); s3.add(new Month(2, 2001), 129.6); s3.add(new Month(10, 2001), 106.1); s3.add(new Month(1, 2002), 111.7); s3.add(new Month(2, 2002), 111.0); datos.addSeries(s1);//from w w w . ja v a 2s . c o m datos.addSeries(s2); datos.addSeries(s3); grafica = ChartFactory.createTimeSeriesChart("titulo", "etiquetas X", "etiquetaY", datos, true, true, false); /// grafica.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) grafica.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("MMM-yyyy")); }
From source file:CargarEntrenamiento.grafica2.java
public void iejmplo() { s1.add(new Month(2, 2001), 181.8); //s1.add(new Week(1, 1), null); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeries s3 = new TimeSeries("andres2255"); s3.add(new Month(2, 2001), 129.6); s3.add(new Month(10, 2001), 106.1); s3.add(new Month(1, 2002), 111.7); s3.add(new Month(2, 2002), 111.0); datos.addSeries(s1);//from w w w . j av a 2s. c o m datos.addSeries(s2); datos.addSeries(s3); grafica = ChartFactory.createTimeSeriesChart("titulo", "etiquetas X", "etiquetaY", datos, true, true, false); /// grafica.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) grafica.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("MMM-yyyy")); }