當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript object.isEmpty函數代碼示例

本文整理匯總了TypeScript中core/util/object.isEmpty函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isEmpty函數的具體用法?TypeScript isEmpty怎麽用?TypeScript isEmpty使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isEmpty函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: get_best_ticker

  get_best_ticker(data_low: number, data_high: number, desired_n_ticks: number) {
    const data_range = data_high - data_low
    const ideal_interval = this.get_ideal_interval(data_low, data_high, desired_n_ticks)
    const ticker_ndxs = [
      sortedIndex(this.min_intervals, ideal_interval) - 1,
      sortedIndex(this.max_intervals, ideal_interval),
    ]
    const intervals = [
      this.min_intervals[ticker_ndxs[0]],
      this.max_intervals[ticker_ndxs[1]],
    ]
    const errors = intervals.map((interval) => {
      return Math.abs(desired_n_ticks - (data_range / interval))
    })

    let best_ticker

    if (isEmpty(errors.filter((e) => !isNaN(e)))) {
      // this can happen if the data isn't loaded yet, we just default to the first scale
      best_ticker = this.tickers[0]
    } else {
      const best_index = argmin(errors)
      const best_ticker_ndx = ticker_ndxs[best_index]
      best_ticker = this.tickers[best_ticker_ndx]
    }

    return best_ticker
  }
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:28,代碼來源:composite_ticker.ts

示例2: _get_label_extent

  _get_label_extent() {
    let label_extent;
    const major_labels = this.model.tick_info().labels.major;
    if ((this.model.color_mapper.low != null) && (this.model.color_mapper.high != null) && !isEmpty(major_labels)) {
      const { ctx } = this.plot_view.canvas_view;
      ctx.save();
      this.visuals.major_label_text.set_value(ctx);
      switch (this.model.orientation) {
        case "vertical":
          label_extent = max((major_labels.map((label) => ctx.measureText(label.toString()).width)));
          break;
        case "horizontal":
          label_extent = text_util.get_text_height(this.visuals.major_label_text.font_value()).height;
          break;
      }

      label_extent += this.model.label_standoff;
      ctx.restore();
    } else {
      label_extent = 0;
    }
    return label_extent;
  }
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:23,代碼來源:color_bar.ts

示例3: Error

  /*protected*/ _get_label_extent(): number {
    const major_labels = this.tick_info().labels.major

    let label_extent: number
    if (this.model.color_mapper.low != null && this.model.color_mapper.high != null && !isEmpty(major_labels)) {
      const {ctx} = this.plot_view.canvas_view
      ctx.save()
      this.visuals.major_label_text.set_value(ctx)
      switch (this.model.orientation) {
        case "vertical":
          label_extent = max((major_labels.map((label) => ctx.measureText(label.toString()).width)))
          break
        case "horizontal":
          label_extent = text_util.measure_font(this.visuals.major_label_text.font_value()).height
          break
        default:
          throw new Error("unreachable code")
      }

      label_extent += this.model.label_standoff
      ctx.restore()
    } else
      label_extent = 0

    return label_extent
  }
開發者ID:jsignell,項目名稱:bokeh,代碼行數:26,代碼來源:color_bar.ts


注:本文中的core/util/object.isEmpty函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。