
Read values on Jfreechart graph
Read values on Jfreechart graph
Hello, i want to know if it's possible to read the values when i put the cursor on the graph like this


Re: Read values on Jfreechart graph
no idea?
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Read values on Jfreechart graph
In principle that is possible by using XYItemEntities and tool tips.
There is not much that you need to do to activate them.
Here is a code snippet:
There is not much that you need to do to activate them.
Here is a code snippet:
Code: Select all
public class SimpleToolTipDemo {
public static void main(String[] args) {
DefaultXYDataset set = new DefaultXYDataset();
set.addSeries("Values",new double[][]{{-10,-1,-0.1,0,0.1,1,10},{-0.1,-1,-10,Double.NaN,10,1,0.1}});
JFreeChart chart = ChartFactory.createXYLineChart(
"Tool Tips","x","y",
set,PlotOrientation.VERTICAL,true, true, false);
XYItemRenderer r = chart.getXYPlot().getRenderer();
r.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
JFrame frame = new JFrame("Test");
frame.setContentPane(new ChartPanel(chart));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}