Two shapes plotted on points of a linegraph

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
blahfunk
Posts: 8
Joined: Wed Jan 17, 2018 5:52 pm
antibot: No, of course not.

Two shapes plotted on points of a linegraph

Post by blahfunk » Mon Jan 22, 2018 8:54 pm

I am wanting to place a single shape at the point where my linegraph is at its max and (eventually) one where it is at its minimum. In my life graph I have an unknown number of linegraphs at the bottom on the graph representing readings from meters from one datetime to the next and then the totals of those meters for each datetime. I want to mark where the total is at its min and max with a triangle pointing down and up respectively.

Suggestions on how to do this?

Image

To follow myself up, I already know what these values are and where and what datetime they occur. I just need to know how to mark these on the linegraph.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Two shapes plotted on points of a linegraph

Post by david.gilbert » Wed Jan 24, 2018 7:08 am

If you are using XYLineAndShapeRenderer, the shape displayed for any particular data item is returned by the method:

Code: Select all

public Shape getItemShape(int row, int column)
The default implementation for this just returns one shape per data series, but if you override it you can return a different shape for any data item. You might also need to override getItemShapeVisible() to only show shapes for the two data points you are interested in.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

blahfunk
Posts: 8
Joined: Wed Jan 17, 2018 5:52 pm
antibot: No, of course not.

Re: Two shapes plotted on points of a linegraph

Post by blahfunk » Mon Feb 12, 2018 10:03 pm

I resolved this using annotations. I found the high and low and then used the pointers from annotations to mark what I needed:
Image

Locked