I have a basic XYPlot with one serie. When the plot orientation is vertical, the tooltip is working fine. When the plot orientation is horizontal, the tooltip does not appear at all, or sometimes by error with wrong values.
public class HorizontalPlotTooltip {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
XYPlot plot = new XYPlot();
plot.setOrientation(PlotOrientation.HORIZONTAL);
NumberAxis xAxis = new NumberAxis("x-axis value");
xAxis.setAutoRange(true);
xAxis.setAutoRangeIncludesZero(false);
xAxis.setInverted(true);
plot.setDomainAxis(xAxis);
NumberAxis yAxis = new NumberAxis("y-axis value");
yAxis.setAutoRange(true);
yAxis.setAutoRangeIncludesZero(false);
plot.setRangeAxis(yAxis);
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true,false);
StandardXYToolTipGenerator generator = new StandardXYToolTipGenerator(StandardXYZToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,new DecimalFormat("#"),new DecimalFormat("0.00"));
renderer.setBaseToolTipGenerator(generator);
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries series = new XYSeries("value");
for (int i=0; i < 2000; i++) {
series.add(i,Math.sin(i/500.0));
}
dataset.addSeries(series);
plot.setDataset(dataset);
plot.setRenderer(renderer);
JFreeChart chart = new JFreeChart("Inverted - Horizontal plot problem",plot);
ChartPanel chartPanel = new ChartPanel(chart);
// long dismiss delay to observe tooltip
chartPanel.setDismissDelay(100000);
frame.setPreferredSize(new Dimension(200,700));
frame.setMinimumSize(new Dimension(200,700));
frame.setLayout(new BorderLayout());
frame.add(chartPanel);
frame.setVisible(true);
}
Is there extra code to add to have tooltip with correct values when the plot is horizontal ?
This is a bug in JFreeChart:
http://www.jfree.org/forum/viewtopic.php?f=3&t=117805
I will fix it, but first have to evaluate which of the renderers are affected.