change annotations' value dynamically

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
archangellin
Posts: 8
Joined: Fri Nov 14, 2008 4:47 am

change annotations' value dynamically

Post by archangellin » Mon Nov 24, 2008 9:18 am

Hello, all

I wanna put an annotation on the left-up corner of a chart, and at the same time, its value changes as the mouse moves. Let say, set the x's value to an annotation.

Another one question:
I am drawing a combinedXYPlot which contains 2 charts, I wonder whether I could add two different subtitles to the two different charts? One chart, one subtitle.
Or is there any other way to realize that?

Many Thanks.

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

Re: change annotations' value dynamically

Post by david.gilbert » Mon Nov 24, 2008 1:38 pm

archangellin wrote:I wanna put an annotation on the left-up corner of a chart, and at the same time, its value changes as the mouse moves. Let say, set the x's value to an annotation.
You can update the annotation text, but this won't trigger a chart repaint...however, you could do that manually by calling chart.setNotify(true).

Recently I was experimenting with putting some overlay items on a ChartPanel using JXLayer. That has some promise - I don't have any code available to share on this, but it is something you might want to experiment with.
archangellin wrote:Another one question:
I am drawing a combinedXYPlot which contains 2 charts, I wonder whether I could add two different subtitles to the two different charts? One chart, one subtitle.
Or is there any other way to realize that?
A CombinedXYPlot isn't really two charts - it is one chart with two subplots. So it isn't possible to put subtitles between them. You could put an XYTextAnnotation on each subplot. Alternatively, use two separate charts in two separate ChartPanels.
David Gilbert
JFreeChart Project Leader

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

Locked