Changing shape of single point in JFreeChart XYPLot

ChartFactory.createScatterPlot() instantiates an XYLineAndShapeRenderer. You can replace the renderer with one that lets you selectively replace the Shape returned by getItemShape(), as shown below. xyPlot.setRenderer(new XYLineAndShapeRenderer(false, true) { @Override public Shape getItemShape(int row, int col) { if (row == 0 & col == N) { return ShapeUtilities.createDiagonalCross(5, 2); } else { return super.getItemShape(row, col); } … Read more

Prevent JFreeChart DialPlot wrapping around with large values?

I would be interested to hear if there are better methods. The disparity between the DialValueIndicator and the maximumValue may be confusing. As an alternative, signify distinct ranges using StandardDialRange: int redLine = 3 * maximumValue / 5; plot.addLayer(new StandardDialRange(minimumValue, redLine, Color.blue)); plot.addLayer(new StandardDialRange(redLine, maximumValue, Color.red)); Setting the frame’s preferred size is problematic. Instead, override … Read more

JFreeChart create tooltip in ChartPanel

Most ChartFactory methods include a boolean tooltips parameter. Just look in the source for your factory of choice to see how to instantiate a default tooltip generator suitable for the designated renderer. You shouldn’t need to handle the events yourself. Addendum: As you are using createXYLineChart, an instance of StandardXYToolTipGenerator is supplied by default. The … Read more

Creating a time series with jfreechart

You might have a look at org.jfree.chart.demo.TimeSeriesChartDemo1, and the associated API documentation. A typical command to run the demo might look like this: java -cp lib/jfreechart-1.0.13.jar:lib/jcommon-1.0.16.jar \ org.jfree.chart.demo.TimeSeriesChartDemo1 The example uses org.jfree.data.time.Month to represent monthly data, but other units are available in org.jfree.data.time. See also the approach shown in this related example, which is based … Read more

jfreechart customize piechart to show absolute values and percentages

Use the MessageFormat symbol {1} for the absolute section value. See StandardPieSectionLabelGenerator for details. public class MyMinimalPieChartExample { private static final String KEY1 = “Datum 1”; public static final String KEY2 = “Datum 2”; public static void main(String[] args) { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue(KEY1, 99); dataset.setValue(KEY2, 77); JFreeChart someChart = ChartFactory.createPieChart( “Header”, dataset, … Read more

Using JFreeChart Scatter Plots is there a Way to Subdivide Styles for Data Sets?

You might consider the approaches mentioned here. The first implements DrawingSupplier, as shown here: class DefaultDrawingSupplier implements DrawingSupplier… The second extends DefaultDrawingSupplier, as shown here, to achieve a similar effect. Paint[] paintArray = {…}; plot.setDrawingSupplier(new DefaultDrawingSupplier( paintArray, … DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); Of course, you can always override getItemPaint(), as shown here.