List of usage examples for org.jfree.chart.axis NumberAxis NumberAxis
public NumberAxis()
From source file:logica.LGraficapeso.java
public static void logicaBtnGraficar(JRadioButton jRLinea) { ChartPanel panel;//from w w w.j av a 2 s . com JFreeChart chart = null; if (jRLinea.isSelected()) { // ejecuto linea XYSplineRenderer graficoLinea = new XYSplineRenderer(); XYSeriesCollection dataset = new XYSeriesCollection(); ValueAxis x = new NumberAxis(); ValueAxis y = new NumberAxis(); XYSeries serie = new XYSeries("Datos"); XYPlot plot; graficoLinea.setSeriesPaint(0, Color.YELLOW); VGraficaPeso.getPanelLinea().removeAll(); for (int i = 0; i < VGraficaPeso.getjTable1().getRowCount(); i++) { float valor1 = Float.parseFloat(String.valueOf(VGraficaPeso.getjTable1().getValueAt(i, 0))); float valor2 = Float.parseFloat(String.valueOf(VGraficaPeso.getjTable1().getValueAt(i, 1))); System.out.println("valores " + valor1 + " " + valor2); serie.add(valor1, valor2); } dataset.addSeries(serie); x.setLabel("MES"); y.setLabel("peso"); plot = new XYPlot(dataset, x, y, graficoLinea); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(10, 15); chart = new JFreeChart(plot); chart.setTitle("grafico"); panel = new ChartPanel(chart); panel.setBounds(5, 10, 410, 350); VGraficaPeso.getPanelLinea().add(panel); VGraficaPeso.getPanelLinea().repaint(); } }
From source file:logica.LGraficaAltura.java
public static void logicaBtnGraficar(JRadioButton jRLinea) { ChartPanel panel;/*from w w w . j av a 2 s . c om*/ JFreeChart chart = null; if (jRLinea.isSelected()) { // ejecuto linea XYSplineRenderer graficoLinea = new XYSplineRenderer(); XYSeriesCollection dataset = new XYSeriesCollection(); ValueAxis x = new NumberAxis(); ValueAxis y = new NumberAxis(); XYSeries serie = new XYSeries("Datos"); XYPlot plot; graficoLinea.setSeriesPaint(0, Color.YELLOW); VGraficaAltura.getPanelLinea().removeAll(); for (int i = 0; i < VGraficaAltura.getjTable1().getRowCount(); i++) { float valor1 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 0))); float valor2 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 1))); System.out.println("valores " + valor1 + " " + valor2); serie.add(valor1, valor2); } dataset.addSeries(serie); x.setLabel("MES"); y.setLabel("ALTURA"); plot = new XYPlot(dataset, x, y, graficoLinea); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(15, 30); chart = new JFreeChart(plot); chart.setTitle("grafico"); panel = new ChartPanel(chart); panel.setBounds(5, 10, 410, 350); VGraficaAltura.getPanelLinea().add(panel); VGraficaAltura.getPanelLinea().repaint(); } }
From source file:no.met.jtimeseries.chart.ErrorPlot.java
public static XYPlot getMarinogramErrorPlot() { XYItemRenderer renderer = new StandardXYItemRenderer(); NumberAxis rangeAxis = new NumberAxis(); XYPlot plot = new XYPlot(null, null, rangeAxis, renderer); XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 0.5, 0.5); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); plot.addAnnotation(annotation);//from w ww. j a v a 2 s . c o m return plot; }
From source file:playground.thibautd.utils.charts.XYChartUtils.java
/** * Sets the X axis of an XYPlot chart to a {@link NumberAxis} * with integer values.//from w w w . jav a 2 s . c o m */ public static void integerXAxis(final JFreeChart chart) { ValueAxis axis = (chart.getXYPlot()).getDomainAxis(); NumberAxis numberAxis; if (axis instanceof NumberAxis) { numberAxis = (NumberAxis) axis; } else { numberAxis = new NumberAxis(); (chart.getXYPlot()).setDomainAxis(numberAxis); } numberAxis.setTickUnit((NumberTickUnit) NumberAxis.createIntegerTickUnits().getCeilingTickUnit(1d)); numberAxis.setAutoRangeIncludesZero(false); }
From source file:ch.zhaw.ias.dito.ui.util.BlockPlotPanel.java
public BlockPlotPanel(Matrix m, double lowerBound, double upperBound) { super(new BorderLayout()); NumberAxis xAxis = new NumberAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(1.0);/*from www. java 2 s . c o m*/ xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(1.0); yAxis.setUpperMargin(0.0); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { XYZDataset xyzDataset = (XYZDataset) dataset; double x = xyzDataset.getXValue(series, item); double y = xyzDataset.getYValue(series, item); double z = xyzDataset.getZValue(series, item); return ("X=" + x + ", Y=" + y + ", Z=" + z); } }); PaintScale scale = new ColorPaintScale(lowerBound, upperBound); renderer.setPaintScale(scale); ValueAxis axis = new NumberAxis(); axis.setLowerBound(scale.getLowerBound()); axis.setUpperBound(scale.getUpperBound()); PaintScaleLegend legend = new PaintScaleLegend(scale, axis); legend.setMargin(new RectangleInsets(10, 10, 10, 10)); legend.setPosition(RectangleEdge.RIGHT); MatrixXYDataset dataset = new MatrixXYDataset(m); plot = new XYPlot(dataset, xAxis, yAxis, renderer); chart = new JFreeChart(plot); chart.removeLegend(); chart.addSubtitle(legend); chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDisplayToolTips(true); this.add(chartPanel, BorderLayout.CENTER); }
From source file:org.xwiki.chart.internal.plot.AbstractXYPlotGenerator.java
/** * {@inheritDoc}/* w w w . j a v a2s. c o m*/ */ public Plot generate(ChartModel model, Map<String, String> parameters) { NumberAxis domainAxis = new NumberAxis(); NumberAxis rangeAxis = new NumberAxis(); XYDataset dataset = buildXYDataset(model, parameters); return new XYPlot(dataset, domainAxis, rangeAxis, getXYItemRenderer(parameters)); }
From source file:playground.thibautd.utils.charts.XYChartUtils.java
/** * Sets the X axis of an XYPlot chart to a {@link NumberAxis} * with integer values.//from w ww.j a v a2 s . c o m */ public static void integerYAxis(final JFreeChart chart) { ValueAxis axis = (chart.getXYPlot()).getRangeAxis(); NumberAxis numberAxis; if (axis instanceof NumberAxis) { numberAxis = (NumberAxis) axis; } else { numberAxis = new NumberAxis(); (chart.getXYPlot()).setRangeAxis(numberAxis); } numberAxis.setTickUnit((NumberTickUnit) NumberAxis.createIntegerTickUnits().getCeilingTickUnit(1d)); numberAxis.setAutoRangeIncludesZero(false); }
From source file:org.xwiki.chart.internal.plot.BarPlotGenerator.java
/** * {@inheritDoc}/*from ww w. ja v a 2 s.c o m*/ */ public Plot generate(ChartModel model, Map<String, String> parameters) { CategoryItemRenderer renderer = new BarRenderer(); CategoryAxis domainAxis = new CategoryAxis(); ValueAxis rangeAxis = new NumberAxis(); return new CategoryPlot(buildCategoryDataset(model, parameters), domainAxis, rangeAxis, renderer); }
From source file:xdevs.lib.util.ScopeView.java
public ScopeView(String windowsTitle, String title, String xTitle, String yTitle) { super(windowsTitle); XYSeriesCollection dataSet = new XYSeriesCollection(); serie = new XYSeries(yTitle); dataSet.addSeries(serie);//from w w w.j a va2s . co m JFreeChart chart = ChartFactory.createXYStepChart(title, xTitle, yTitle, dataSet, PlotOrientation.VERTICAL, true, false, false); chart.getXYPlot().setDomainAxis(new NumberAxis()); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); chartPanel.setMouseZoomable(true, false); setContentPane(chartPanel); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { dispose(); } }); super.pack(); RefineryUtilities.centerFrameOnScreen(this); this.setVisible(true); }
From source file:org.sonar.plugins.core.charts.DistributionAreaChart.java
@Override protected Plot getPlot(ChartParameters params) { DefaultCategoryDataset dataset = createDataset(params); CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setCategoryMargin(0.0);/*from w ww. j av a 2 s . c o m*/ domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setNumberFormatOverride(NumberFormat.getIntegerInstance(params.getLocale())); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); AreaRenderer renderer = new AreaRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); plot.setForegroundAlpha(0.5f); plot.setDomainGridlinesVisible(true); configureColors(dataset, plot, params.getValues(PARAM_COLORS, ",")); return plot; }