Tooltip - Y value always shows 0

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
chrisrhyno2003
Posts: 30
Joined: Thu Jun 18, 2015 5:42 pm
antibot: No, of course not.

Tooltip - Y value always shows 0

Post by chrisrhyno2003 » Thu Jul 09, 2015 12:48 am

I am generating a StackedXYAreaChart using the ChartFactory utility.

Everytime I hover over my chart - the 'Y' value is always shown 0.0 even though the chart plots a correct value greater than -0.
Is there something I am doing wrong ? Here's my sample program:
TimeTableXYDataset dataset = new TimeTableXYDataset ();
JFreeChart chart = ChartFactory.createStackedXYChart("Chart Name" "Time", "Size ", dataset , PlotOrientation.VERTICAL, true, true, false);

final StackedXYAreaRenderer renderChart = new StackedXYAreaRenderer(StackedXYAreaRenderer.AREA_AND_SHAPES);
renderChart.setSeriesPaint(0, Color.decode("#339900"));
renderChart.setSeriesPaint(1, Color.decode("#ffff7f"));
renderChart.setSeriesPaint(2, Color.decode("#33CCFF"));
renderChart.setSeriesPaint(3, Color.decode("#FF9966"));
renderChart.setSeriesShape(0, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));
renderChart.setSeriesShape(1, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));
renderChart.setSeriesShape(2, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));
renderChart.setSeriesShape(3, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));
renderChart.setToolTipGenerator(new StandardXYToolTipGenerator(){
@Override
public String generateToolTip(XYDataset dataset, int series, int item)
{
String toolTip = "Payload Size : " + dataset.getY(item,series);
return toolTip;
}
});

chart.getplot().setRenderer(renderChart);

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

Re: Tooltip - Y value always shows 0

Post by paradoxoff » Thu Jul 09, 2015 8:50 am

Replace

Code: Select all

String toolTip = "Payload Size : " + dataset.getY(item,series);
with

Code: Select all

String toolTip = "Payload Size : " + dataset.getY(series,item);

chrisrhyno2003
Posts: 30
Joined: Thu Jun 18, 2015 5:42 pm
antibot: No, of course not.

Re: Tooltip - Y value always shows 0

Post by chrisrhyno2003 » Thu Jul 09, 2015 5:32 pm

Still shows me the same value of 0.

chrisrhyno2003
Posts: 30
Joined: Thu Jun 18, 2015 5:42 pm
antibot: No, of course not.

Re: Tooltip - Y value always shows 0

Post by chrisrhyno2003 » Thu Jul 09, 2015 5:35 pm

I changed to a StackXYAreaRenderer2. It works now.

Locked