@nativescript-community/ui-chart
Version:
A powerful chart / graph plugin, supporting line, bar, pie, radar, bubble, and candlestick charts as well as scaling, panning and animations.
188 lines (186 loc) • 6.05 kB
TypeScript
import { GestureStateEventData, GestureTouchEventData, PanGestureHandler, PinchGestureHandler, TapGestureHandler } from '@nativescript-community/gesturehandler';
import { Matrix } from '@nativescript-community/ui-canvas';
import { BarLineChartBase } from '../charts/BarLineChartBase';
import { ChartTouchListener } from './ChartTouchListener';
/**
* TouchListener for Bar-, Line-, Scatter- and CandleStickChart with handles all
* touch interaction. Longpress === Zoom out. Double-Tap === Zoom in.
*
*/
export declare class BarLineChartTouchListener extends ChartTouchListener<BarLineChartBase<any, any, any>> {
/**
* the original touch-matrix from the chart
*/
private mMatrix;
/**
* matrix for saving the original matrix state
*/
private mSavedMatrix;
/**
* center between two pointers (fingers on the display)
*/
private mTouchPointCenter;
private mSavedXDist;
private mSavedYDist;
private mClosestDataSetToTouch;
private mDecelerationVelocity;
/**
* Constructor with initialization parameters.
*
* @param chart instance of the chart
* @param touchMatrix the touch-matrix of the chart
* @param dragTriggerDistance the minimum movement distance that will be interpreted as a "drag" gesture in dp (3dp equals
* to about 9 pixels on a 5.5" FHD screen)
*/
TAP_HANDLER_TAG: any;
DOUBLE_TAP_HANDLER_TAG: any;
PINCH_HANDLER_TAG: any;
PAN_HANDLER_TAG: any;
constructor(chart: BarLineChartBase<any, any, any>, touchMatrix: Matrix, dragTriggerDistance: any);
panGestureHandler: PanGestureHandler;
pinchGestureHandler: PinchGestureHandler;
tapGestureHandler: TapGestureHandler;
doubleTapGestureHandler: TapGestureHandler;
getPanGestureOptions(): {
minDist?: number;
activeOffsetXStart?: number;
activeOffsetXEnd?: number;
failOffsetXStart?: number;
failOffsetXEnd?: number;
activeOffsetYStart?: number;
activeOffsetYEnd?: number;
failOffsetYStart?: number;
failOffsetYEnd?: number;
enabled?: boolean;
shouldCancelWhenOutside?: boolean;
waitFor?: number[];
simultaneousHandlers?: number[];
nativeGetterKey?: string;
gestureTag: any;
};
getPinchGestureOptions(): {
minSpan?: number;
enabled?: boolean;
shouldCancelWhenOutside?: boolean;
waitFor?: number[];
simultaneousHandlers?: number[];
nativeGetterKey?: string;
gestureTag: any;
};
getTapGestureOptions(): {
numberOfTaps?: number;
maxDurationMs?: number;
maxDelayMs?: number;
maxDeltaX?: number;
maxDeltaY?: number;
maxDist?: number;
minPointers?: number;
enabled?: boolean;
shouldCancelWhenOutside?: boolean;
waitFor?: number[];
simultaneousHandlers?: number[];
nativeGetterKey?: string;
gestureTag: any;
};
getDoubleTapGestureOptions(): {
numberOfTaps?: number;
maxDurationMs?: number;
maxDelayMs?: number;
maxDeltaX?: number;
maxDeltaY?: number;
maxDist?: number;
minPointers?: number;
enabled?: boolean;
shouldCancelWhenOutside?: boolean;
waitFor?: number[];
simultaneousHandlers?: number[];
nativeGetterKey?: string;
gestureTag: any;
};
getOrCreateDoubleTapGestureHandler(): TapGestureHandler;
getOrCreateTapGestureHandler(): TapGestureHandler;
getOrCreatePinchGestureHandler(): PinchGestureHandler;
getOrCreatePanGestureHandler(): PanGestureHandler;
setDoubleTap(enabled: boolean): void;
setTap(enabled: boolean): void;
setPinch(enabled: boolean): void;
setPan(enabled: boolean): void;
dispose(): void;
init(): void;
onPanGestureState(event: GestureStateEventData): void;
onPanGestureTouch(event: GestureTouchEventData): void;
onPinchGestureState(event: GestureStateEventData): void;
onPinchGestureTouch(event: GestureTouchEventData): void;
/**
* ################ ################ ################ ################
*/
/** BELOW CODE PERFORMS THE ACTUAL TOUCH ACTIONS */
/**
* Saves the current Matrix state and the touch-start point.
*
* @param event
*/
private saveTouchStart;
/**
* Performs all necessary operations needed for dragging.
*
* @param event
*/
private performDrag;
/**
* Highlights upon dragging, generates callbacks for the selection-listener.
*
* @param e
*/
private performHighlightDrag;
/**
* Highlights upon dragging, generates callbacks for the selection-listener.
*
* @param e
*/
private handleTouchHighlight;
/**
* calculates the distance on the x-axis between two pointers (fingers on
* the display)
*
* @param e
* @return
*/
private static getXDist;
/**
* calculates the distance on the y-axis between two pointers (fingers on
* the display)
*
* @param e
* @return
*/
private static getYDist;
/**
* Returns a recyclable MPPointF instance.
* returns the correct translation depending on the provided x and y touch
* points
*
* @param x
* @param y
* @return
*/
getTrans(x: any, y: any): {
x: number;
y: number;
};
/**
* Returns true if the current touch situation should be interpreted as inverted, false if not.
*/
private inverted;
/**
* ################ ################ ################ ################
*/
/** GETTERS AND GESTURE RECOGNITION BELOW */
/**
* returns the matrix object the listener holds
*/
getMatrix(): Matrix;
onDoubleTapGesture(event: GestureStateEventData): void;
onTapGesture(event: GestureStateEventData): void;
stopDeceleration(): void;
}