本文整理汇总了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
}
示例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;
}
示例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
}