ToolTips No Longer Work.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
artipton
Posts: 16
Joined: Thu Jul 03, 2008 6:59 pm

ToolTips No Longer Work.

Post by artipton » Tue Feb 14, 2012 3:43 pm

Morning,

About two updates ago, I was able to hover the mouse over a trending line and it would show the value in a tooltip. When I went to version 13, it stopped working... I just updated to 14 and still no luck. I have found a post relating to this, but maybe the API has changed. I have worked with my code, but still not able to find a solution.

Here is how I am creating the chart:

Code: Select all

protected void createChart()
        {
        JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, null, false, true, false);
        chart.getXYPlot().setDataset(INT_DATASET_INDEX, dataSet);
        chart.getXYPlot().setDataset(BOOL_DATASET_INDEX, booleanDataSet);
        chart.getXYPlot().setRenderer(INT_DATASET_INDEX, new StandardXYItemRenderer());
        chart.getXYPlot().setRenderer(BOOL_DATASET_INDEX, new XYStepRenderer());
        chart.getXYPlot().setBackgroundPaint(AdcAppPrefs.GetDvuGraphBackgroundColor());
        chart.getXYPlot().getDomainAxis().setTickLabelFont(new Font(Font.DIALOG, Font.BOLD, 10));
        chart.getXYPlot().getRangeAxis().setTickLabelFont(new Font(Font.DIALOG, Font.BOLD, 10));
        chart.getXYPlot().getDomainAxis().setTickMarksVisible(true);
        chart.getXYPlot().getRangeAxis().setTickMarksVisible(true);
        chart.getXYPlot().setDomainGridlinePaint(AdcAppPrefs.GetDvuGraphGridColor());
        chart.getXYPlot().setRangeGridlinePaint(AdcAppPrefs.GetDvuGraphGridColor());
        chart.getXYPlot().setDomainCrosshairVisible(true);
        chart.getXYPlot().setRangeCrosshairVisible(true);
        chartPane = new ChartPanel(chart);
        chartPane.setMouseWheelEnabled(true);
        chartPane.setPreferredSize(new Dimension(200, 100));
        JPopupMenu menu = chartPane.getPopupMenu();
        menu.remove(0); // Remove the Properties item...
        menu.remove(0); // Remove the line separator...
        menu.remove(8); // Remove the auto scale item...
        menu.remove(7); // Remove the line separator...
        menu.addSeparator();
        menu.add(ShowDataViewPropsAction.getInstance());
        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setRangePannable(true);
        }
Thank you for your help,
Andy

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: ToolTips No Longer Work.

Post by paradoxoff » Wed Feb 15, 2012 1:56 pm

A renderer needs an associated XYToolTipGenerator to create the tooltips. Such one is not created by default, but must be assigned to the renderer explicitly. This is done in the ChartFactory method that you have used. However, you are creating a new renderer for whatever INT_DATASET_INDEX and BOOL_DATASET_INDEX is, and you need to assign XYToolTipGenerators for them as well.

artipton
Posts: 16
Joined: Thu Jul 03, 2008 6:59 pm

Re: ToolTips No Longer Work.

Post by artipton » Fri May 25, 2012 4:48 pm

I appreciate the help. I am finally back to working on this area after several overrides...

I got these working with the tool tip generator. I was trying to use HTML in the return string to change the looks of the tooltip, but most everything seems to be ignored (I can bold the text). I can't change the background color font color, etc...

For example:

Code: Select all

return "<html><p background:#FFFFAA; border-color:#9FDAEE;>"+dataset.getSeriesKey( series ) +": "+dataset.getYValue(series, item)+"</p></html>";
Should I be able to customize the tooltip?

Thank you,
Andy

Locked