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.

116 lines 3.65 kB
import { LineScatterCandleRadarDataSet } from './LineScatterCandleRadarDataSet'; import { Style } from '@nativescript-community/ui-canvas'; import { ColorTemplate } from '../utils/ColorTemplate'; export class CandleDataSet extends LineScatterCandleRadarDataSet { constructor(yVals, label, xProperty, yProperty, highProperty, lowProperty, openProperty, closeProperty) { super(yVals, label, xProperty, yProperty); /** * property to access the "high" value of an entry for this set * */ this.highProperty = 'high'; /** * property to access the "low" value of an entry for this set * */ this.lowProperty = 'low'; /** * property to access the "close" value of an entry for this set * */ this.closeProperty = 'close'; /** * property to access the "open" value of an entry for this set * */ this.openProperty = 'open'; /** * the width of the shadow of the candle */ this.shadowWidth = 3; /** * should the candle bars show? * when false, only "ticks" will show * <p/> * - default: true */ this.showCandleBar = true; /** * the space between the candle entries, default 0.1 (10%) */ this.barSpace = 0.1; /** * use candle color for the shadow */ this.shadowColorSameAsCandle = false; /** * palet style when open < close * increasing candlesticks are traditionally hollow */ this.increasingPaintStyle = Style.STROKE; /** * palet style when open > close * descreasing candlesticks are traditionally filled */ this.decreasingPaintStyle = Style.FILL; /** * color for open === close */ this.neutralColor = ColorTemplate.COLOR_SKIP; /** * color for open < close */ this.increasingColor = ColorTemplate.COLOR_SKIP; /** * color for open > close */ this.decreasingColor = ColorTemplate.COLOR_SKIP; /** * shadow line color, set -1 for backward compatibility and uses default * color */ this.shadowColor = ColorTemplate.COLOR_SKIP; if (highProperty) { this.highProperty = highProperty; } if (lowProperty) { this.lowProperty = lowProperty; } if (openProperty) { this.openProperty = openProperty; } if (closeProperty) { this.closeProperty = closeProperty; } this.init(); } getEntryYValue(e) { const lowValue = e[this.lowProperty] || 0; const highValue = e[this.highProperty] || 0; return (lowValue + highValue) / 2; } calcMinMaxForEntry(e, index) { if (!e) return; const high = e[this.highProperty]; const low = e[this.lowProperty]; if (low < this.mYMin) this.mYMin = low; if (high > this.mYMax) this.mYMax = high; this.calcMinMaxX(e, index); } calcMinMaxY(e) { const high = e[this.highProperty]; const low = e[this.lowProperty]; if (high < this.mYMin) this.mYMin = high; if (high > this.mYMax) this.mYMax = high; if (low < this.mYMin) this.mYMin = low; if (low > this.mYMax) this.mYMax = low; } } //# sourceMappingURL=CandleDataSet.js.map