List of usage examples for org.jfree.chart.renderer.category BarRenderer setSeriesToolTipGenerator
@Override public void setSeriesToolTipGenerator(int series, CategoryToolTipGenerator generator)
From source file:org.matsim.counts.algorithms.graphs.CountsLoadCurveGraph.java
@Override public JFreeChart createChart(final int nbr) { String title = this.getChartTitle() + ", Iteration: " + this.iteration_; this.chart_ = ChartFactory.createBarChart(title, "Hour", "Volumes [veh/h]", this.dataset0, PlotOrientation.VERTICAL, true, // legend? true, // tooltips? false // URLs? );//from w w w . ja v a 2s .c om CategoryPlot plot = this.chart_.getCategoryPlot(); // plot.getRangeAxis().setRange(0.0, 10000.0); // do not set a fixed range for the single link graphs plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); // BarRenderer renderer=(BarRenderer) plot.getRenderer(); BarRenderer renderer = new BarRenderer(); renderer.setSeriesOutlinePaint(0, Color.black); renderer.setSeriesOutlinePaint(1, Color.black); renderer.setSeriesPaint(0, Color.getHSBColor((float) 0.62, (float) 0.56, (float) 0.93)); // Color.orange gives a dirty yellow! renderer.setSeriesPaint(1, Color.getHSBColor((float) 0.1, (float) 0.79, (float) 0.89)); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); renderer.setItemMargin(0.0); // configure plot with light colors instead of the default 3D renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); this.chart_.setBackgroundPaint(Color.getHSBColor((float) 0.0, (float) 0.0, (float) 0.93)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setRangeGridlinesVisible(true); plot.setRenderer(0, renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); // TRRE: plot.setDataset(1, this.dataset1); plot.mapDatasetToRangeAxis(1, 1); final CategoryAxis axis1 = plot.getDomainAxis(); axis1.setCategoryMargin(0.25); // leave a gap of 25% between categories /* TRRE: final ValueAxis axis2 = new NumberAxis("Signed Rel. Error [%]"); plot.setRangeAxis(1, axis2); final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); renderer2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer2.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0)); renderer2.setSeriesPaint(0, Color.black); renderer2.setBaseStroke(new BasicStroke(2.5f)); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); */ return this.chart_; }
From source file:org.matsim.counts.algorithms.graphs.CountsGEHCurveGraph.java
@Override public JFreeChart createChart(final int nbr) { String title = this.getChartTitle() + ", Iteration: " + this.iteration_; this.chart_ = ChartFactory.createBarChart(title, "Hour", "GEH", this.dataset, PlotOrientation.VERTICAL, false, // legend? false, // tooltips? false // URLs? );//from www. j a v a 2 s.c om CategoryPlot plot = this.chart_.getCategoryPlot(); // plot.getRangeAxis().setRange(0.0, 10000.0); // do not set a fixed range for the single link graphs plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); // BarRenderer renderer=(BarRenderer) plot.getRenderer(); // BarRenderer renderer = new BarRenderer(); /* * Chooses the color adaptive based on the value to be shown by a bar. * Values <= 5.0 are green, values >= 10 are red. In between the color is interpolated. */ BarRenderer renderer = new BarRenderer() { @Override public Paint getItemPaint(final int row, final int column) { double value = dataset.getValue(row, column).doubleValue(); if (value <= 5.0) return Color.green; else if (value >= 10) return Color.red; else { if (value < 7.5) { int mixed = mix(Color.yellow.getRGB(), Color.green.getRGB(), (7.5 - value) / 2.5); return new Color(mixed); } else { int mixed = mix(Color.red.getRGB(), Color.yellow.getRGB(), (10.0 - value) / 2.5); return new Color(mixed); } } // if (value <= 5.0) return Color.green; // else if (value >= 10) return Color.red; // else { // int mixed = mix(Color.red.getRGB(), Color.green.getRGB(), (10.0 - value) / 5.0); // return new Color(mixed); // } } }; renderer.setSeriesOutlinePaint(0, Color.black); renderer.setSeriesPaint(0, Color.getHSBColor((float) 0.62, (float) 0.56, (float) 0.93)); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer.setItemMargin(0.0); // configure plot with light colors instead of the default 3D renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); this.chart_.setBackgroundPaint(Color.getHSBColor((float) 0.0, (float) 0.0, (float) 0.93)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setRangeGridlinesVisible(true); plot.setRenderer(0, renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.mapDatasetToRangeAxis(1, 1); final CategoryAxis axis1 = plot.getDomainAxis(); axis1.setCategoryMargin(0.25); // leave a gap of 25% between categories return this.chart_; }