Tooltip Modifier 3D
In SciChart Android 3D you can add Tooltips onto SciChartSurface3D using the TooltipModifier3D. It's derived from the ChartModifierBase3D and executes on touch over the data-point and shows tooltips under the pointer.
Note
Examples of the TooltipModifier3D usage can be found in the SciChart Android Examples Suite as well as on GitHub:
TooltipModifier3D Usage
The TooltipModifier3D allows inspecting RenderableSeries 3D at a touch point. For convenience, the actual hit-test point is located a bit above the actual touch point. It is marked with a small "X" sign. Tooltips will appear to the side of it, showing the hit-test result of the topmost IRenderableSeries3D at the "X" location:
For hit-testing series parts that are close to the chart boundaries, a multi-touch finger drag can be used, which makes hit-test point appear in between of two finger touches, same way as it works with 2D TooltipModifier.
TooltipModifier3D Features
The TooltipModifier3D has a bunch of the configuration properties listed in the table below, some of them are inherited from its base class - TooltipModifierBase:
Feature | Description | |
---|---|---|
setShowTooltip(boolean showTooltip) | Allows to hide or show modifier's Tooltips. | |
setSourceMode(SourceMode sourceMode) | Allows to specify which IRenderableSeries are to be inspected by a modifier, e.g. Visible, Selected, etc. Other will be ignored by the modifier. Expects a member of the SourceMode enumeration. | |
setShowAxisLabels(boolean showAxisLabels) | Allows to hide or show Tooltips axis labels | |
setOffset(float offset) | Specifies how far the hit-test point is from the actual touch point. This value will be used for either X or Y coordinate, or both, depending on markerPlacement . |
|
setCustomPointOffset(PointF customPointOffset) | Specifies how far the hit-test point is from the actual touch point. As opposed to offset , both X and Y coordinate will always be applied. |
|
setMarkerPlacement(Placement markerPlacement) | Allows to specify the position of the hit-test point relative to the touch point, e.g. Left, Top, etc... Expects a member of the Placement enumeration. | |
setCrosshairStrokeStyle(SolidPenStyle crosshairStrokeStyle) | Allows to specify the PenStyle which will be used to draw Crosshair strokes | |
setCrosshairPlanesFill(int crosshairPlanesFill) | Allows to specify the color to draw Crosshair planes with, if the CrosshairMode.Planes is selected. | |
setCrosshairMode(CrosshairMode crosshairMode) | Allows to specify the crosshair mode, could be Planes or Lines. Expects CrosshairMode enumeration. | |
setProjectionMode(ProjectionMode projectionMode) | Defines the projection mode used to draw Crosshair. Expects the ProjectionMode enumeration. | |
setLineProjectionMode(int lineProjectionMode) | Allows to specify the planes, onto which the crosshair will be projected - XY, XZ, YZ or any combination of planes. Expects LineProjectionMode enumeration. |
Adding a TooltipModifier3D to a Chart
Any Chart Modifier 3D can be added to a SciChartSurface3D via the chartModifiers property and TooltipModifier3D is no difference:
// Assume a surface has been created and configured somewhere
surface.getChartModifiers().add(new TooltipModifier3D());
Note
To learn more about features available, please visit the Chart Modifier 3D APIs article.
Customizing Tooltip Modifier 3D Tooltips
In SciChart, you can fully customize tooltips for TooltipModifier3D. This customization is achieved via the ISeriesInfo3DProvider and ISeriesTooltip3D protocols. Moreover - tooltips can be made unique per a RenderableSeries instance via the setSeriesInfoProvider(renderableSeries.hitTest.ISeriesInfo3DProvider seriesInfoProvider) property.
Note
Examples of the TooltipModifier3D customization can be found in the SciChart Android Examples Suite as well as on GitHub:
To have fully custom tooltip for your modifier, you will need to provide custom ISeriesInfo3DProvider for your RenderableSeries via inheriting from Seriesinfo3DProviderBase<TRenderableSeries3D,TSeriesInfo3D> which contains some base functionality. From there - you might want to override one of the following (or both):
- getSeriesInfoInternal() - allows to provide custom implementation of SeriesInfo3D<T>, which simply contains information about a RenderableSeries and should be created based on it
- getSeriesTooltipInternal(Context context, TSeriesInfo seriesInfo, Class<?> modifierType) - allows to provide custom tooltip for your series, based on
seriesInfo
andmodifierType
Customization TooltipModifier3D Example
First thing, we will need to create custom ISeriesTooltip3D and implement internalUpdate(T seriesInfo) method in which we update tooltip instance based on passed in SeriesInfo3D<T> instance. Then, in custom ISeriesInfo3DProvider we override getSeriesTooltipInternal(Context context, TSeriesInfo seriesInfo, Class<?> modifierType) and provide our custom tooltip there. Finally, we provide our custom SeriesInfo3DProvider to our IRenderableSeries3D instance via the corresponding property.
Let's see the code below:
class CustomXyzSeriesTooltip3D extends XyzSeriesTooltip3D {
public CustomXyzSeriesTooltip3D(Context context, XyzSeriesInfo3D<?> seriesInfo) {
super(context, seriesInfo);
}
@Override
protected void internalUpdate(XyzSeriesInfo3D<?> seriesInfo) {
final SpannableStringBuilder sb = new SpannableStringBuilder();
sb.append("This is Custom Tooltip").append(NEW_LINE);
sb.append("VertexId: ").append(Integer.toString(seriesInfo.vertexId)).append(NEW_LINE);
sb.append("X: ").append(seriesInfo.getFormattedXValue()).append(NEW_LINE);
sb.append("Y: ").append(seriesInfo.getFormattedYValue()).append(NEW_LINE);
sb.append("Z: ").append(seriesInfo.getFormattedZValue());
setText(sb);
setSeriesColor(seriesInfo.seriesColor);
setTooltipBackgroundColor(0xffe2460c);
setTooltipStroke(0xffff4500);
setTooltipTextColor(0xffffffff);
}
}
class CustomSeriesInfo3DProvider extends DefaultXyzSeriesInfo3DProvider {
@Override
protected ISeriesTooltip3D getSeriesTooltipInternal(Context context, XyzSeriesInfo3D<? extends XyzRenderableSeries3DBase> seriesInfo, Class<?> modifierType) {
if (modifierType == TooltipModifier3D.class) {
return new CustomXyzSeriesTooltip3D(context, seriesInfo);
} else {
return super.getSeriesTooltipInternal(context, seriesInfo, modifierType);
}
}
}
final ScatterRenderableSeries3D scatterSeries3D = new ScatterRenderableSeries3D();
scatterSeries3D.setSeriesInfoProvider(new CustomSeriesInfo3DProvider());
Note
Full example sources are available in 3D Charts -> Tooltips and HitTest 3D Charts -> Custom Series Tooltips 3D Charts
This will result in the following:
Note
A custom Tooltip has to implement the ISeriesTooltip3D or extend the SeriesTooltip3DBase<T> class, which is derived from TextView.