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.
- Ray Hung asked 8 years ago
- last edited 8 years ago
- You must login to post comments
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:
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.
- Nazar Rudnyk answered 8 years ago
- You must login to post comments
Please login first to submit.