Domain Type labels on points

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
TheHaas
Posts: 21
Joined: Sat Feb 07, 2004 9:14 pm
Contact:

Domain Type labels on points

Post by TheHaas » Wed Feb 11, 2004 5:59 pm

My customer wants a XY-Line chart with at least 3 sets of data. That is no problem, but they want each dot on the chart labeled with the domain name. So, for all the points that belong to Series 1, they want a "1" by each point.

Is this even possible to do with JFreeChart? Does anyone have an idea on how to move toward it? Looking through the javadocs and the Developer's Guide yields little on this.

TheHaas
Posts: 21
Joined: Sat Feb 07, 2004 9:14 pm
Contact:

Post by TheHaas » Wed Feb 11, 2004 6:36 pm

It never fails . . . I ask the question, and then I stumble on it in the javadocs:

Code: Select all

XYTextAnnotation note = new XYTextAnnotation("1",5,5.2);
		plotdata.addAnnotation(note);
I can probably figure out how to align the annotations with the point in some programmic manner

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

Post by david.gilbert » Thu Feb 12, 2004 11:47 am

That is one way to do it. If you are labelling every point, then you might want to customise the renderer to draw the labels, that way it will be easier to work out where to put the labels. (Shortly I will be adding "item labels" to the XYItemRenderer classes, to work the same way as the item labels for the CategoryItemRenderer classes).
David Gilbert
JFreeChart Project Leader

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

TheHaas
Posts: 21
Joined: Sat Feb 07, 2004 9:14 pm
Contact:

Post by TheHaas » Thu Feb 12, 2004 7:06 pm

Customizing the renderer would be a wondeful idea . . . . but I decided not to look too deep renderer code.

Here is a method that works for me. I used an x-offset of 0.1. You may have to adjust this to your own need.

http://users.binary.net/thehaas/blogfil ... Notes.html

Locked