@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.
300 lines (298 loc) • 8.44 kB
TypeScript
import { TypedArray } from '@nativescript-community/arraybuffers';
import { CanvasView, Matrix, Rect, RectF } from '@nativescript-community/ui-canvas';
/**
* Class that contains information about the charts current viewport settings, including offsets, scale & translation
* levels, ...
*
*/
export declare class ViewPortHandler {
/**
* matrix used for touch events
*/
mMatrixTouch: Matrix;
/**
* this rectangle defines the area in which graph values can be drawn
*/
readonly contentRect: RectF;
readonly chartRect: RectF;
chartWidth: number;
chartHeight: number;
/**
* buffer for storing the 9 matrix values of a 3x3 matrix
*/
protected mMatrixBuffer: number[] | TypedArray;
/**
* minimum scale value on the y-axis
*/
private mMinScaleY;
/**
* maximum scale value on the y-axis
*/
private mMaxScaleY;
/**
* minimum scale value on the x-axis
*/
private mMinScaleX;
/**
* maximum scale value on the x-axis
*/
private mMaxScaleX;
/**
* contains the current scale factor of the x-axis
*/
private mScaleX;
/**
* contains the current scale factor of the y-axis
*/
private mScaleY;
/**
* current translation (drag distance) on the x-axis
*/
private mTransX;
/**
* current translation (drag distance) on the y-axis
*/
private mTransY;
/**
* offset that allows the chart to be dragged over its bounds on the x-axis
*/
private mTransOffsetX;
/**
* offset that allows the chart to be dragged over its bounds on the x-axis
*/
private mTransOffsetY;
/**
* Sets the width and height of the chart.
*
* @param width
* @param height
*/
setChartDimens(width: any, height: any): void;
get hasChartDimens(): boolean;
restrainViewPort(offsetLeft: any, offsetTop: any, offsetRight: any, offsetBottom: any): void;
get offsetLeft(): number;
get offsetRight(): number;
get offsetTop(): number;
get offsetBottom(): number;
get contentTop(): number;
get contentLeft(): number;
get contentRight(): number;
get contentBottom(): number;
get contentCenter(): {
x: number;
y: number;
};
/**
* Returns the smallest extension of the content rect (width or height).
*/
get smallestContentExtension(): number;
/**
* ################ ################ ################ ################
*/
/** CODE BELOW THIS RELATED TO SCALING AND GESTURES */
/**
* Zooms in by 1.4f, x and y are the coordinates (in pixels) of the zoom
* center.
*
* @param x
* @param y
*/
zoomIn(x: any, y: any, outputMatrix: any): any;
zoomOut(x: any, y: any, outputMatrix: any): any;
/**
* Zooms out to original size.
* @param outputMatrix
*/
resetZoom(outputMatrix: any): void;
/**
* Post-scales by the specified scale factors.
*
* @param scaleX
* @param scaleY
* @return
*/
zoom(scaleX: any, scaleY: any, outputMatrix: any): any;
/**
* Post-scales by the specified scale factors. x and y is pivot.
*
* @param scaleX
* @param scaleY
* @param x
* @param y
* @return
*/
zoomAtPosition(scaleX: any, scaleY: any, x: any, y: any, outputMatrix: Matrix): Matrix;
/**
* Sets the scale factor to the specified values.
*
* @param scaleX
* @param scaleY
* @return
*/
setZoom(scaleX: any, scaleY: any, outputMatrix: any): any;
/**
* Sets the scale factor to the specified values. x and y is pivot.
*
* @param scaleX
* @param scaleY
* @param x
* @param y
* @return
*/
setZoomAtPosition(scaleX: any, scaleY: any, x: any, y: any): Matrix;
/**
* Resets all zooming and dragging and makes the chart fit exactly it's
* bounds. Output Matrix is available for those who wish to cache the object.
*/
fitScreen(outputMatrix?: any): any;
/**
* Post-translates to the specified points. Output matrix allows for caching objects.
*
* @param transformedPts
* @return
*/
translate(transformedPts: any, outputMatrix?: any): any;
/**
* Centers the viewport around the specified position (x-index and y-value)
* in the chart. Centering the viewport outside the bounds of the chart is
* not possible. Makes most sense in combination with the
* setScaleMinima(...) method.
*
* @param transformedPts the position to center view viewport to
* @param view
* @return save
*/
centerViewPort(transformedPts: number[] | TypedArray, view: CanvasView): void;
/**
* call this method to refresh the graph with a given matrix
*
* @param newMatrix
* @return
*/
refresh(newMatrix: Matrix, chart: CanvasView, invalidate: any): Matrix;
setScale(scaleX: any, scaleY: any): void;
get scaleX(): number;
get scaleY(): number;
/**
* limits the maximum scale and X translation of the given matrix
*
* @param matrix
*/
limitTransAndScale(matrix: Matrix, content: Rect): void;
/**
* Sets the minimum scale factor for the x-axis
*
* @param xScale
*/
setMinimumScaleX(xScale: any): void;
/**
* Sets the maximum scale factor for the x-axis
*
* @param xScale
*/
setMaximumScaleX(xScale: any): void;
/**
* Sets the minimum and maximum scale factors for the x-axis
*
* @param minScaleX
* @param maxScaleX
*/
setMinMaxScaleX(minScaleX: any, maxScaleX: any): void;
/**
* Sets the minimum scale factor for the y-axis
*
* @param yScale
*/
setMinimumScaleY(yScale: any): void;
/**
* Sets the maximum scale factor for the y-axis
*
* @param yScale
*/
setMaximumScaleY(yScale: any): void;
setMinMaxScaleY(minScaleY: any, maxScaleY: any): void;
/**
* Returns the charts-touch matrix used for translation and scale on touch.
*/
getMatrixTouch(): Matrix;
/**
* ################ ################ ################ ################
*/
/**
* BELOW METHODS FOR BOUNDS CHECK
*/
isInBoundsX(x: any): boolean;
isInBoundsY(y: any): boolean;
isInBounds(x: any, y: any): boolean;
isInBoundsLeft(x: any): boolean;
isInBoundsRight(x: any): boolean;
isInBoundsTop(y: any): boolean;
isInBoundsBottom(y: any): boolean;
/**
* returns the current x-scale factor
*/
getScaleX(): number;
/**
* returns the current y-scale factor
*/
getScaleY(): number;
getMinScaleX(): number;
getMaxScaleX(): number;
getMinScaleY(): number;
getMaxScaleY(): number;
/**
* Returns the translation (drag / pan) distance on the x-axis
*/
getTransX(): number;
/**
* Returns the translation (drag / pan) distance on the y-axis
*/
getTransY(): number;
/**
* if the chart is fully zoomed out, return true
*/
isFullyZoomedOut(): boolean;
/**
* Returns true if the chart is fully zoomed out on it's y-axis (vertical).
*/
isFullyZoomedOutY(): boolean;
/**
* Returns true if the chart is fully zoomed out on it's x-axis
* (horizontal).
*/
isFullyZoomedOutX(): boolean;
/**
* Set an offset in dp that allows the user to drag the chart over it's
* bounds on the x-axis.
*
* @param offset
*/
setDragOffsetX(offset: any): void;
/**
* Set an offset in dp that allows the user to drag the chart over it's
* bounds on the y-axis.
*
* @param offset
*/
setDragOffsetY(offset: any): void;
/**
* Returns true if both drag offsets (x and y) are zero or smaller.
*/
hasNoDragOffset(): boolean;
/**
* Returns true if the chart is not yet fully zoomed out on the x-axis
*/
canZoomOutMoreX(): boolean;
/**
* Returns true if the chart is not yet fully zoomed in on the x-axis
*/
canZoomInMoreX(): boolean;
/**
* Returns true if the chart is not yet fully zoomed out on the y-axis
*/
canZoomOutMoreY(): boolean;
/**
* Returns true if the chart is not yet fully zoomed in on the y-axis
*/
canZoomInMoreY(): boolean;
}