本文整理汇总了TypeScript中core/util/array.min函数的典型用法代码示例。如果您正苦于以下问题:TypeScript min函数的具体用法?TypeScript min怎么用?TypeScript min使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了min函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: _index_data
protected _index_data(): SpatialIndex {
const points = []
for (let i = 0, end = this._xs.length; i < end; i++) {
if (this._xs[i] == null || this._xs[i].length === 0)
continue
const _xsi = this._xs[i]
const xs: number[] = []
for (let j = 0, n = _xsi.length; j < n; j++) {
const x = _xsi[j]
if (!isStrictNaN(x))
xs.push(x)
}
const _ysi = this._ys[i]
const ys: number[] = []
for (let j = 0, n = _ysi.length; j < n; j++) {
const y = _ysi[j]
if (!isStrictNaN(y))
ys.push(y)
}
const [minX, maxX] = [min(xs), max(xs)]
const [minY, maxY] = [min(ys), max(ys)]
points.push({minX, minY, maxX, maxY, i})
}
return new SpatialIndex(points)
}
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:30,代码来源:multi_line.ts
示例2: _index_hole_data
protected _index_hole_data(): SpatialIndex {
// need advice on how to use this sure if this could be more useful
const points = []
for (let i = 0, end = this._xs.length; i < end; i++) {
for (let j = 0, endj = this._xs[i].length; j < endj; j++) {
if (this._xs[i][j].length > 1 ) {
for (let k = 1, endk = this._xs[i][j].length; k < endk; k++) {
const xs = this._xs[i][j][k] // only use holes
const ys = this._ys[i][j][k] // only use holes
if (xs.length == 0)
continue
points.push({
minX: min(xs),
minY: min(ys),
maxX: max(xs),
maxY: max(ys),
i,
})
}
}
}
}
return new SpatialIndex(points)
}
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:26,代码来源:multi_polygons.ts
示例3: _index_data
protected _index_data(): SpatialIndex {
const xss = this._build_discontinuous_object(this._xs as any) // XXX
const yss = this._build_discontinuous_object(this._ys as any) // XXX
const points = []
for (let i = 0, end = this._xs.length; i < end; i++) {
for (let j = 0, endj = xss[i].length; j < endj; j++) {
const xs = xss[i][j]
const ys = yss[i][j]
if (xs.length == 0)
continue
points.push({
minX: min(xs),
minY: min(ys),
maxX: max(xs),
maxY: max(ys),
i,
})
}
}
return new SpatialIndex(points)
}
开发者ID:gully,项目名称:bokeh,代码行数:25,代码来源:patches.ts
示例4: compute
compute(x: number): number {
this.sort(false)
if (this.clip) {
if (x < this._x_sorted[0] || x > this._x_sorted[this._x_sorted.length-1])
return NaN
} else {
if (x < this._x_sorted[0])
return this._y_sorted[0]
if (x > this._x_sorted[this._x_sorted.length-1])
return this._y_sorted[this._y_sorted.length-1]
}
let ind: number
switch (this.mode) {
case "after": {
ind = find_last_index(this._x_sorted, num => x >= num)
break
}
case "before": {
ind = find_index(this._x_sorted, num => x <= num)
break
}
case "center": {
const diffs = this._x_sorted.map((tx) => Math.abs(tx - x))
const mdiff = min(diffs)
ind = find_index(diffs, num => mdiff === num)
break
}
default:
throw new Error(`unknown mode: ${this.mode}`)
}
return ind != -1 ? this._y_sorted[ind] : NaN
}
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:35,代码来源:step_interpolator.ts
示例5: _get_values
_get_values(data: number[], palette: number[], image_glyph: boolean = false): number[] {
const n = palette.length;
const low = this.low != null ? this.low : min(data);
const high = this.high != null ? this.high : max(data);
const scale = n / (log1p(high) - log1p(low)); // subtract the low offset
const max_key = palette.length - 1;
const values = [];
const nan_color = image_glyph ? this._nan_color : this.nan_color;
const high_color = image_glyph ? this._high_color : this.high_color;
const low_color = image_glyph ? this._low_color : this.low_color;
for (const d of data) {
// Check NaN
if (isNaN(d)) {
values.push(nan_color);
continue;
}
if (d > high) {
if (this.high_color != null) {
values.push(high_color);
} else {
values.push(palette[max_key]);
}
continue;
}
// This handles the edge case where d == high, since the code below maps
// values exactly equal to high to palette.length, which is greater than
// max_key
if (d === high) {
values.push(palette[max_key]);
continue;
}
if (d < low) {
if (this.low_color != null) {
values.push(low_color);
} else {
values.push(palette[0]);
}
continue;
}
// Get the key
const log = log1p(d) - log1p(low); // subtract the low offset
let key = Math.floor(log * scale);
// Deal with upper bound
if (key > max_key) {
key = max_key;
}
values.push(palette[key]);
}
return values;
}
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:58,代码来源:log_color_mapper.ts
示例6: _get_dim_limits
// utility function to get limits along both dimensions, given
// optional dimensional constraints
_get_dim_limits([sx0, sy0]: [number, number], [sx1, sy1]: [number, number],
frame: CartesianFrame, dims: Dimensions): [[number, number], [number, number]] {
const hr = frame.bbox.h_range
let sxlim: [number, number]
if (dims == 'width' || dims == 'both') {
sxlim = [min([sx0, sx1]), max([sx0, sx1])]
sxlim = [max([sxlim[0], hr.start]), min([sxlim[1], hr.end])]
} else
sxlim = [hr.start, hr.end]
const vr = frame.bbox.v_range
let sylim: [number, number]
if (dims == 'height' || dims == 'both') {
sylim = [min([sy0, sy1]), max([sy0, sy1])]
sylim = [max([sylim[0], vr.start]), min([sylim[1], vr.end])]
} else
sylim = [vr.start, vr.end]
return [sxlim, sylim]
}
开发者ID:Zyell,项目名称:bokeh,代码行数:23,代码来源:tool.ts
示例7: _index_data
protected _index_data(): SpatialIndex {
const points = []
for (let i = 0, end = this._xs.length; i < end; i++) {
for (let j = 0, endj = this._xs[i].length; j < endj; j++) {
const xs = this._xs[i][j][0] // do not use holes
const ys = this._ys[i][j][0] // do not use holes
if (xs.length == 0)
continue
points.push({
minX: min(xs),
minY: min(ys),
maxX: max(xs),
maxY: max(ys),
i,
})
}
}
this.hole_index = this._index_hole_data() // should this be set here?
return new SpatialIndex(points)
}
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:22,代码来源:multi_polygons.ts
示例8: _index_data
_index_data() {
const xss = this._build_discontinuous_object(this._xs);
const yss = this._build_discontinuous_object(this._ys);
const points = [];
for (let i = 0, end = this._xs.length; i < end; i++) {
for (let j = 0, endj = xss[i].length; j < endj; j++) {
const xs = xss[i][j];
const ys = yss[i][j];
if (xs.length === 0) {
continue;
}
points.push({
minX: min(xs),
minY: min(ys),
maxX: max(xs),
maxY: max(ys),
i,
});
}
}
return new RBush(points);
}
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:24,代码来源:patches.ts
示例9: _get_values
_get_values(data: number[], palette: number[], image_glyph: boolean = false): number[] {
const low = this.low != null ? this.low : min(data);
const high = this.high != null ? this.high : max(data);
const max_key = palette.length - 1;
const values = [];
const nan_color = image_glyph ? this._nan_color : this.nan_color;
const low_color = image_glyph ? this._low_color : this.low_color;
const high_color = image_glyph ? this._high_color : this.high_color;
const norm_factor = 1 / (high - low);
const normed_interval = 1 / palette.length;
for (const d of data) {
if (isNaN(d)) {
values.push(nan_color);
continue;
}
// This handles the edge case where d == high, since the code below maps
// values exactly equal to high to palette.length, which is greater than
// max_key
if (d === high) {
values.push(palette[max_key]);
continue;
}
const normed_d = (d - low) * norm_factor;
const key = Math.floor(normed_d / normed_interval);
if (key < 0) {
if (this.low_color != null) {
values.push(low_color);
} else {
values.push(palette[0]);
}
} else if (key > max_key) {
if (this.high_color != null) {
values.push(high_color);
} else {
values.push(palette[max_key]);
}
} else {
values.push(palette[key]);
}
}
return values;
}
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:47,代码来源:linear_color_mapper.ts
示例10: compute
compute(x) {
// Apply the transform to a single value
let descending, ret;
this.sort(descending = false);
if (this.clip === true) {
if ((x < this._x_sorted[0]) || (x > this._x_sorted[this._x_sorted.length-1])) {
return(null);
}
} else {
if (x < this._x_sorted[0]) {
return this._y_sorted[0];
}
if (x > this._x_sorted[this._x_sorted.length-1]) {
return this._y_sorted[this._y_sorted.length-1];
}
}
let ind = -1;
if (this.mode === "after") {
ind = findLastIndex(this._x_sorted, num => x >= num);
}
if (this.mode === "before") {
ind = findIndex(this._x_sorted, num => x <= num);
}
if (this.mode === "center") {
const diffs = (this._x_sorted.map((tx) => Math.abs(tx - x)));
const mdiff = min(diffs);
ind = findIndex(diffs, num => mdiff === num);
}
if (ind !== -1) {
ret = this._y_sorted[ind];
} else {
ret = null;
}
return(ret);
}
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:41,代码来源:step_interpolator.ts
注:本文中的core/util/array.min函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论