|
Re: [chart] tooltip containing x label [message #913072 is a reply to message #912946] |
Fri, 14 September 2012 18:06   |
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02110 seconds