Hello,
I’m probably missing something obvious, but how can I change the font/colors of JUST the scichart legend (not axes labels or other text) in Android.
Thank you.
- C Bolton asked 2 years ago
- You must login to post comments
Hi there,
Well to do this you’ll need to create custom LegendItem or extend default one and override font and colors. Then you need to create factory for new items:
class CustomLegendItemFactory extends DefaultLegendItemsFactory {
@Override
protected LegendItemBase createLegendItem(View legendItemView) {
return new CustomLegendItem(legendItemView);
}
public static class CustomLegendItem extends DefaultLegendItem {
public CustomLegendItem(View itemView) {
super(itemView);
}
@Override
public void bindSource(Object source, SciChartLegend legend) {
super.bindSource(source, legend);
// change TextView properties of item
name.setTextColor(Color.RED);
name.setTypeface(Typeface.MONOSPACE);
}
}
}
After that just need to use new factory during creation of LegendModifier and pass it into chart:
LegendModifier legendModifier = new LegendModifier(new SciChartLegend(getActivity()), new SeriesInfoLegendAdapter(new CustomLegendItemFactory()), true);
legendModifier.setLegendPosition(Gravity.TOP | Gravity.START, 16);
Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroup()
.withModifier(legendModifier)
.build());
Is this suitable for your needs?
Best regards,
Yura
- Yura Khariton answered 2 years ago
-
That’s what I needed. Thank you!
- You must login to post comments
Please login first to submit.