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.

48 lines 2.02 kB
import { ObjectPool } from '../utils/ObjectPool'; import { Utils } from '../utils/Utils'; import { ViewPortJob } from './ViewPortJob'; export class ZoomJob extends ViewPortJob { static getInstance(viewPortHandler, scaleX, scaleY, xValue, yValue, trans, axis, v) { const result = pool.get(); result.xValue = xValue; result.yValue = yValue; result.mScaleX = scaleX; result.mScaleY = scaleY; result.mViewPortHandler = viewPortHandler; result.transformer = trans; result.mAxisDependency = axis; result.mView = v; return result; } static recycleInstance(instance) { pool.recycle(instance); } constructor(viewPortHandler, scaleX, scaleY, xValue, yValue, trans, axis, v) { super(viewPortHandler, xValue, yValue, trans, v); this.mScaleX = scaleX; this.mScaleY = scaleY; this.mAxisDependency = axis; } run() { const save = Utils.getTempMatrix(); const viewPortHanlder = this.mViewPortHandler; viewPortHanlder.zoom(this.mScaleX, this.mScaleY, save); viewPortHanlder.refresh(save, this.mView, false); const yValsInView = this.mView.getAxis(this.mAxisDependency).axisRange / viewPortHanlder.getScaleY(); const xValsInView = this.mView.xAxis.axisRange / viewPortHanlder.getScaleX(); const pts = Utils.getTempArray(2); pts[0] = this.xValue - xValsInView / 2; pts[1] = this.yValue + yValsInView / 2; this.transformer.pointValuesToPixel(pts); viewPortHanlder.translate(pts, save); viewPortHanlder.refresh(save, this.mView, false); this.mView.calculateOffsets(); this.mView.invalidate(); ZoomJob.recycleInstance(this); } instantiate() { return new ZoomJob(null, 0, 0, 0, 0, null, null, null); } } const pool = ObjectPool.create(1, new ZoomJob(null, 0, 0, 0, 0, null, null, null)).setReplenishPercentage(0.5); //# sourceMappingURL=ZoomJob.js.map