JFreeChart:工具提示停止在旋转的绘图上工作

[英]JFreeChart: tooltip stop working on rotated plot


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.

我有一个基本的XYPlot和一个系列。当绘图方向是垂直的时,工具提示工作正常。当绘图方向为水平时,工具提示根本不显示,或者有时显示错误值的错误。

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 ?

当绘图是水平的时,是否有额外的代码可以添加工具提示正确的值?

1 个解决方案

#1


2  

This is a bug in JFreeChart:

这是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.

我会修复它,但首先必须评估哪些渲染器受到影响。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2017/04/05/72045552648f5d0c4dbc05c6433256c3.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告