How to use the @dynatrace/barista-components/core.isNumber function in @dynatrace/barista-components

To help you get started, we’ve selected a few @dynatrace/barista-components examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dynatrace-oss / barista / components / formatters / src / count / count.ts View on Github external
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;
  }
}
github dynatrace-oss / barista / components / chart / src / range / range.ts View on Github external
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.
github dynatrace-oss / barista / components / formatters / src / bytes / megabytes.ts View on Github external
// 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;
  }
}
github dynatrace-oss / barista / components / table / src / simple-columns / simple-number-column.ts View on Github external
_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;
  }
}
github dynatrace-oss / barista / libs / testing / src / lib / chart / generate-area-range-data.ts View on Github external
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,
github dynatrace-oss / barista / components / pagination / src / pagination.ts View on Github external
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;
github dynatrace-oss / barista / libs / examples / src / chart / chart-data-utils.ts View on Github external
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,
github dynatrace-oss / barista / components / pagination / src / pagination.ts View on Github external
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;
github dynatrace-oss / barista / components / chart / src / timestamp / timestamp.ts View on Github external
set value(value: number) {
    if (!isNumber(value)) {
      this._handleOverlayClose();
      return;
    }
    this._value = value;
    this._timestampHidden = false;
    this._reflectValueToPosition();
    this._emitStateChanges();
    this._changeDetectorRef.markForCheck();
  }
github dynatrace-oss / barista / components / formatters / src / time / time.ts View on Github external
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;
  }
}