Pre loader

How to customize y axis label

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

0
0

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!

Version
Trial
  • You must to post comments
1
0

Hi Tommy,

I’m not 100% sure that I understand your requirements but I’ll try to answer your questions.

  1. 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.

  2. 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

  • tommy ng
    Thanks! Your answer is perfect
  • tommy ng
    May i ask how could i do the same in iOS? I need to do the same with Objective C
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies