@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.
176 lines (174 loc) • 5.67 kB
TypeScript
import { Matrix, Path, Rect } from '@nativescript-community/ui-canvas';
import { TypedArray } from '@nativescript-community/arraybuffers';
import { BubbleDataSet } from '../data/BubbleDataSet';
import { CandleDataSet } from '../data/CandleDataSet';
import { Entry } from '../data/Entry';
import { IDataSet } from '../interfaces/datasets/IDataSet';
import { ViewPortHandler } from './ViewPortHandler';
/**
* Transformer class that contains all matrices and is responsible for
* transforming values into pixels on the screen and backwards.
*
*/
export declare class Transformer {
/**
* matrix to map the values to the screen pixels
*/
protected mMatrixValueToPx: Matrix;
/**
* matrix for handling the different offsets of the chart
*/
protected mMatrixOffset: Matrix;
protected mViewPortHandler: ViewPortHandler;
protected mValuePointsForGenerateTransformedValuesScatter: TypedArray;
protected mValuePointsForGenerateTransformedValuesCandle: TypedArray;
protected mValuePointsForGenerateTransformedValues: TypedArray;
protected mValuePointsForGenerateTransformedValuesBubble: TypedArray;
private mMBuffer1;
private mMBuffer2;
constructor(viewPortHandler: ViewPortHandler);
/**
* Prepares the matrix that transforms values to pixels. Calculates the
* scale factors from the charts size and offsets.
*
* @param xChartMin
* @param deltaX
* @param deltaY
* @param yChartMin
*/
prepareMatrixValuePx(xChartMin: any, deltaX: any, deltaY: any, yChartMin: any): void;
/**
* Prepares the matrix that contains all offsets.
*
* @param inverted
*/
prepareMatrixOffset(inverted: any): void;
/**
* Transforms an List of Entry into a let array containing the x and
* y values transformed with all matrices for the SCATTERCHART.
*
* @param data
* @return
*/
generateTransformedValuesScatter(dataSet: IDataSet<Entry>, phaseX: any, phaseY: any, from: any, to: any): {
points: number[] | TypedArray;
count: number;
};
/**
* Transforms an List of Entry into a float array containing the x and
* y values transformed with all matrices for the BUBBLECHART.
*
* @param data
* @return
*/
generateTransformedValuesBubble(dataSet: BubbleDataSet, phaseY: any, from: any, to: any): {
points: number[] | TypedArray;
count: number;
};
/**
* Transforms an List of Entry into a let array containing the x and
* y values transformed with all matrices for the BUBBLECHART.
*
* @param data
* @return
*/
generateTransformedValues(dataSet: IDataSet<Entry>, phaseX: any, phaseY: any, from: any, to: any): {
points: number[] | TypedArray;
count: number;
};
/**
* Transforms an List of Entry into a let array containing the x and
* y values transformed with all matrices for the CANDLESTICKCHART.
*
* @param data
* @return
*/
generateTransformedValuesCandle(dataSet: CandleDataSet, phaseX: any, phaseY: any, from: any, to: any): {
points: number[] | TypedArray;
count: number;
};
/**
* transform a path with all the given matrices VERY IMPORTANT: keep order
* to value-touch-offset
*
* @param path
*/
pathValueToPixel(path: Path): void;
/**
* Transforms multiple paths will all matrices.
*
* @param paths
*/
pathValuesToPixel(paths: Path[]): void;
mapPoints(matrix: Matrix, pts: number[] | TypedArray): void;
/**
* Transform an array of points with all matrices. VERY IMPORTANT: Keep
* matrix order "value-touch-offset" when transforming.
*
* @param pts
*/
pointValuesToPixel(pts: number[] | TypedArray): void;
/**
* Transform a rectangle with all matrices.
*
* @param r
*/
rectValueToPixel(r: any): void;
/**
* Transform a rectangle with all matrices with potential animation phases.
*
* @param r
* @param phaseY
*/
rectToPixelPhase(r: Rect, phaseY: any): void;
rectToPixelPhaseHorizontal(r: Rect, phaseY: any): void;
/**
* Transform a rectangle with all matrices with potential animation phases.
*
* @param r
* @param phaseY
*/
rectValueToPixelHorizontal(r: Rect, phaseY?: any): void;
/**
* transforms multiple rects with all matrices
*
* @param rects
*/
rectValuesToPixel(rects: Rect[]): void;
protected mPixelToValueMatrixBuffer: Matrix;
/**
* Transforms the given array of touch positions (pixels) (x, y, x, y, ...)
* into values on the chart.
*
* @param pixels
*/
pixelsToValue(pixels: any): void;
/**
* Returns a recyclable MPPointD instance.
* returns the x and y values in the chart at the given touch point
* (encapsulated in a MPPointD). This method transforms pixel coordinates to
* coordinates / values in the chart. This is the opposite method to
* getPixelForValues(...).
*
* @param x
* @param y
* @return
*/
getValuesByTouchPoint(x: any, y: any, outputPoint?: any): any;
/**
* Returns a recyclable MPPointD instance.
* Returns the x and y coordinates (pixels) for a given x and y value in the chart.
*
* @param x
* @param y
* @return
*/
getPixelForValues(x: any, y: any): {
x: number;
y: number;
};
getValueMatrix(): Matrix;
getOffsetMatrix(): Matrix;
getValueToPixelMatrix(): Matrix;
getPixelToValueMatrix(): Matrix;
}