Pre loader

How to change ChartModifier

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 developing a candle stick chart, with modifier newModifierGroupWithDefaultModifiers
What i want to do is
1. when user click the chart, the modifier will be changed to CursorModifier,
2. xy axis label should not disappeared when user release their finger

How could i do that?

Thank you

Version
Trial
  • You must to post comments
0
0

Hi Tommy,

Thanks for writing to us.

Well nothing of this is available out of the box but you can create custom modifiers to provided desired behavior.

  1. You can create a separate modifier which listens to touch event and when click occurs it enables CursorModifier:

    class ActivateCursorModifier extends GestureModifierBase {
    private final CursorModifier cursorModifier;
    
    ActivateCursorModifier(CursorModifier cursorModifier) {
        this.cursorModifier = cursorModifier;
    
        // intercept handled touch events
        setReceiveHandledEvents(true);
    
        // disable modifier
        cursorModifier.setIsEnabled(false);
    }
    
    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        // enable modifier after click
        cursorModifier.setIsEnabled(true);
        return true;
    }
    }
    
  2. You can customize CursorModifier to prevent hiding it’s tooltips and override its onTouchDown() which shows tooltips and onTouchUp() which hides tooltips:

    class CustomCursorModifier extends CursorModifier {
    private boolean isFirstTouch = true;
    
    @Override
    protected boolean onTouchDown(ModifierTouchEventArgs args) {
        // place tooltip on first touch only and ignore other touch down events because tooltip should remain on screen
        if(isFirstTouch) {
            isFirstTouch = false;
            return super.onTouchDown(args);
        } else
            super.onTouchMove(args);
        return true;
    
    }
    
    @Override
    protected boolean onTouchUp(ModifierTouchEventArgs args) {
        // ignore touch up event
        return false;
    }
    }
    

Is this suitable for your needs?

Hope it will help you.

Best regards,
Yura

  • You must to post comments
0
0

Thanks! Your code is really helpful
May I ask how to modify the axis label of the cursor? I cannot find any public interface to change it

  • You must to post comments
Showing 2 results
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