Search code examples
javajfreechartshapes

JFreeChart XYLineChart customise shape of nodes into rings


I have an XYLineChart and I want to customize the shape of nodes into rings.

Like this:

shape nodes

Here is the code how I try to done this:

Ellipse2D bigCircle = new Ellipse2D.Double(-4, -4, 8, 8);
Ellipse2D smallCircle = new Ellipse2D.Double(-2,-2,4,4);

Area ring = new Area(bigCircle);
ring.subtract(new Area(smallCircle));

Shape ringShape = (Shape)ring;

renderer.setSeriesShape(0, ringShape);

But the result is like in the left image. It is like this renderer.setSeriesShape(0, bigCircle);

What I am doing wrong?

or

Exist a factory with shapes which include my shape?


Solution

  • My code is fine, but the problem is from line. How @samabcde said.

    I made a bigger ring to see what exactly is.

    https://i.imgur.com/JM4xG88.png