Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » [chart] tooltip containing x label
[chart] tooltip containing x label [message #912946] Fri, 14 September 2012 09:05 Go to next message
moritz du is currently offline moritz du
Messages: 98
Registered: February 2010
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 14:06 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
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


Jason Weathersby

BIRT Exchange
Re: [chart] tooltip containing x label [message #915371 is a reply to message #913072] Mon, 17 September 2012 02:44 Go to previous messageGo to next message
moritz du is currently offline moritz du
Messages: 98
Registered: February 2010
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 13:10 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

I am glad I could help.

Jason


Jason Weathersby

BIRT Exchange
Previous Topic:createFactoryObject returns null after upgrade of BIRT
Next Topic:Birt:param tag, need help
Goto Forum:
  


Current Time: Mon Apr 21 00:44:44 EDT 2014

Powered by FUDForum. Page generated in 0.01606 seconds