@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.
81 lines • 2.39 kB
JavaScript
export var ChartGesture;
(function (ChartGesture) {
ChartGesture[ChartGesture["NONE"] = 0] = "NONE";
ChartGesture[ChartGesture["DRAG"] = 1] = "DRAG";
ChartGesture[ChartGesture["X_ZOOM"] = 2] = "X_ZOOM";
ChartGesture[ChartGesture["Y_ZOOM"] = 3] = "Y_ZOOM";
ChartGesture[ChartGesture["PINCH_ZOOM"] = 4] = "PINCH_ZOOM";
ChartGesture[ChartGesture["ROTATE"] = 5] = "ROTATE";
ChartGesture[ChartGesture["SINGLE_TAP"] = 6] = "SINGLE_TAP";
ChartGesture[ChartGesture["DOUBLE_TAP"] = 7] = "DOUBLE_TAP";
ChartGesture[ChartGesture["LONG_PRESS"] = 8] = "LONG_PRESS";
ChartGesture[ChartGesture["FLING"] = 9] = "FLING";
})(ChartGesture || (ChartGesture = {}));
/**
* Created by philipp on 12/06/15.
*/
export class ChartTouchListener {
constructor(chart) {
/**
* the last touch gesture that has been performed
**/
this.mLastGesture = ChartGesture.NONE;
/**
* integer field that holds the current touch-state
*/
this.mTouchMode = ChartTouchListener.NONE;
this.chart = chart;
}
dispose() { }
init() { }
/**
* returns the touch mode the listener is currently in
*/
get touchMode() {
return this.mTouchMode;
}
/**
* Returns the last gesture that has been performed on the chart.
*/
get lastGesture() {
return this.mLastGesture;
}
/**
* Perform a highlight operation.
*
* @param e
*/
performHighlight(h) {
if (!h || h === this.lastHighlighted) {
this.chart.highlight(null, true);
this.lastHighlighted = null;
}
else {
this.chart.highlight(h, true);
this.lastHighlighted = h;
}
}
/**
* returns the distance between two points
*
* @param eventX
* @param startX
* @param eventY
* @param startY
* @return
*/
static distance(eventX, startX, eventY, startY) {
const dx = eventX - startX;
const dy = eventY - startY;
return Math.sqrt(dx * dx + dy * dy);
}
}
// states
ChartTouchListener.NONE = 0;
ChartTouchListener.DRAG = 1;
ChartTouchListener.X_ZOOM = 2;
ChartTouchListener.Y_ZOOM = 3;
ChartTouchListener.PINCH_ZOOM = 4;
ChartTouchListener.POST_ZOOM = 5;
ChartTouchListener.ROTATE = 6;
//# sourceMappingURL=ChartTouchListener.js.map