Java Code Examples for org.jfree.chart.renderer.xy.XYLineAndShapeRenderer#setBaseToolTipGenerator()
The following examples show how to use
org.jfree.chart.renderer.xy.XYLineAndShapeRenderer#setBaseToolTipGenerator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartFactory.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates and returns a time series chart. A time series chart is an * {@link XYPlot} with a {@link DateAxis} for the x-axis and a * {@link NumberAxis} for the y-axis. The default renderer is an * {@link XYLineAndShapeRenderer}. A convenient dataset to use with this * chart is a {@link TimeSeriesCollection}. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A time series chart. */ public static JFreeChart createTimeSeriesChart(String title, String timeAxisLabel, String valueAxisLabel, XYDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); // override default XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); XYToolTipGenerator toolTipGenerator = null; toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(toolTipGenerator); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example 2
Source File: ScatterPlotChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected JFreeChart computeXYChart( final XYDataset xyDataset ) { final JFreeChart chart; if ( xyDataset instanceof TimeSeriesCollection ) { chart = ChartFactory.createTimeSeriesChart( computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, isShowLegend(), false, false ); final XYPlot xyPlot = chart.getXYPlot(); final XYLineAndShapeRenderer itemRenderer = (XYLineAndShapeRenderer) xyPlot.getRenderer(); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer( false, true ); renderer.setBaseToolTipGenerator( itemRenderer.getBaseToolTipGenerator() ); renderer.setURLGenerator( itemRenderer.getURLGenerator() ); xyPlot.setRenderer( renderer ); } else { final PlotOrientation orientation = computePlotOrientation(); chart = ChartFactory.createScatterPlot( computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, orientation, isShowLegend(), false, false ); } chart.getXYPlot().setRenderer( new XYDotRenderer() ); configureLogarithmicAxis( chart.getXYPlot() ); return chart; }
Example 3
Source File: ChartRendererFactory.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
private static void configureXYLineAndShapeRenderer(XYLineAndShapeRenderer renderer, ValueSource valueSource, PlotInstance plotInstance) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); SeriesFormat seriesFormat = valueSource.getSeriesFormat(); DimensionConfig domainConfig = valueSource.getDomainConfig(); DimensionConfig colorDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig( PlotDimension.COLOR); DimensionConfig shapeDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig( PlotDimension.SHAPE); ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource); int seriesCount = valueSourceData.getSeriesDataForAllGroupCells().groupCellCount(); // Loop all series and set series format. // Format based on dimension configs will be set later on in initFormatDelegate(). for (int seriesIdx = 0; seriesIdx < seriesCount; ++seriesIdx) { // configure linestyle if (seriesFormat.getLineStyle() == LineStyle.NONE) { renderer.setSeriesLinesVisible(seriesIdx, false); } else { renderer.setSeriesLinesVisible(seriesIdx, true); renderer.setSeriesStroke(seriesIdx, seriesFormat.getStroke(), false); } // configure series shape if necessary if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, shapeDimensionConfig)) { if (seriesFormat.getItemShape() != ItemShape.NONE) { renderer.setSeriesShapesVisible(seriesIdx, true); renderer.setSeriesShape(seriesIdx, seriesFormat.getItemShape().getShape()); } else { renderer.setSeriesShapesVisible(seriesIdx, false); } } // configure series color if necessary if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, colorDimensionConfig)) { Color itemColor = seriesFormat.getItemColor(); renderer.setSeriesPaint(seriesIdx, itemColor); renderer.setSeriesFillPaint(seriesIdx, itemColor); } renderer.setSeriesOutlinePaint(seriesIdx, PlotConfiguration.DEFAULT_SERIES_OUTLINE_PAINT); renderer.setUseOutlinePaint(true); } }
Example 4
Source File: ChromatogramPlotWindowController.java From old-mzmine3 with GNU General Public License v2.0 | 4 votes |
private void configureRenderer(ChromatogramPlotDataSet dataset, int datasetIndex) { final XYPlot plot = chartNode.getChart().getXYPlot(); XYLineAndShapeRenderer newRenderer = new XYLineAndShapeRenderer(); final int lineThickness = dataset.getLineThickness(); newRenderer.setBaseShape(new Ellipse2D.Double(-2 * lineThickness, -2 * lineThickness, 4 * lineThickness + 1, 4 * lineThickness + 1)); newRenderer.setBaseShapesFilled(true); newRenderer.setBaseShapesVisible(dataset.getShowDataPoints()); newRenderer.setDrawOutlines(false); Stroke baseStroke = new BasicStroke(lineThickness); newRenderer.setBaseStroke(baseStroke); // Set tooltips for legend newRenderer.setLegendItemToolTipGenerator((ds, series) -> { if (ds instanceof ChromatogramPlotDataSet) { return ((ChromatogramPlotDataSet) ds).getDescription(); } else return null; }); // Set color Color baseColor = dataset.getColor(); newRenderer.setBasePaint(JavaFXUtil.convertColorToAWT(baseColor)); // Set label generator XYItemLabelGenerator intelligentLabelGenerator = new IntelligentItemLabelGenerator(chartNode, 100, dataset); newRenderer.setBaseItemLabelGenerator(intelligentLabelGenerator); newRenderer.setBaseItemLabelPaint(JavaFXUtil.convertColorToAWT(labelsColor)); newRenderer.setBaseItemLabelsVisible(itemLabelsVisible.get()); newRenderer.setBaseItemLabelsVisible(true); // Set tooltip generator newRenderer.setBaseToolTipGenerator(dataset); plot.setRenderer(datasetIndex, newRenderer); }