Hi,
i am trying to create multiple Y Axis in my chart
1. Left side is showing Price Value, i.e. 1200, 1201…
2. Right side is showing the % change relative to certain price, i.e. 1%, 2%…
3. Both side label should be aligned so that 1200 1%, 1201 2% ….
Questions:
1. How to align the value on both Y Axis?
2. I want to assign multiple color to Y Axis, for example, blue for -ve value, red for +ve value, how to do that?
Thank you!
- tommy ng asked 6 years ago
- You must login to post comments
Hi Tommy,
I’m not 100% sure that I understand your requirements but I’ll try to answer your questions.
-
To align two axes you need to use same VisibleRange so when you scroll one axes other will be scrolled as well. You can find a information about how to do this in our documentation ( the only difference is that we synchronize ranges across xAxes across different charts). Then you can use LabelProvider API to change yAxis labels and output per cent values.
-
To change colors of axis labels you need to create custom LabelProvider and return SpannableString with ForegroundColorSpan:
@Override public CharSequence formatLabel(Comparable dataValue) { Spannable spannable = new SpannableString(super.formatLabel(dataValue)); spannable.setSpan(new ForegroundColorSpan(Color.BLUE), 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return spannable; }
Is this suitable for your needs?
Hope it will help you!
Best regards,
Yura
- Yura Khariton answered 6 years ago
-
Thanks! Your answer is perfect
-
May i ask how could i do the same in iOS? I need to do the same with Objective C
- You must login to post comments
Please login first to submit.