Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
transform(
// tslint:disable-next-line:no-any
input: any,
inputUnit: DtUnit | string = DtUnit.COUNT,
): DtFormattedValue | string {
if (isEmpty(input)) {
return NO_DATA;
}
if (input instanceof DtFormattedValue) {
return formatCount(input, inputUnit);
}
if (isNumber(input)) {
return formatCount(coerceNumberProperty(input), inputUnit);
}
return NO_DATA;
}
}
set value(value: [number, number]) {
if (!isNumber(value[0]) || !isNumber(value[1])) {
this._handleOverlayClose();
return;
}
this._value = value;
this._rangeHidden = false;
// add the triangles to the handles to enable the drag state
// the value is going to be set programmatically so we never need the initial drag state
// without the triangles
this._reflectRangeReleased(true);
// reflect the values to px values and display them
this._reflectValueToArea();
// trigger an internal state changes event
this._emitStateChanges();
// check if the range is valid and toggle the appropriate classes
this._checkRangeValid();
// sets the aria labels with the renderer to avoid change detection.
// tslint:disable-next-line:no-any
input: any,
factor: number = KILO_MULTIPLIER,
inputUnit: DtUnit = DtUnit.BYTES,
): DtFormattedValue | string {
if (isEmpty(input)) {
return NO_DATA;
}
if (input instanceof DtFormattedValue) {
return formatBytes(input, {
factor,
inputUnit,
outputUnit: DtUnit.MEGA_BYTES,
});
}
if (isNumber(input)) {
return formatBytes(coerceNumberProperty(input), {
factor,
inputUnit,
outputUnit: DtUnit.MEGA_BYTES,
});
}
return NO_DATA;
}
}
_getData(data: T): any {
const output = this.displayAccessor
? this.displayAccessor(data, this.name)
: (data as any)[this.name]; // tslint:disable-line:no-any
if (isNumber(output) && !isDefined(this.formatter)) {
return formatCount(output);
}
return this.formatter ? this.formatter(output) : output;
}
}
export function generateAreaRangeData(
amountOrLineSeries: number | DataPoint[],
min: number,
max: number,
timestampStart?: number,
timestampTick?: number,
): DataPoint[] {
if (min > max) {
throw new Error(
`Min value (${min}) must not be larger than max value (${max})`,
);
}
let data: DataPoint[];
if (isNumber(amountOrLineSeries)) {
if (amountOrLineSeries < 0) {
throw new Error('Amount must not be negative');
}
if (timestampStart === undefined || timestampTick === undefined) {
throw new Error(
'Parameters timestampStart and timestampTick are required',
);
}
const amount = amountOrLineSeries as number;
data = new Array(amount);
for (let i = 0; i < amount; i++) {
data[i] = {
x: timestampStart + timestampTick * i,
set length(value: number) {
const length = coerceNumberProperty(value);
if (isNumber(value) && this._length !== length) {
this._length = length;
this._updateItems();
this._changeDetectorRef.markForCheck();
}
}
private _length = 0;
export function generateAreaRangeData(
amountOrLineSeries: number | DataPoint[],
min: number,
max: number,
timestampStart?: number,
timestampTick?: number,
): DataPoint[] {
if (min > max) {
throw new Error(
`Min value (${min}) must not be larger than max value (${max})`,
);
}
let data: DataPoint[];
if (isNumber(amountOrLineSeries)) {
if (amountOrLineSeries < 0) {
throw new Error('Amount must not be negative');
}
if (timestampStart === undefined || timestampTick === undefined) {
throw new Error(
'Parameters timestampStart and timestampTick are required',
);
}
const amount = amountOrLineSeries as number;
data = new Array(amount);
for (let i = 0; i < amount; i++) {
data[i] = {
x: timestampStart + timestampTick * i,
set pageSize(value: number) {
const pageSize = coerceNumberProperty(value);
if (isNumber(value) && this._pageSize !== pageSize) {
this._pageSize = pageSize;
this._updateItems();
this._changeDetectorRef.markForCheck();
}
}
private _pageSize: number = DEFAULT_PAGE_SIZE;
set value(value: number) {
if (!isNumber(value)) {
this._handleOverlayClose();
return;
}
this._value = value;
this._timestampHidden = false;
this._reflectValueToPosition();
this._emitStateChanges();
this._changeDetectorRef.markForCheck();
}
transform(
input: any,
inputUnit: DtTimeUnit = DtTimeUnit.MILLISECOND,
toUnit: DtTimeUnit | undefined,
): DtFormattedValue | string {
if (isEmpty(input)) {
return NO_DATA;
}
return isNumber(input)
? formatTime(coerceNumberProperty(input), inputUnit, toUnit)
: NO_DATA;
}
}