List of usage examples for org.jfree.chart.plot XYPlot addRangeMarker
public void addRangeMarker(Marker marker)
From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java
public static void addRangeMarker(XYPlot xyplot, String label, double value) { xyplot.addRangeMarker(addValueMarker(label, value, false)); }
From source file:com.spotify.heroic.http.render.RenderUtils.java
public static JFreeChart createChart(final List<ShardedResultGroup> groups, final String title, Map<String, String> highlight, Double threshold, int height) { final XYLineAndShapeRenderer lineAndShapeRenderer = new XYLineAndShapeRenderer(true, true); final DeviationRenderer intervalRenderer = new DeviationRenderer(); final XYSeriesCollection regularData = new XYSeriesCollection(); final YIntervalSeriesCollection intervalData = new YIntervalSeriesCollection(); int lineAndShapeCount = 0; int intervalCount = 0; for (final ShardedResultGroup resultGroup : groups) { final MetricCollection group = resultGroup.getMetrics(); if (group.getType() == MetricType.POINT) { final XYSeries series = new XYSeries(resultGroup.getMetrics().toString()); final List<Point> data = group.getDataAs(Point.class); for (final Point d : data) { series.add(d.getTimestamp(), d.getValue()); }//from w w w .jav a2 s . c om lineAndShapeRenderer.setSeriesPaint(lineAndShapeCount, Color.BLUE); lineAndShapeRenderer.setSeriesShapesVisible(lineAndShapeCount, false); lineAndShapeRenderer.setSeriesStroke(lineAndShapeCount, new BasicStroke(2.0f)); regularData.addSeries(series); ++lineAndShapeCount; } if (group.getType() == MetricType.SPREAD) { final YIntervalSeries series = new YIntervalSeries(resultGroup.getMetrics().toString()); final List<Spread> data = group.getDataAs(Spread.class); for (final Spread d : data) { series.add(d.getTimestamp(), d.getSum() / d.getCount(), d.getMin(), d.getMax()); } intervalRenderer.setSeriesPaint(intervalCount, Color.GREEN); intervalRenderer.setSeriesStroke(intervalCount, new BasicStroke(2.0f)); intervalRenderer.setSeriesFillPaint(intervalCount, new Color(200, 255, 200)); intervalRenderer.setSeriesShapesVisible(intervalCount, false); intervalData.addSeries(series); ++intervalCount; } } final JFreeChart chart = buildChart(title, regularData, intervalData, lineAndShapeRenderer, intervalRenderer); chart.setAntiAlias(true); chart.setBackgroundPaint(Color.WHITE); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); if (threshold != null) { final ValueMarker marker = new ValueMarker(threshold, Color.RED, new BasicStroke(Math.max(Math.min(height / 20, 6), 1)), Color.RED, null, 0.5f); plot.addRangeMarker(marker); } plot.setRenderer(lineAndShapeRenderer); // final DateAxis rangeAxis = (DateAxis) plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); return chart; }
From source file:org.gwaspi.reports.PlinkReportLoaderCombined.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection tempChrData, boolean showlables) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.red); renderer.setSeriesVisibleInLegend(0, showlables); renderer.setSeriesVisibleInLegend(1, showlables); //renderer.setBaseShape(new Ellipse2D.Float(0, 0, 2,2), false); if (combinedPlot.getSubplots().isEmpty()) { LogAxis rangeAxis = new LogAxis("P value"); rangeAxis.setBase(10);// w w w. j a va 2 s .c o m rangeAxis.setInverted(true); rangeAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE); rangeAxis.setTickMarkOutsideLength(2.0f); rangeAxis.setMinorTickCount(2); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setAxisLineVisible(true); rangeAxis.setAutoRangeMinimumSize(0.0000005); rangeAxis.setLowerBound(1d); //rangeAxis.setAutoRangeIncludesZero(false); combinedPlot.setRangeAxis(0, rangeAxis); } JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", tempChrData, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); final Marker thresholdLine = new ValueMarker(0.0000005); thresholdLine.setPaint(Color.red); if (showlables) { thresholdLine.setLabel("P = 510??"); } thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT); thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); subplot.addRangeMarker(thresholdLine); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(false); chrAxis.setTickLabelsVisible(false); chrAxis.setTickMarksVisible(false); chrAxis.setAutoRangeIncludesZero(false); //combinedPlot.setGap(0); combinedPlot.add(subplot, 1); }
From source file:de.xirp.chart.ChartManager.java
/** * Sets some values on the given//from www .j a v a 2s . c o m * {@link org.jfree.chart.plot.XYPlot} corresponding to some * options of the {@link de.xirp.chart.ChartOptions} * field. <br> * <br> * If <code>options.is(OptionName.SHOW_THRESHOLD)</code> is * <code>true</code> a threshold line is painted to the chart * using the <code>threshold</code> field. <br> * <br> * If <code>options.is(OptionName.USE_RELATIVE)</code> is * <code>true</code> the date axis of the plot gets a title * indicating that relative values are used. If the flag is * <code>false</code> the plot gets a title indicating that * absolute values are used. * * @param plot * The plot to alter. * @param start * The start time. * @see de.xirp.chart.ChartOptions * @see org.jfree.chart.plot.XYPlot */ private static void setXYPlot(XYPlot plot, Date start) { plot.setNoDataMessage(NO_DATA_AVAILABLE); if (options.is(OptionName.SHOW_THRESHOLD)) { Marker marker = new ValueMarker(threshold); marker.setPaint(Color.orange); marker.setAlpha(0.8f); plot.addRangeMarker(marker); } if (options.is(OptionName.USE_RELATIVE)) { DateAxis axis = new DateAxis(I18n.getString("ChartManager.text.relativeTime")); //$NON-NLS-1$ RelativeDateFormat rdf = new RelativeDateFormat(start); axis.setDateFormatOverride(rdf); plot.setDomainAxis(axis); } else { plot.setDomainAxis(new DateAxis(I18n.getString("ChartManager.text.absoluteTime"))); //$NON-NLS-1$ } }
From source file:api3.window.sound.panel.SoundPanel.java
public void plot(PanelData data, JFreeChart chart, JPanel plotPanel) { chart = ChartFactory.createXYLineChart(data.name, "prbka", "warto", data.dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); LOG.info("PLOTTING 1"); domainAxis = (NumberAxis) plot.getDomainAxis(); plot.addRangeMarker(new ValueMarker(0, Color.BLACK, new BasicStroke(1))); ChartPanel chartPanel = new ChartPanel(chart); Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createEtchedBorder()); chartPanel.setBorder(border);/*from w ww . ja v a 2s . c om*/ LOG.info("PLOTTING 2"); plotPanel.removeAll(); plotPanel.add(chartPanel); plotPanel.revalidate(); LOG.info("PLOTTING 3"); }
From source file:org.jfree.chart.demo.TimeSeriesDemo4.java
/** * A demonstration application showing a quarterly time series containing a null value. * * @param title the frame title.// w ww .j ava2 s . co m */ public TimeSeriesDemo4(final String title) { super(title); final TimeSeries series = new TimeSeries("Random Data", Hour.class); final Day today = new Day(); series.add(new Hour(1, today), 500.2); series.add(new Hour(2, today), 694.1); series.add(new Hour(3, today), 734.4); series.add(new Hour(4, today), 453.2); series.add(new Hour(7, today), 500.2); series.add(new Hour(8, today), null); series.add(new Hour(12, today), 734.4); series.add(new Hour(16, today), 453.2); final TimeSeriesCollection dataset = new TimeSeriesCollection(series); // create a title with Unicode characters (currency symbols in this case)... final String chartTitle = "\u20A2\u20A2\u20A3\u20A4\u20A5\u20A6\u20A7\u20A8\u20A9\u20AA"; final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Time", "Value", dataset, true, true, false); final XYPlot plot = chart.getXYPlot(); // plot.setInsets(new Insets(0, 0, 0, 20)); final Marker marker = new ValueMarker(700.0); marker.setPaint(Color.blue); marker.setAlpha(0.8f); plot.addRangeMarker(marker); plot.setBackgroundPaint(null); plot.setBackgroundImage(JFreeChart.INFO.getLogo()); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer r = (StandardXYItemRenderer) renderer; r.setPlotShapes(true); r.setShapesFilled(true); } final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); chartPanel.setMouseZoomable(true, false); setContentPane(chartPanel); }
From source file:org.yccheok.jstock.gui.SellPortfolioTimeChartJDialog.java
private JFreeChart createChart(String name) { final JStockOptions jStockOptions = MainFrame.getInstance().getJStockOptions(); final boolean isFeeCalculationEnabled = jStockOptions.isFeeCalculationEnabled(); final boolean isPenceToPoundConversionEnabled = jStockOptions.isPenceToPoundConversionEnabled(); final Portfolio portfolio = (Portfolio) portfolioTreeTableModel.getRoot(); final int count = portfolio.getChildCount(); final List<DataEx> dataExs = new ArrayList<DataEx>(); for (int i = 0; i < count; i++) { TransactionSummary transactionSummary = (TransactionSummary) portfolio.getChildAt(i); if (transactionSummary.getChildCount() <= 0) { continue; }//w w w . ja v a 2s . c om Transaction transaction = (Transaction) transactionSummary.getChildAt(0); final Date date = transaction.getDate().getTime(); if (name.equals(cNames[2]) || name.equals(cNames[3])) { this.isCumulativeChart = true; } else { this.isCumulativeChart = false; } /* Should use reflection technology. */ if (name.equals(cNames[0]) || name.equals(cNames[2])) { if (isPenceToPoundConversionEnabled == false) { if (isFeeCalculationEnabled) { dataExs.add(DataEx.newInstance(date, portfolioTreeTableModel.getNetGainLossValue(transactionSummary))); } else { dataExs.add(DataEx.newInstance(date, portfolioTreeTableModel.getGainLossValue(transactionSummary))); } } else { if (isFeeCalculationEnabled) { dataExs.add(DataEx.newInstance(date, portfolioTreeTableModel.getNetGainLossValue(transactionSummary) / 100.0)); } else { dataExs.add(DataEx.newInstance(date, portfolioTreeTableModel.getGainLossValue(transactionSummary) / 100.0)); } } } else if (name.equals(cNames[1]) || name.equals(cNames[3])) { if (isPenceToPoundConversionEnabled == false) { if (isFeeCalculationEnabled) { dataExs.add(DataEx.newInstance(date, -portfolioTreeTableModel.getNetGainLossValue(transactionSummary))); } else { dataExs.add(DataEx.newInstance(date, -portfolioTreeTableModel.getGainLossValue(transactionSummary))); } } else { if (isFeeCalculationEnabled) { dataExs.add(DataEx.newInstance(date, -portfolioTreeTableModel.getNetGainLossValue(transactionSummary) / 100.0)); } else { dataExs.add(DataEx.newInstance(date, -portfolioTreeTableModel.getGainLossValue(transactionSummary) / 100.0)); } } } } Collections.sort(dataExs); TimeSeries series = new TimeSeries(name); double totalValue = 0; for (DataEx dataEx : dataExs) { double value = dataEx.value; if (!this.isCumulativeChart && series.getValue(new Day(dataEx.date)) != null) { value += series.getValue(new Day(dataEx.date)).doubleValue(); } if (this.isCumulativeChart) { totalValue += value; series.addOrUpdate(new Day(dataEx.date), totalValue); } else { series.addOrUpdate(new Day(dataEx.date), value); } } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createTimeSeriesChart(name, "date", null, dataset, false, true, false); ValueMarker marker = new ValueMarker(0); marker.setPaint(Color.black); XYPlot plot = (XYPlot) chart.getXYPlot(); plot.addRangeMarker(marker); return chart; }
From source file:com.yahoo.egads.utilities.GUIUtils.java
/** * Compute the time-series of anomalies. *//* w w w. j av a 2 s . c o m*/ public void addAnomalyTS(CombinedDomainXYPlot plot, DataSequence observedSeries, DataSequence expectedSeries) { // Compute the time-series of errors. HashMap<String, ArrayList<Float>> allErrors = aes.initAnomalyErrors(observedSeries, expectedSeries); Float sDAutoSensitivity = (float) 0.0; Float amntAutoSensitivity = (float) 0.0; if (config.getProperty("AUTO_SENSITIVITY_ANOMALY_PCNT") != null) { amntAutoSensitivity = new Float(config.getProperty("AUTO_SENSITIVITY_ANOMALY_PCNT")); } if (config.getProperty("AUTO_SENSITIVITY_SD") != null) { sDAutoSensitivity = new Float(config.getProperty("AUTO_SENSITIVITY_SD")); } String errorDebug = ""; for (int i = 0; i < (aes.getIndexToError().keySet()).size(); i++) { Float[] fArray = (allErrors.get(aes.getIndexToError().get(i))) .toArray(new Float[(allErrors.get(aes.getIndexToError().get(i))).size()]); XYDataset data1 = createDataset(fArray, aes.getIndexToError().get(i)); XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis(aes.getIndexToError().get(i)); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); // Get threshold. Float d = AutoSensitivity.getLowDensitySensitivity(fArray, sDAutoSensitivity, amntAutoSensitivity); subplot1.addRangeMarker(new ValueMarker(d)); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.add(subplot1, 1); errorDebug += aes.getIndexToError().get(i) + ": " + d + " "; } System.out.println(errorDebug); }
From source file:grafix.graficos.eixos.Eixo.java
private void incluirEixoX(XYPlot plot) { if (Controle.getConfiguracoesUsuario().isExibeEixoX()) { ValueMarker mx = new ValueMarker(0); mx.setPaint(Color.BLACK); mx.setStroke(new BasicStroke(.9f)); mx.setAlpha(1.0f);/*from www . j a v a 2 s. c o m*/ plot.addRangeMarker(mx); } }
From source file:grafix.graficos.eixos.Eixo.java
protected void incluirMarcas(final XYPlot plot, final JanelaGraficos janela) { try {/*from w w w . j av a 2 s . c o m*/ Vector<MarcaGrafica> marcas = janela.getAcao().getAnalise().getMarcas(); for (MarcaGrafica m : marcas) { if (m.isRangeMarker()) { if (getNomeEixo().equals(m.getNomeEixo())) { plot.addRangeMarker(gerarRangeMarker(m)); } } else { plot.addDomainMarker(gerarIntervalMarker(m, janela)); } } incluirMarcaIntraday(plot, janela); } catch (Exception e) { AjudaGrafix.exibirMensagem(AjudaGrafix.ERRO_MARCAS); janela.getAcao().getAnalise().apagarMarcasAnalise(); } }