UNPKG

@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.

104 lines (102 loc) 3.83 kB
import { Canvas, Paint, Path, RectF } from '@nativescript-community/ui-canvas'; import { AxisBase } from '../components/AxisBase'; import { LimitLine } from '../components/LimitLine'; import { Transformer } from '../utils/Transformer'; import { ViewPortHandler } from '../utils/ViewPortHandler'; import { BaseCustomRenderer } from './DataRenderer'; import { Renderer } from './Renderer'; import { MPPointF } from '../utils/MPPointF'; export type CustomRendererZeroLineFunction = (c: Canvas, axis: AxisBase, zeroPos: MPPointF, path: Path, paint: Paint) => void; export type CustomRendererGridLineFunction = (c: Canvas, axis: AxisBase, rect: RectF, x: any, y: any, axisValue: any, paint: Paint) => void; export type CustomRendererLimitLineFunction = (c: Canvas, axis: AxisBase, limitLine: LimitLine, rect: RectF, x: number, paint: Paint) => void; export type CustomRendererLabelFunction = (c: Canvas, axis: AxisBase, text: string, x: number, y: number, paint: Paint, anchor?: MPPointF, angleDegrees?: number) => void; export type CustomRendererTickFunction = (c: Canvas, renderer: AxisRenderer, startX: number, startY: number, stopX: number, stopY: number, paint: Paint) => void; export interface CustomRenderer extends BaseCustomRenderer { drawLabel?: CustomRendererLabelFunction; drawGridLine?: CustomRendererGridLineFunction; drawZeroLine?: CustomRendererZeroLineFunction; drawLimitLine?: CustomRendererLimitLineFunction; drawMarkTick?: CustomRendererTickFunction; } /** * Baseclass of all axis renderers. * */ export declare abstract class AxisRenderer extends Renderer { /** base axis this axis renderer works with */ protected mAxis: AxisBase; /** transformer to transform values to screen pixels and return */ readonly transformer: Transformer; /** * palet object for the grid lines */ protected mGridPaint: Paint; /** * palet for the x-label values */ protected mAxisLabelPaint: Paint; /** * palet for the line surrounding the chart */ protected mAxisLinePaint: Paint; /** * palet used for the limit lines */ protected mLimitLinePaint: Paint; constructor(viewPortHandler: ViewPortHandler, trans: Transformer, axis: AxisBase); /** * Returns the Paint object that is used for drawing the axis-line that goes * alongside the axis. */ get axisLinePaint(): Paint; get limitLinePaint(): Paint; /** * Returns the Paint object used for drawing the axis (labels). */ get axisLabelsPaint(): Paint; protected createAxisLabelsPaint(): Paint; /** * Returns the Paint object that is used for drawing the grid-lines of the * axis. */ get gridPaint(): Paint; getCurrentMinMax(min?: any, max?: any, inverted?: any): { min: any; max: any; }; /** * Computes the axis values. * * @param min - the minimum value in the data object for this axis * @param max - the maximum value in the data object for this axis */ computeAxis(min: any, max: any, inverted: any): void; /** * Sets up the axis values. Computes the desired number of labels between the two given extremes. */ protected computeAxisValues(min: any, max: any): void; /** * Draws the axis labels to the screen. * * @param c */ abstract renderAxisLabels(c: Canvas): any; /** * Draws the grid lines belonging to the axis. * * @param c */ abstract renderGridLines(c: Canvas): any; /** * Draws the line that goes alongside the axis. * * @param c */ abstract renderAxisLine(c: Canvas): any; /** * Draws the LimitLines associated with this axis to the screen. * * @param c */ abstract renderLimitLines(c: Canvas): any; }