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
- tommy ng asked 6 years ago
- You must login to post comments
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
- tommy ng answered 6 years ago
-
Do you mean text of label? If yes then you can change tooltip formatting by setting CursorTextFormatting – https://www.scichart.com/documentation/android/v2.x/webframe.html#Axis%20Labels%20-%20TextFormatting%20and%20CursorTextFormatting.html
-
Yes, but i want to change the color. Currently, the axis label of the cursor is green and semi transparent
-
Well you can change colors by creating custom theme for chart ( https://www.scichart.com/example/android-chart-example-create-a-custom-theme/ ) and overriding axisTooltipTextColor/axisTooltipBackground. If you want you can use one of predefined themes ( https://www.scichart.com/example/android-chart-example-using-thememanager/ ) as parent and override only desired properties.
-
Thanks! Could it be changed programmatically?
- You must login to post comments
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.
-
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; } }
-
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
- Yura Khariton answered 6 years ago
- You must login to post comments
Please login first to submit.