List of usage examples for org.jfree.chart.plot XYPlot setRangeGridlinePaint
public void setRangeGridlinePaint(Paint paint)
From source file:org.jfree.chart.demo.DifferenceChartDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Difference Chart Demo 1", "Time", "Value", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYDifferenceRenderer xydifferencerenderer = new XYDifferenceRenderer(Color.green, Color.red, false); xydifferencerenderer.setRoundXCoordinates(true); xyplot.setDomainCrosshairLockedOnData(true); xyplot.setRangeCrosshairLockedOnData(true); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); xyplot.setRenderer(xydifferencerenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); DateAxis dateaxis = new DateAxis("Time"); dateaxis.setLowerMargin(0.0D);/*from ww w. j ava 2 s. co m*/ dateaxis.setUpperMargin(0.0D); xyplot.setDomainAxis(dateaxis); xyplot.setForegroundAlpha(0.5F); return jfreechart; }
From source file:org.matsim.analysis.LegHistogramChart.java
static JFreeChart getGraphic(final LegHistogram.DataFrame dataFrame, final String mode, int iteration) { final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries departuresSerie = new XYSeries("departures", false, true); final XYSeries arrivalsSerie = new XYSeries("arrivals", false, true); final XYSeries onRouteSerie = new XYSeries("en route", false, true); int onRoute = 0; for (int i = 0; i < dataFrame.countsDep.length; i++) { onRoute = onRoute + dataFrame.countsDep[i] - dataFrame.countsArr[i] - dataFrame.countsStuck[i]; double hour = i * dataFrame.binSize / 60.0 / 60.0; departuresSerie.add(hour, dataFrame.countsDep[i]); arrivalsSerie.add(hour, dataFrame.countsArr[i]); onRouteSerie.add(hour, onRoute); }/* w w w.j a va 2 s. c o m*/ xyData.addSeries(departuresSerie); xyData.addSeries(arrivalsSerie); xyData.addSeries(onRouteSerie); final JFreeChart chart = ChartFactory.createXYStepChart("Leg Histogram, " + mode + ", it." + iteration, "time", "# persons", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setDomainGridlinePaint(Color.gray); return chart; }
From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileChartFactory.java
public static JFreeChart createDiveProfileChartPanel(DiveProfile diveProfile, Locale locale, LengthUnit lengthUnit) {//from ww w .ja va 2 s . co m XYSeries depthSerie = new XYSeries(SERIE_DEPTH); XYSeriesCollection depthCollection = new XYSeriesCollection(); depthCollection.addSeries(depthSerie); JFreeChart chart = ChartFactory.createXYAreaChart(null, getDomainLegend(locale), getRangeLegend(locale, lengthUnit), depthCollection, PlotOrientation.VERTICAL, false, true, false); XYPlot xyp = chart.getXYPlot(); Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f, UIAgent.getInstance().getColorWaterSurface(), false); xyp.setBackgroundPaint(p); xyp.setDomainGridlinePaint(UIAgent.getInstance().getColorWaterGrid()); xyp.setRangeGridlinePaint(UIAgent.getInstance().getColorWaterGrid()); ((NumberAxis) xyp.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat()); XYAreaRenderer renderer0 = new XYAreaRenderer(); renderer0.setOutline(true); renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorWaterBottom()); Color baseColor = UIAgent.getInstance().getColorBaseBackground(); renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50)); xyp.setRenderer(0, renderer0); int i = 1; XYSeriesCollection decoEntriesCollection = new XYSeriesCollection(); XYSeries decoEntriesSerie = new XYSeries(SERIE_DECO_ENTRY); decoEntriesCollection.addSeries(decoEntriesSerie); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorDecoEntries()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_ENTRY]); xyp.setDataset(i, decoEntriesCollection); xyp.setRenderer(i, renderer2); i++; XYSeriesCollection ascentTooFastCollection = new XYSeriesCollection(); XYSeries ascentTooFastSerie = new XYSeries(SERIE_WARNING_ASCENT_TOO_FAST); ascentTooFastCollection.addSeries(ascentTooFastSerie); renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningAscentTooFast()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_ASCENT_TOO_FAST_WARNING]); xyp.setDataset(i, ascentTooFastCollection); xyp.setRenderer(i, renderer2); i++; XYSeriesCollection decoWarningCollection = new XYSeriesCollection(); XYSeries decoWarningSerie = new XYSeries(SERIE_DECO_STOP); decoWarningCollection.addSeries(decoWarningSerie); renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningDecoCeiling()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_WARNING]); xyp.setDataset(i, decoWarningCollection); xyp.setRenderer(i, renderer2); i++; XYSeriesCollection remainBottomTimeCollection = new XYSeriesCollection(); XYSeries remainBottomTimeSerie = new XYSeries(SERIE_REMAINING_BOTTOM_TIME); remainBottomTimeCollection.addSeries(remainBottomTimeSerie); renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningRemainingBottomTime()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_REMAINING_BOTTOM_TIME_WARNING]); xyp.setDataset(i, remainBottomTimeCollection); xyp.setRenderer(i, renderer2); Map<Double, Double> depthEntries = diveProfile.getDepthEntries(); Set<Double> ascentWarning = diveProfile.getAscentWarnings(); Set<Double> decoWarnings = diveProfile.getDecoCeilingWarnings(); Set<Double> remainBottomTime = diveProfile.getRemainingBottomTimeWarnings(); Set<Double> decoEntryTime = diveProfile.getDecoEntries(); if (depthEntries.size() > 0 && depthEntries.get(0d) == null) { depthEntries.put(0d, 0d); } for (Double seconds : depthEntries.keySet()) { double d = UnitsAgent.getInstance().convertLengthFromModel(depthEntries.get(seconds), lengthUnit); depthSerie.add(seconds, Double.valueOf(d)); } if (null != ascentWarning) { for (Double seconds : ascentWarning) { ascentTooFastSerie.add(seconds, depthEntries.get(seconds)); } } if (null != decoWarnings) { for (Double seconds : decoWarnings) { decoWarningSerie.add(seconds, depthEntries.get(seconds)); } } if (null != remainBottomTime) { for (Double seconds : remainBottomTime) { remainBottomTimeSerie.add(seconds, depthEntries.get(seconds)); } } if (null != decoEntryTime) { for (Double seconds : decoEntryTime) { decoEntriesSerie.add(seconds, depthEntries.get(seconds)); } } return chart; }
From source file:org.gumtree.vis.awt.PlotFactory.java
public static JFreeChart createXYErrorChart(IXYErrorDataset dataset) { JFreeChart chart;//from ww w . j a v a 2 s . c o m String title = null; String xTitle = null; String yTitle = null; if (dataset != null) { title = ""; if (dataset.getTitle() != null) { title = dataset.getTitle(); } xTitle = ""; if (dataset.getXTitle() != null) { xTitle += dataset.getXTitle(); } if (dataset.getXUnits() != null) { xTitle += " (" + dataset.getXUnits() + ")"; } yTitle = ""; if (dataset.getYTitle() != null) { yTitle += dataset.getYTitle(); } if (dataset.getYUnits() != null) { yTitle += " (" + dataset.getYUnits() + ")"; } } else { dataset = new XYErrorDataset(); } chart = createXYLineChart(title, xTitle, yTitle, dataset, PlotOrientation.VERTICAL, true, false, true); chart.setBackgroundPaint(Color.WHITE); final LegendTitle legend = (LegendTitle) chart.getLegend(); RectangleEdge legendPosition = RectangleEdge.BOTTOM; try { String legendProperty = "RectangleEdge." + System.getProperty("kuranda1D.legendPosition"); if (RectangleEdge.BOTTOM.toString().equals(legendProperty)) legendPosition = RectangleEdge.BOTTOM; else if (RectangleEdge.RIGHT.toString().equals(legendProperty)) legendPosition = RectangleEdge.RIGHT; else if (RectangleEdge.LEFT.toString().equals(legendProperty)) legendPosition = RectangleEdge.LEFT; else if (RectangleEdge.TOP.toString().equals(legendProperty)) legendPosition = RectangleEdge.TOP; } catch (Exception e) { // TODO: handle exception } legend.setPosition(legendPosition); chart.setBorderVisible(true); // ChartUtilities.applyCurrentTheme(chart); // chartTheme.apply(chart); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); // plot.setRangeZeroBaselineVisible(false); // plot.setDomainZeroBaselineVisible(false); ValueAxis rangeAxis = plot.getRangeAxis(); if (rangeAxis instanceof NumberAxis) { ((NumberAxis) rangeAxis).setAutoRangeStickyZero(false); ((NumberAxis) rangeAxis).setAutoRangeIncludesZero(false); } ValueAxis domainAxis = plot.getDomainAxis(); if (domainAxis instanceof NumberAxis) { ((NumberAxis) domainAxis).setAutoRangeStickyZero(false); ((NumberAxis) domainAxis).setAutoRangeIncludesZero(false); } plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainGridlinesVisible(true); // plot.setDomainCrosshairLockedOnData(true); // plot.setDomainCrosshairVisible(true); plot.setRangeGridlinesVisible(true); // plot.setRangeCrosshairLockedOnData(true); // plot.setRangeCrosshairVisible(true); // xAxis = plot.getDomainAxis(); // yAxis = plot.getRangeAxis(); plot.setDataset(dataset); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); if (renderer instanceof XYErrorRenderer) { // ((XYLineAndShapeRenderer) renderer).setBaseShapesVisible(true); ((XYErrorRenderer) renderer).setBaseShapesFilled(true); ((XYErrorRenderer) renderer).setDrawXError(false); ((XYErrorRenderer) renderer).setDrawYError(true); } chart.fireChartChanged(); return chart; }
From source file:org.esa.beam.visat.toolviews.diag.TileCacheMonitor.java
private static TimeSeriesCollection addSubPlot(CombinedDomainXYPlot plot, String label) { final TimeSeriesCollection seriesCollection = new TimeSeriesCollection( new TimeSeries(label, Millisecond.class)); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRangeIncludesZero(false); XYPlot subplot = new XYPlot(seriesCollection, null, rangeAxis, new StandardXYItemRenderer()); subplot.setBackgroundPaint(Color.lightGray); subplot.setDomainGridlinePaint(Color.white); subplot.setRangeGridlinePaint(Color.white); plot.add(subplot);// www . ja va 2 s . c o m return seriesCollection; }
From source file:com.alibaba.dubbo.monitor.simple.SimpleMonitorService.java
private static void createChart(String key, String service, String method, String date, String[] types, Map<String, long[]> data, double[] summary, String path) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm"); DecimalFormat numberFormat = new DecimalFormat("###,##0.##"); TimeSeriesCollection xydataset = new TimeSeriesCollection(); for (int i = 0; i < types.length; i++) { String type = types[i];/*from w w w. j a va 2 s . com*/ TimeSeries timeseries = new TimeSeries(type); for (Map.Entry<String, long[]> entry : data.entrySet()) { try { timeseries.add(new Minute(dateFormat.parse(date + entry.getKey())), entry.getValue()[i]); } catch (ParseException e) { logger.error(e.getMessage(), e); } } xydataset.addSeries(timeseries); } JFreeChart jfreechart = ChartFactory.createTimeSeriesChart( "max: " + numberFormat.format(summary[0]) + (summary[1] >= 0 ? " min: " + numberFormat.format(summary[1]) : "") + " avg: " + numberFormat.format(summary[2]) + (summary[3] >= 0 ? " sum: " + numberFormat.format(summary[3]) : ""), toDisplayService(service) + " " + method + " " + toDisplayDate(date), key, xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(Color.GRAY); xyplot.setRangeGridlinePaint(Color.GRAY); xyplot.setDomainGridlinesVisible(true); xyplot.setRangeGridlinesVisible(true); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("HH:mm")); BufferedImage image = jfreechart.createBufferedImage(600, 300); try { if (logger.isInfoEnabled()) { logger.info("write chart: " + path); } File methodChartFile = new File(path); File methodChartDir = methodChartFile.getParentFile(); if (methodChartDir != null && !methodChartDir.exists()) { methodChartDir.mkdirs(); } FileOutputStream output = new FileOutputStream(methodChartFile); try { ImageIO.write(image, "png", output); output.flush(); } finally { output.close(); } } catch (IOException e) { logger.warn(e.getMessage(), e); } }
From source file:org.matsim.contrib.socnetsim.usage.analysis.CourtesyHistogramListener.java
static JFreeChart getGraphic(final CourtesyHistogram.DataFrame dataFrame, int iteration, String actType) { final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries helloSeries = new XYSeries("hello", false, true); final XYSeries goodbyeSerie = new XYSeries("goodbye", false, true); final XYSeries togetherSerie = new XYSeries("pairs together", false, true); int together = 0; for (int i = 0; i < dataFrame.countsHello.length; i++) { together = together + dataFrame.countsHello[i] - dataFrame.countsGoodbye[i]; double hour = i * dataFrame.binSize / 60.0 / 60.0; helloSeries.add(hour, dataFrame.countsHello[i]); goodbyeSerie.add(hour, dataFrame.countsGoodbye[i]); togetherSerie.add(hour, together); }/*from w ww. j a v a 2 s .c o m*/ xyData.addSeries(helloSeries); xyData.addSeries(goodbyeSerie); xyData.addSeries(togetherSerie); final JFreeChart chart = ChartFactory.createXYStepChart( "Courtesy Statistics," + "actType " + actType + " it." + iteration, "time", "# persons", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setDomainGridlinePaint(Color.gray); return chart; }
From source file:Operacional.Janela2.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("Dados Parquimetro", "Mes", true, "Dados", intervalxydataset, PlotOrientation.VERTICAL, true, false, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = jfreechart.getXYPlot(); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0")); //xyitemrenderer.setToolTipGenerator(standardxytooltipgenerator); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.white); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateaxis.setLowerMargin(0.01D);/*from w w w .ja v a 2s.c o m*/ dateaxis.setUpperMargin(0.01D); return jfreechart; }
From source file:org.gumtree.vis.awt.PlotFactory.java
public static JFreeChart createXYBlockChart(IXYZDataset dataset) { NumberAxis xAxis = createXAxis(dataset); NumberAxis yAxis = createYAxis(dataset); NumberAxis scaleAxis = createScaleAxis(dataset); float min = (float) dataset.getZMin(); float max = (float) dataset.getZMax(); PaintScale scale = generateRainbowScale(min, max, StaticValues.DEFAULT_COLOR_SCALE); XYBlockRenderer renderer = createRender(dataset, scale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); plot.setDomainPannable(true);//from ww w . ja v a 2 s . c om plot.setRangePannable(true); JFreeChart chart = new JFreeChart(dataset.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, false); // chart = new JFreeChart(dataset.getTitle(), plot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); PaintScale scaleBar = generateRainbowScale(min, max, StaticValues.DEFAULT_COLOR_SCALE); PaintScaleLegend legend = createScaleLegend(scale, scaleAxis); legend.setSubdivisionCount(ColorScale.DIVISION_COUNT); // legend.setStripOutlineVisible(true); chart.addSubtitle(legend); chart.setBorderVisible(true); // ChartUtilities.applyCurrentTheme(chart); chartTheme.apply(chart); chart.fireChartChanged(); return chart; }
From source file:eu.cassandra.training.utils.ChartUtils.java
/** * This function is used for the visualization of two Area Diagrams. * // w w w . ja va 2s. c o m * @param title * The title of the chart. * @param x * The unit on the X axis of the chart. * @param y * The unit on the Y axis of the chart. * @param doubles * The array of values of the first array. * * @return a chart panel with the graphical representation. */ public static ChartPanel createExpectedPowerChart(String title, String x, String y, double[] data) { JFreeChart chart = null; XYSeries series1 = new XYSeries("Expected Power"); for (int i = 0; i < data.length; i++) { series1.add(i, data[i]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; chart = ChartFactory.createXYLineChart(title, x, y, dataset, orientation, show, toolTips, 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); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setVerticalTickLabels(true); domainAxis.setRange(0.0, 1440.0); domainAxis.setTickUnit(new NumberTickUnit(100)); return new ChartPanel(chart); }