Adding Label on the Chart....

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ashutosh
Posts: 15
Joined: Fri Dec 08, 2006 1:43 pm

Adding Label on the Chart....

Post by ashutosh » Thu Jan 18, 2007 2:29 pm

Hi Everyone,

I want to ask a few questions :

1. How can I add a label or annotation on the Chart?? I have a Single Category bar, on which LabelGenerator is generating the values when dataset is getting refreshed. So I want a label of system time stamp should be visible on the Plot Area beside the bar where value is visible.


2. While Ploting a Category Bar Chart can there be some gap between the Ploting of the same bar graph.

For Example: Let say, I am having a dynamic bar graph with single category that plots the bar from 0-1000 with an interval of 50.

So if it plots the bar from 0-350 dynamically, then there should be a gap from 350-500 and next Ploting should start from 500 onwards. Can this be done with Category Bar Chart, or Stacked bar chart or any other Chart.

If yes then how??? what I have to do for that.

3 . My other question is, can I fix the tick marks (0-50-100-150-200-250-300......so on) ??? As they changes automatically if the size of the chart area changes. What method I have to use for that?


Please help me ....

-Ashutosh

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

Re: Adding Label on the Chart....

Post by david.gilbert » Thu Jan 18, 2007 6:00 pm

ashutosh wrote:1. How can I add a label or annotation on the Chart?? I have a Single Category bar, on which LabelGenerator is generating the values when dataset is getting refreshed. So I want a label of system time stamp should be visible on the Plot Area beside the bar where value is visible.
The reason JFreeChart uses an interface (CategoryItemLabelGenerator) to derive the item labels is precisely so that you can plug in your own implementation of the interface.
ashutosh wrote:2. While Ploting a Category Bar Chart can there be some gap between the Ploting of the same bar graph.

For Example: Let say, I am having a dynamic bar graph with single category that plots the bar from 0-1000 with an interval of 50.

So if it plots the bar from 0-350 dynamically, then there should be a gap from 350-500 and next Ploting should start from 500 onwards. Can this be done with Category Bar Chart, or Stacked bar chart or any other Chart.
If your x-axis is numerical, you should use XYPlot and work with the XYBarRenderer class. It's not as simple, but it is more flexible and can handle the case you described (as far as I can tell).
ashutosh wrote:3 . My other question is, can I fix the tick marks (0-50-100-150-200-250-300......so on) ??? As they changes automatically if the size of the chart area changes. What method I have to use for that?
If you use an XYPlot as I've suggested, then you can call setTickUnit() on the NumberAxis that is being used for the chart's x-axis.
David Gilbert
JFreeChart Project Leader

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

ashutosh
Posts: 15
Joined: Fri Dec 08, 2006 1:43 pm

Re: Adding Label on the Chart....

Post by ashutosh » Fri Jan 19, 2007 8:11 am

david.gilbert wrote:
ashutosh wrote:1. How can I add a label or annotation on the Chart?? I have a Single Category bar, on which LabelGenerator is generating the values when dataset is getting refreshed. So I want a label of system time stamp should be visible on the Plot Area beside the bar where value is visible.
The reason JFreeChart uses an interface (CategoryItemLabelGenerator) to derive the item labels is precisely so that you can plug in your own implementation of the interface.
ashutosh wrote:2. While Ploting a Category Bar Chart can there be some gap between the Ploting of the same bar graph.

For Example: Let say, I am having a dynamic bar graph with single category that plots the bar from 0-1000 with an interval of 50.

So if it plots the bar from 0-350 dynamically, then there should be a gap from 350-500 and next Ploting should start from 500 onwards. Can this be done with Category Bar Chart, or Stacked bar chart or any other Chart.
If your x-axis is numerical, you should use XYPlot and work with the XYBarRenderer class. It's not as simple, but it is more flexible and can handle the case you described (as far as I can tell).
ashutosh wrote:3 . My other question is, can I fix the tick marks (0-50-100-150-200-250-300......so on) ??? As they changes automatically if the size of the chart area changes. What method I have to use for that?
If you use an XYPlot as I've suggested, then you can call setTickUnit() on the NumberAxis that is being used for the chart's x-axis.


Thank You, David

ashutosh
Posts: 15
Joined: Fri Dec 08, 2006 1:43 pm

Post by ashutosh » Mon Feb 19, 2007 5:35 am

David,

This was my query last time.....


While Ploting a Category Bar Chart can there be some gap between the Ploting of the same bar graph.

For Example: Let say, I am having a dynamic bar graph with single category that plots the bar from 0-1000 with an interval of 50.

So if it plots the bar from 0-350 dynamically, then there should be a gap from 350-500 and next Ploting should start from 500 onwards. Can this be done with Category Bar Chart, or Stacked bar chart or any other Chart.

If yes then how??? what I have to do for that.



You suggested to use XY Plot if my x-axis is numeric. But my x-axis is not numeric.

Can I do this with Cataegory Plot. if yes the how??? Please help.


Please Reply.....

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 » Mon Feb 19, 2007 10:43 am

You might have to explain this some more. Is the 0-1000 on the x-axis or the y-axis?
David Gilbert
JFreeChart Project Leader

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

ashutosh
Posts: 15
Joined: Fri Dec 08, 2006 1:43 pm

Post by ashutosh » Mon Feb 19, 2007 4:32 pm

Hi David,

As I'm using the Category bar chart the numeric value 0-1000 with interval of 50 (0-50, 50-100, 100-150......300-350) will be on Y-axis.

Locked