I have written the code below, and when I click on chart I want that it display date and payment on the correspondent position (that jfrechart displays with 2 perpendicular dotted lines), wiht a lable or a tooltips. How can I do ?
XYDataset data = createTimeSeriesCollection(); // creates a dataset wiht date , with new Day() on x and payments , with double ,on y
JFreeChart chart = ChartFactory.createTimeSeriesChart(title, xAxisLabel, yAxisLabel, data,false);
chart.setChartBackgroundPaint(new GradientPaint(0, 0, Color.white,0, 1000, Color.blue));
Plot plot = chart.getPlot();
// and present it in a frame...
JFreeChartFrame timeSeries2ChartFrame = new JFreeChartFrame("chart", chart,true);
timeSeries2ChartFrame.pack();
Setta.centra(timeSeries2ChartFrame,false);
timeSeries2ChartFrame.setVisible(true);
display value when I click on chart
Re: display value when I click on chart
Hi Walter,
There isn't a feature (yet) for displaying the actual values with the crosshairs, but it will get added at some point.
Tooltips are working for XYPlots but the code is not quite in a complete state. The basic mechanism is there, but I still need to document how it works (which usually entails changing how it works at the same time).
The principle is that you need to get JFreeChartPanel to pass a DrawInfo object to the JFreeChart.draw method, and the DrawInfo instance has to have a non-null ToolTipsCollection object to collect information about where the tooltips should be drawn. At the same time, you need to register an instance of an XYToolTipGenerator with the plot, which controls the actual format of the text (looking at the code, I haven't yet written the method for registering the tooltip generator, so until the next version of JFreeChart you'll have to write your own).
It's a bit messy, but it will get tidied up...
Regards,
DG.
There isn't a feature (yet) for displaying the actual values with the crosshairs, but it will get added at some point.
Tooltips are working for XYPlots but the code is not quite in a complete state. The basic mechanism is there, but I still need to document how it works (which usually entails changing how it works at the same time).
The principle is that you need to get JFreeChartPanel to pass a DrawInfo object to the JFreeChart.draw method, and the DrawInfo instance has to have a non-null ToolTipsCollection object to collect information about where the tooltips should be drawn. At the same time, you need to register an instance of an XYToolTipGenerator with the plot, which controls the actual format of the text (looking at the code, I haven't yet written the method for registering the tooltip generator, so until the next version of JFreeChart you'll have to write your own).
It's a bit messy, but it will get tidied up...
Regards,
DG.