• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Display Bar Values in Chart

 
Ranch Hand
Posts: 1951
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone help me with the following code syntax? I need to display the x values on top of the bars in my chart.

 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess would be that this calls for a subclass of ClusteredXYBarRenderer that does some extra drawing (of the numeric value) on top of the bar. You'd override the drawItem method for that.
 
Steve Dyke
Ranch Hand
Posts: 1951
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:My guess would be that this calls for a subclass of ClusteredXYBarRenderer that does some extra drawing (of the numeric value) on top of the bar. You'd override the drawItem method for that.



Can you explain a little more in detail?
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like this:
 
Steve Dyke
Ranch Hand
Posts: 1951
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I am missing somthing and I am surely not questioning your advice and expertise. Is all this necessary just to do what I thought would be a simple, turn on or display x value labels.
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I'm misunderstanding what you're trying to do. I interpreted "I need to display the x values on top of the bars in my chart. " to mean that you want the values to be drawn inside of the rectangle defined by each bar. Since FreeChart has no provisions for doing that, you'd have to go the route I outlined.

If you actually meant something else, please elaborate.

Out of the box, JFreeChart can only display values as part of an Axis, which can be left or right of a chart (for value axes) or above or below a chart (for domain axes); see the AxisLocation class for details.
 
Steve Dyke
Ranch Hand
Posts: 1951
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right now my chart displays horizontal bars, seven sets of five bars. It is showing a weeks worth of department activity. What the Management wants to see in addition to what I have is the values of the bars also displayed above each bar.
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could check out what the AbstractRenderer.setBaseItemLabelsVisible
and setBasePositiveItemLabelPosition methods can do.
 
Steve Dyke
Ranch Hand
Posts: 1951
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:You could check out what the AbstractRenderer.setBaseItemLabelsVisible
and setBasePositiveItemLabelPosition methods can do.



Is there any way you could provide an example of this?
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be something like this:
 
Steve Dyke
Ranch Hand
Posts: 1951
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the example, I got it to work.
 
I will suppress my every urge. But not this shameless plug:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!