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.

我會修復它,但首先必須評估哪些渲染器受到影響。


注意!

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



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