Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » [chart] tooltip containing x label
[chart] tooltip containing x label [message #912946] Fri, 14 September 2012 13:05 Go to next message
moritz du is currently offline moritz duFriend
Messages: 102
Registered: February 2010
Senior Member
I am trying to set a hover tool tip that contains the series definition and the category/xlabel and value.

so far i managed to create a tool tip with series definition and value:

        for (BarSeries bs : barSeries) {
            bs.getDataPoint().setPrefix((String) bs.getSeriesIdentifier() + ": ");
            bs.getTriggers()
              .add(TriggerImpl.create(TriggerCondition.ONMOUSEOVER_LITERAL,
                                      ActionImpl.create(ActionType.SHOW_TOOLTIP_LITERAL,
                                                        TooltipValueImpl.create(200,
                                                                                null))));

        }


but how to get access to the corresponding x-Label (the value of x series)?
Re: [chart] tooltip containing x label [message #913072 is a reply to message #912946] Fri, 14 September 2012 18:06 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You need to specify an ActionRenderer for interactivity:
gcs = gr.build(dServer, cm, bo, null, null, null);
gcs.getRunTimeContext().setActionRenderer( new SimpleActionRenderer(null));
//have to have this line if you want the image map generated
dRenderer.setProperty(IDeviceRenderer.UPDATE_NOTIFIER,
new EmptyUpdateNotifier(cm, gcs.getChartModel()));


SimpleActionRenderer is one you could use or extend ActionRendererAdapter and write your own. For example:

import org.eclipse.birt.chart.computation.DataPointHints;
import org.eclipse.birt.chart.event.StructureSource;
import org.eclipse.birt.chart.event.StructureType;
import org.eclipse.birt.chart.factory.IDataRowExpressionEvaluator;
import org.eclipse.birt.chart.integrate.SimpleActionHandle;
import org.eclipse.birt.chart.integrate.SimpleActionUtil;
import org.eclipse.birt.chart.model.attribute.ActionType;
import org.eclipse.birt.chart.model.attribute.TooltipValue;
import org.eclipse.birt.chart.model.attribute.URLValue;
import org.eclipse.birt.chart.model.data.Action;
import org.eclipse.birt.chart.render.ActionRendererAdapter;
import org.eclipse.birt.chart.util.ChartUtil;

/**
* Simple implementation for IActionRenderer
*/

public class MyActionRenderer extends ActionRendererAdapter
{

private final IDataRowExpressionEvaluator evaluator;

public MyActionRenderer( IDataRowExpressionEvaluator evaluator )
{
this.evaluator = evaluator;
}

public void processAction( Action action, StructureSource source )
{
if ( ActionType.URL_REDIRECT_LITERAL.equals( action.getType( ) ) )
{
URLValue uv = (URLValue) action.getValue( );

String sa = uv.getBaseUrl( );
SimpleActionHandle handle = SimpleActionUtil.deserializeAction( sa );
String uri = handle.getURI( );
if ( StructureType.SERIES_DATA_POINT.equals( source.getType( ) )
&& evaluator != null )
{
final DataPointHints dph = (DataPointHints) source.getSource( );
uri = ChartUtil.stringValue( dph.getUserValue( uri ) );
}
uv.setBaseUrl( uri );
uv.setTarget( handle.getTargetWindow( ) );
}
else if ( ActionType.SHOW_TOOLTIP_LITERAL.equals( action.getType( ) ) )
{
TooltipValue tv = (TooltipValue) action.getValue( );

if ( StructureType.SERIES_DATA_POINT.equals( source.getType( ) ) )
{
final DataPointHints dph = (DataPointHints) source.getSource( );

tv.setText( ChartUtil.stringValue( dph.getBaseValue() + "--" +dph.getSeriesDisplayValue() + "--"+dph.getOrthogonalDisplayValue()) );
}
}
}

}

This sets the tooltip value to the basevalue--seriesvalue-orthogonalvalue.
You would then set the renderer like:
gcs.getRunTimeContext().setActionRenderer( new MyActionRenderer(null));

Jason
Re: [chart] tooltip containing x label [message #915371 is a reply to message #913072] Mon, 17 September 2012 06:44 Go to previous messageGo to next message
moritz du is currently offline moritz duFriend
Messages: 102
Registered: February 2010
Senior Member
jason you are great!

it's unbelievable how much i learned about a single api from a single person in such a short time.
Re: [chart] tooltip containing x label [message #915637 is a reply to message #915371] Mon, 17 September 2012 17:10 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I am glad I could help.

Jason
Previous Topic:Maximo+BIRT: how to use jdbc data source?
Next Topic:Birt:param tag, need help
Goto Forum:
  


Current Time: Thu Apr 25 22:14:17 GMT 2024

Powered by FUDForum. Page generated in 0.03460 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top