本文整理汇总了TypeScript中core/util/arrayable.max函数的典型用法代码示例。如果您正苦于以下问题:TypeScript max函数的具体用法?TypeScript max怎么用?TypeScript max使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了max函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _hit_point
protected _hit_point(geometry: PointGeometry): Selection {
let {sx, sy} = geometry
const x = this.renderer.xscale.invert(sx)
const y = this.renderer.yscale.invert(sy)
const scenter_x = []
for (let i = 0, end = this.sx0.length; i < end; i++) {
scenter_x.push(this.sx0[i] + this.sw[i]/2)
}
const scenter_y = []
for (let i = 0, end = this.sy1.length; i < end; i++) {
scenter_y.push(this.sy1[i] + this.sh[i]/2)
}
const max_x2_ddist = max(this._ddist(0, scenter_x, this.ssemi_diag))
const max_y2_ddist = max(this._ddist(1, scenter_y, this.ssemi_diag))
const x0 = x - max_x2_ddist
const x1 = x + max_x2_ddist
const y0 = y - max_y2_ddist
const y1 = y + max_y2_ddist
const hits = []
const bbox = hittest.validate_bbox_coords([x0, x1], [y0, y1])
for (const i of this.index.indices(bbox)) {
let height_in: boolean, width_in: boolean
if (this._angle[i]) {
const s = Math.sin(-this._angle[i])
const c = Math.cos(-this._angle[i])
const px = c*(sx - this.sx[i]) - s*(sy - this.sy[i]) + this.sx[i]
const py = s*(sx - this.sx[i]) + c*(sy - this.sy[i]) + this.sy[i]
sx = px
sy = py
width_in = Math.abs(this.sx[i] - sx) <= this.sw[i]/2
height_in = Math.abs(this.sy[i] - sy) <= this.sh[i]/2
} else {
width_in = (sx - this.sx0[i] <= this.sw[i]) && (sx - this.sx0[i] >= 0)
height_in = (sy - this.sy1[i] <= this.sh[i]) && (sy - this.sy1[i] >= 0)
}
if (height_in && width_in)
hits.push(i)
}
const result = hittest.create_empty_hit_test_result()
result.indices = hits
return result
}
示例2: min
protected _v_compute<T>(data: Arrayable<number>, values: Arrayable<T>,
palette: Arrayable<T>, colors: {nan_color: T, low_color?: T, high_color?: T}): void {
const {nan_color, low_color, high_color} = colors
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
for (let i = 0, end = data.length; i < end; i++) {
const d = data[i]
// Check NaN
if (isNaN(d)) {
values[i] = nan_color
continue
}
if (d > high) {
values[i] = high_color != null ? high_color : 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[i] = palette[max_key]
continue
}
if (d < low) {
values[i] = low_color != null ? low_color : 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[i] = palette[key]
}
}
示例3: min
protected _v_compute<T>(data: Arrayable<number>, values: Arrayable<T>,
palette: Arrayable<T>, colors: {nan_color: T, low_color?: T, high_color?: T}): void {
const {nan_color, low_color, high_color} = colors
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 norm_factor = 1 / (high - low)
const normed_interval = 1 / palette.length
for (let i = 0, end = data.length; i < end; i++) {
const d = data[i]
if (isNaN(d)) {
values[i] = 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[i] = palette[max_key]
continue
}
const normed_d = (d - low) * norm_factor
const key = Math.floor(normed_d / normed_interval)
if (key < 0)
values[i] = low_color != null ? low_color : palette[0]
else if (key > max_key)
values[i] = high_color != null ? high_color : palette[max_key]
else
values[i] = palette[key]
}
}