Pre loader

Custom Tooltip Labels in OHLC Chart (Android)

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
1
2

Hi all,

I would like to ask how to modify the label of the OHLC Chart in Android.
For example, in the attached screenshot, how to change the label “Highest” to “High” ? Thanks.

Version
1.2.1
Images
  • You must to post comments
Best Answer
2
1

Hi Ray,

To achieve that you need to create custom SeriesInfoProvider, override getSeriesTooltipInternal method and return
Custom tooltip inside in it. Please take a look at our documentation below:

https://www.scichart.com/documentation/android/v1.x/webframe.html#Common%20Features%20and%20Tooltip%20Customization.html

Please take a look at the custom series info provider and custom tooltip code below, which demonstrates how to do that:

private static class CustomOhlcSeriesInfoProvider extends DefaultOhlcSeriesInfoProvider {
    @Override
    protected ISeriesTooltip getSeriesTooltipInternal(Context context, OhlcSeriesInfo seriesInfo) {
        return new CustomOhlcSeriesTooltip(context, seriesInfo);
    }

    private static class CustomOhlcSeriesTooltip extends OhlcSeriesTooltip {
        public CustomOhlcSeriesTooltip(Context context, OhlcSeriesInfo seriesInfo) {
            super(context, seriesInfo);
        }

        @Override
        protected boolean internalUpdate(OhlcSeriesInfo seriesInfo) {
            final StringBuilder sb = new StringBuilder();
            sb.append(String.format("Open CHANGED: %s", seriesInfo.getFormattedOpenValue()));
            sb.append(StringUtil.NEW_LINE);
            sb.append(String.format("High CHANGED: %s", seriesInfo.getFormattedHighValue()));
            sb.append(StringUtil.NEW_LINE);
            sb.append(String.format("Low CHANGED: %s", seriesInfo.getFormattedLowValue()));
            sb.append(StringUtil.NEW_LINE);
            sb.append(String.format("Close CHANGED: %s", seriesInfo.getFormattedCloseValue()));

            setText(sb.toString());
            setSeriesColor(0xFFBBAAAC);

            return true;
        }
    }
}

all you need to do, is to set SeriesInfoProvider to your OHLC series like so:

  candlestickRenderableSeries.setSeriesInfoProvider(new CustomOhlcSeriesInfoProvider());

Hope this helps.
Best regards.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.