Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interactive Charts

 
J Fae
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hellow!

Do you know about any library that has built in funcitions for interactive charts in Swing/AWT.
Something like a "drag-drop" line chart. So that user can change the graph dynamically.

Or an idea how to do that in Java.

Tnx.
 
Jeremy Wilson
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you checked out JFreeChart
 
J Fae
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, but the graphs are not "clickable"
 
Tim Moores
Bartender
Posts: 2951
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... by which you mean what, exactly?
 
J Fae
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


At first you have blue, than by clicking on an dragging, you could change it
 
Tim Moores
Bartender
Posts: 2951
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JFreeChart comes with a subclass of JPanel (called ChartPanel if memory serves); that might be extendable to do this.
 
J Fae
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
final XYSeries series = new XYSeries("XYGraph");
series.add(1, 1);
series.add(1, 2);
series.add(2, 1);
series.add(3, 9);
series.add(4, 10);
...

panel.addChartMouseListener(new ChartMouseListener() {

@Override
public void chartMouseMoved(ChartMouseEvent arg0) {


}

@Override
public void chartMouseClicked(ChartMouseEvent arg0) {
// TODO Get location where user clicked and add coordination to data
// series.add(new Random().nextInt(10), new Random().nextInt(10));

//Returns the underlying mouse event (never null) that triggered the generation of this event.
//This contains information about the mouse location, among other things.
System.out.println("point:"+arg0.getTrigger().getPoint()); //<--doesnt help to identify the location of chart line



}
});
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ChartMouseEvent object has a method getEntity() which in this case returns an instance of 'XYItemEntity'. This class has methods like getSeries() and getItem() which gives back the data about which item on which series was clicked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic