SciChart Android 2D Charts API > ChartModifier API > Cursors and Tooltips > Common Features and Tooltip Customization
Common Features and Tooltip Customization

The following features are common to all the modifiers that inherit TooltipModifierBase (TooltipModifierCursorModifierRolloverModifier):

Feature Description
getShowTooltip()setShowTooltip() Allows to hide or show modifier's Tooltips.
getUseInterpolation()setUseInterpolation() Allows to show interpolated values between data points. True by default. If False, modifier's Tooltips will report the info about closest data points.
getSourceMode()setSourceMode() Allows to specify which RenderableSeries are to be inspected by a modifier , e.g. VisibleSeriesSelectedSeries, etc. Other will be ignored by the modifier. Expects a member of the SourceMode enumeration.

Tooltips Customization

In SciChart, tooltips customization can be achieved via the ISeriesInfoProvider and ISeriesTooltip interfaces. Tooltips can be made unique per a RenderableSeries instance via the setSeriesInfoProvider() method of the IRenderableSeries type. The base implementation is provided in the abstract SeriesInfoProviderBase class. A custom SeriesInfo can be derived directly from the interface or SeriesInfoProviderBase, or can extend any of the existing SeriesInfo classes. A custom SeriesInfo class should extend the SeriesInfo type and is created based on a RenderableSeries instance.

Copy Code
/**
 * Defines the interface which creates {@link SeriesInfo} and tooltips based on {@link SeriesInfo} values.
 */
public interface ISeriesInfoProvider extends IAttachable {
    /**
     * Creates {@link SeriesInfo} instance which is attached to current {@link IRenderableSeries}.
     *
     * @return The {@link SeriesInfo} instance.
     */
    SeriesInfo getSeriesInfo();
    /**
     * Creates {@link ISeriesTooltip} instance for specified {@code tooltipId} which is attached to current {@link IRenderableSeries}.
     *
     * @param modifierType The type of modifier for which tooltip will be created.
     * @return Tooltip instance.
     */
    ISeriesTooltip getSeriesTooltip(Class<?> modifierType);
    /**
     * Creates {@link ISeriesTooltip} instance which is attached to current {@link IRenderableSeries}.
     *
     * @return Tooltip instance.
     */
    ISeriesTooltip getSeriesTooltip();
}

A custom Tooltip has to implement the ISeriesTooltip or extend the SeriesTooltipBase class, which is derived from TextView.

Copy Code
/**
 * Defines the interface for tooltips for {@link IRenderableSeries}.
 */
public interface ISeriesTooltip extends ITooltip, IHitTestInfoUpdatable, IThemeable, IAttachable {
    /**
     * Gets the associated {@link SeriesInfo} instance.
     *
     * @return The associated {@link SeriesInfo} instance.
     */
    SeriesInfo getSeriesInfo();
    /**
     * Updates tooltips with specified updateAction.
     *
     * @param updateAction The action which updated this tooltip.
     * @param xyCoordinate The {@link PointF} coordinate to update tooltip at.
     */
    void updateTooltip(Action2<View, PointF> updateAction, PointF xyCoordinate);
    /**
     * Draws overlay provided by this tooltip.
     *
     * @param canvas The target Canvas to draw overlay at.
     */
    void onDrawTooltipOverlay(Canvas canvas);
    /**
     * Checks whether series info contains passed in {@link IRenderableSeries} instance.
     * Used mostly {@link StackedSeriesTooltipBase} and inheritors.
     *
     * @param renderableSeries The {@link IRenderableSeries} instance.
     * @return True if the underlying {@link SeriesInfo} contains passed in renderableSeries instance. Otherwise - false.
     */
    boolean containsHitRenderableSeries(IRenderableSeries renderableSeries);
    /**
     * Requests layout for {@link ISeriesTooltip} views using {@link View#requestLayout()}
     */
    void requestLayout();
    /**
     * Invalidate {@link ISeriesTooltip} views using {@link View#invalidate()}
     */
    void invalidate();
    /**
     * Sets the background color for this {@link ISeriesTooltip} instance.
     *
     * @param color Int color which will be used as a background color.
     */
    void setTooltipBackgroundColor(@ColorInt int color);
    /**
     * Sets the stroke color for this {@link ISeriesTooltip} instance.
     *
     * @param color Int color which will be used as a stroke color.
     */
    void setTooltipStroke(@ColorInt int color);
    /**
     * Sets the text color for this {@link ISeriesTooltip} instance.
     *
     * @param color Int color which will be used as a text color.
     */
    void setTooltipTextColor(@ColorInt int color);
}

 

See Also