• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bar Chart

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm looking to create a Bar Chart applet,I did that by drawing
rectangles,but the problem is I need to create an event when I click on each bar,but the bars are not objects ,they are just shapes.
Any one please can help and tell me how to create a Bar Chart applet and when you click on each bar we popup a menu.
Thanks alot.
 
paul wheaton
Trailboss
Pie
Posts: 21880
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest that you make lightweight components. Each component can inherit Canvas or Component. Set their size to be the size of the rectangle you want. Set their background color to the color you want. Then place them on a panel using the null layout manager (so you can get exact positioning). Now, each bar has it's own collection of events that it will generate!
 
Pawel Veselov
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not quite sure creating each comp. for every chart is that great idea, since it can slow the whole down a lot (depends on how many charts are there). Why just not check coordinates from the mouse clicks that are going to root component ?
From the other side, for the popup menu it can be more complicated, since if popup menu differes for every chart, then you'll need to remove/add items each time you click the popupTrigger button.

------------------
With best of best regards, Pawel S. Veselov ( aka Black Angel )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic