Closed hecto932 closed 3 years ago
Hi @hecto932 you should create your custom modifier by extending RubberBandXyZoomModifier, here you can find an example - https://github.com/ABTSoftware/SciChart.JS.Examples/blob/master/Sandbox/CustomerExamples/CreateAnnotationsDynamically/src/CreateAnnotationModifier.ts Let me know if it helps
Also, you can assign different mouse buttons to the modifiers, to prevent conflicts if they are used simultaneously
import { EExecuteOn } from "scichart/types/ExecuteOn";
...
const rubberBandModifier = new RubberBandXyZoomModifier({ executeOn: EExecuteOn.MouseRightButton });
const zoomPanModifier = new ZoomPanModifier({ executeOn: EExecuteOn.MouseMiddleButton });
sciChartSurface.chartModifiers.add(zoomPanModifier);
sciChartSurface.chartModifiers.add(rubberBandModifier);
I'll check those examples
Thanks, @klishevich @observerjnr
This is what I did and it solved my issue :)
import { RubberBandXyZoomModifier } from 'scichart/Charting/ChartModifiers/RubberBandXyZoomModifier';
import { ModifierMouseArgs } from 'scichart/Charting/ChartModifiers/ModifierMouseArgs';
import { easing } from 'scichart/Core/Animations/EasingFunctions';
import { EXyDirection } from 'scichart/types/XyDirection';
// Create a TypeScript class which inherits ChartModifierbase2D to insert into SciChartSurface.chartModifiers collection
export class CustomRubberXyModifier extends RubberBandXyZoomModifier {
private options: any;
constructor(options: any) {
const defaultOptions = {
isAnimated: true,
animationDuration: 400,
easingFunction: easing.outExpo,
fill: '#FFFFFF33',
stroke: '#FFFFFF77',
strokeThickness: 1,
xyDirection: EXyDirection.YDirection,
}
super(defaultOptions);
this.options = options;
}
// Called when mouse-up on the chart
public modifierMouseUp(args: ModifierMouseArgs) {
super.modifierMouseUp(args);
if (this.options?.modifierMouseUp) {
this.options.modifierMouseUp();
}
}
}
Do you have any comments about it?
Hi @hecto932 it looks fine :)!
Hi Hector - looks good! That is precisely how to extend the RubberBandXyZoomModifier using typescript. Good job!
On Mon, Mar 15, 2021 at 10:02 AM Michael Klishevich < @.***> wrote:
Hi @hecto932 https://github.com/hecto932 it looks fine :)!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ABTSoftware/SciChart.JS.Examples/issues/61#issuecomment-799288281, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADLEDVMCPSTWHZNGT4SPY3DTDXLKTANCNFSM4Y7LY5SQ .
Hi, again guys!
Currently, I would like to call a custom function after make zoom in using a rubberBandXyZoomModifier.
So here I have an example about how I'm using the
modifierMouseUp
event to call a custom functionWhat would I like to do?
I would like to switch between zoomPanModifier and rubberBandXyZoomModifier, and when I'm using a rubberBandXyZoomModifier I would like to call a custom function without overwriting the normal behavior of zoom.
What would it be the best way to do this? It looks like I'm overwriting or replacing the modifierMouseUp function