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.

63 lines 2.04 kB
import { Rounding } from '../data/DataSet'; import { DataRenderer } from './DataRenderer'; /** * Class representing the bounds of the current viewport in terms of indices in the values array of a DataSet. */ export class XBounds { /** * Calculates the minimum and maximum x values as well as the range between them. * * @param chart * @param dataSet */ set(chart, dataSet, animator) { const phaseX = Math.max(0, Math.min(1, animator.phaseX)); const low = chart.lowestVisibleX; const high = chart.highestVisibleX; const entryFrom = dataSet.getEntryForXValue(low, NaN, Rounding.DOWN); const entryTo = dataSet.getEntryForXValue(high, NaN, Rounding.UP); this.min = entryFrom ? dataSet.getEntryIndex(entryFrom) : 0; this.max = entryTo ? dataSet.getEntryIndex(entryTo) : 0; this.range = (this.max - this.min) * phaseX; } } /** * Created by Philipp Jahoda on 09/06/16. */ export class BarLineScatterCandleBubbleRenderer extends DataRenderer { constructor(animator, viewPortHandler) { super(animator, viewPortHandler); /** * buffer for storing the current minimum and maximum visible x */ this.mXBounds = new XBounds(); } /** * Returns true if the DataSet values should be drawn, false if not. * * @param set * @return */ shouldDrawValues(set) { return set.visible && (set.drawValuesEnabled || set.drawIconsEnabled); } /** * Checks if the provided entry object is in bounds for drawing considering the current animation phase. * * @param e * @param set * @return */ isInBoundsX(e, set) { if (!e) return false; const entryIndex = set.getEntryIndex(e); if (!e || entryIndex >= set.entryCount * this.animator.phaseY) { return false; } else { return true; } } } //# sourceMappingURL=BarLineScatterCandleBubbleRenderer.js.map