List of usage examples for org.jfree.chart.plot XYPlot getRangeAxis
public ValueAxis getRangeAxis()
From source file:com.okmich.twitanalysis.gui.ApplicationFrame.java
/** * Creates a sample chart.//from w w w. j av a2 s . c om * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createTimeSeriesChart("Twitter Sentiments Analysis", "Time", "Sentiment score", dataset, true, true, false); final XYPlot plot = result.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60000.0); // 60 seconds axis = plot.getRangeAxis(); axis.setRange(0.0, 50.0); return result; }
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 av a 2s . c om*/ return chart; }
From source file:grafix.telas.MolduraAreaDados.java
private Point2D converterPontoNaMolduraParaPlot_EixoLinear(final Point2D pontoMoldura) { XYPlot plot = getPlot(); ValueAxis vAxis = plot.getRangeAxis(); ValueAxis dAxis = plot.getDomainAxis(); double fracaoX = pontoMoldura.getX() / this.getWidth(); double fracaoY = 1 - (pontoMoldura.getY() / this.getHeight()); double dX = dAxis.getUpperBound() - dAxis.getLowerBound(); double dY = vAxis.getUpperBound() - vAxis.getLowerBound(); return new Point2D.Double(dAxis.getLowerBound() + dX * fracaoX, vAxis.getLowerBound() + dY * fracaoY); }
From source file:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java
private JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createTimeSeriesChart(TITLE, "mm:ss", "Value", dataset, true, true, false);/*w w w . j ava2 s . c o m*/ final XYPlot plot = result.getXYPlot(); plot.setBackgroundPaint(Color.white); ValueAxis domain = plot.getDomainAxis(); domain.setAutoRange(true); ValueAxis range = plot.getRangeAxis(); range.setRange(0, MINMAX); range.setAutoRangeMinimumSize(20); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); for (int i = 0; i < SERIES; i++) { renderer.setSeriesStroke(i, new BasicStroke(2.0f)); } return result; }
From source file:grafix.telas.MolduraAreaDados.java
private Point2D converterPontoNaMolduraParaPlot_EixoLog(final Point2D pontoMoldura) { XYPlot plot = getPlot(); ValueAxis vAxis = plot.getRangeAxis(); ValueAxis dAxis = plot.getDomainAxis(); double fracaoX = pontoMoldura.getX() / this.getWidth(); double fracaoYlog = 1 - (pontoMoldura.getY() / this.getHeight()); double dX = dAxis.getUpperBound() - dAxis.getLowerBound(); double dYlog = Math.log10(vAxis.getUpperBound()) - Math.log10(vAxis.getLowerBound()); double ylog = Math.log10(vAxis.getLowerBound()) + fracaoYlog * dYlog; return new Point2D.Double(dAxis.getLowerBound() + dX * fracaoX, Math.pow(10, ylog)); }
From source file:Modelos.Grafica.java
public JFreeChart crearGrafica(XYSeriesCollection dataset) { chart = ChartFactory.createXYLineChart("Sensores", "Tiempo", "Porcentaje", dataset, PlotOrientation.VERTICAL, true, // uso de leyenda false, // uso de tooltips false // uso de urls );//w w w . ja v a 2s . c om // color de fondo de la grfica chart.setBackgroundPaint(COLOR_FONDO_GRAFICA); final XYPlot plot = (XYPlot) chart.getPlot(); configurarPlot(plot); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); configurarDomainAxis(domainAxis); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); configurarRangeAxis(rangeAxis); final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); configurarRendered(renderer); return chart; }
From source file:grafix.telas.MolduraAreaDados.java
private Point2D converterPontoNoPlotParaMoldura_EixoLinear(final Point2D pontoPlot) { XYPlot plot = getPlot(); ValueAxis vAxis = plot.getRangeAxis(); ValueAxis dAxis = plot.getDomainAxis(); double dX = dAxis.getUpperBound() - dAxis.getLowerBound(); double dY = vAxis.getUpperBound() - vAxis.getLowerBound(); double proporcaoX = this.getWidth() / dX; double proporcaoY = this.getHeight() / dY; double fracaoX = pontoPlot.getX() - dAxis.getLowerBound(); double fracaoY = pontoPlot.getY() - vAxis.getLowerBound(); return new Point2D.Double(fracaoX * proporcaoX, this.getHeight() - (fracaoY * proporcaoY)); }
From source file:grafix.telas.MolduraAreaDados.java
private Point2D converterPontoNoPlotParaMoldura_EixoLog(final Point2D pontoPlot) { XYPlot plot = getPlot(); ValueAxis vAxis = plot.getRangeAxis(); ValueAxis dAxis = plot.getDomainAxis(); double dX = dAxis.getUpperBound() - dAxis.getLowerBound(); double dYlog = Math.log10(vAxis.getUpperBound()) - Math.log10(vAxis.getLowerBound()); double proporcaoX = this.getWidth() / dX; double fracaoX = pontoPlot.getX() - dAxis.getLowerBound(); double fracaoYlog = Math.log10(pontoPlot.getY()) - Math.log10(vAxis.getLowerBound()); double coefYlog = fracaoYlog / dYlog; return new Point2D.Double(fracaoX * proporcaoX, this.getHeight() - (coefYlog * this.getHeight())); }
From source file:net.sf.mzmine.chartbasics.chartthemes.ChartThemeParameters.java
public void applyToChart(JFreeChart chart) { // apply chart settings boolean showTitle = this.getParameter(ChartThemeParameters.showTitle).getValue(); boolean changeTitle = this.getParameter(ChartThemeParameters.changeTitle).getValue(); String title = this.getParameter(ChartThemeParameters.changeTitle).getEmbeddedParameter().getValue(); boolean showLegends = this.getParameter(ChartThemeParameters.showLegends).getValue(); boolean usexlabel = this.getParameter(ChartThemeParameters.xlabel).getValue(); boolean useylabel = this.getParameter(ChartThemeParameters.ylabel).getValue(); String xlabel = this.getParameter(ChartThemeParameters.xlabel).getEmbeddedParameter().getValue(); String ylabel = this.getParameter(ChartThemeParameters.ylabel).getEmbeddedParameter().getValue(); Color gbColor = this.getParameter(ChartThemeParameters.color).getValue(); chart.setBackgroundPaint(gbColor);/*from www . j a v a2s. c o m*/ chart.getPlot().setBackgroundPaint(gbColor); if (changeTitle) chart.setTitle(title); chart.getTitle().setVisible(showTitle); ((List<Title>) chart.getSubtitles()).stream().forEach(t -> t.setVisible(showLegends)); if (chart.getXYPlot() != null) { XYPlot p = chart.getXYPlot(); if (usexlabel) p.getDomainAxis().setLabel(xlabel); if (useylabel) p.getRangeAxis().setLabel(ylabel); boolean xgrid = this.getParameter(ChartThemeParameters.xGridPaint).getValue(); boolean ygrid = this.getParameter(ChartThemeParameters.yGridPaint).getValue(); Color cxgrid = this.getParameter(ChartThemeParameters.xGridPaint).getEmbeddedParameter().getValue(); Color cygrid = this.getParameter(ChartThemeParameters.yGridPaint).getEmbeddedParameter().getValue(); p.setDomainGridlinesVisible(xgrid); p.setDomainGridlinePaint(cxgrid); p.setRangeGridlinesVisible(ygrid); p.setRangeGridlinePaint(cygrid); p.getDomainAxis().setVisible(this.getParameter(ChartThemeParameters.showXAxis).getValue()); p.getRangeAxis().setVisible(this.getParameter(ChartThemeParameters.showYAxis).getValue()); } }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL,// www .j a v a 2 s . c o m // !legendPanelOn, false, // no legend true, false); // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }