本文整理汇总了TypeScript中core/util/array.sum函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sum函数的具体用法?TypeScript sum怎么用?TypeScript sum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sum函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: return
return () => {
const ntabs = this.model.tabs.length
if (dir == "left")
scroll_index = Math.max(scroll_index - 1, 0)
else
scroll_index = Math.min(scroll_index + 1, ntabs - 1)
if (scroll_index == 0)
left_el.setAttribute("disabled", "")
else
left_el.removeAttribute("disabled")
if (scroll_index == ntabs - 1)
right_el.setAttribute("disabled", "")
else
right_el.removeAttribute("disabled")
const sizes = children(this.headers_el)
.slice(0, scroll_index)
.map((el) => el.getBoundingClientRect())
if (vertical) {
const left = -sum(sizes.map((size) => size.width))
this.headers_el.style.left = `${left}px`
} else {
const top = -sum(sizes.map((size) => size.height))
this.headers_el.style.top = `${top}px`
}
}
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:30,代码来源:tabs.ts
示例2: _measure
protected _measure(viewport: Sizeable) {
const min_headers = 3
const scroll = size(scroll_el)
const headers = children(headers_el).slice(0, min_headers).map((el) => size(el))
const {width, height} = super._measure(viewport)
if (vertical) {
const min_width = scroll.width + sum(headers.map((size) => size.width))
return {width: viewport.width != Infinity ? viewport.width : min_width, height}
} else {
const min_height = scroll.height + sum(headers.map((size) => size.height))
return {width, height: viewport.height != Infinity ? viewport.height : min_height}
}
}
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:15,代码来源:tabs.ts
示例3: map_three_levels
export function map_three_levels(factors: L3Factor[],
outer_pad: number, inner_pad: number, factor_pad: number,
offset: number = 0): [L3Mapping, string[], [string, string][], number] {
const mapping: L3Mapping = {}
const tops: {[key: string]: [string, string][]} = {}
const tops_order: string[] = []
for (const [f0, f1, f2] of factors) {
if (!(f0 in tops)) {
tops[f0] = []
tops_order.push(f0)
}
tops[f0].push([f1, f2])
}
const mids_order: [string, string][] = []
let suboffset = offset
let total_subpad = 0
for (const f0 of tops_order) {
const n = tops[f0].length
const [submap, submids_order, subpad] = map_two_levels(tops[f0], inner_pad, factor_pad, suboffset)
for (const f1 of submids_order)
mids_order.push([f0, f1])
total_subpad += subpad
const subtot = sum(tops[f0].map(([f1,]) => submap[f1].value))
mapping[f0] = {value: subtot/n, mapping: submap}
suboffset += n + outer_pad + subpad
}
return [mapping, tops_order, mids_order, (tops_order.length-1)*outer_pad + total_subpad]
}
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:32,代码来源:factor_range.ts
示例4: map_two_levels
export function map_two_levels(factors: L2Factor[],
outer_pad: number, factor_pad: number,
offset: number = 0): [L2Mapping, string[], number] {
const mapping: L2Mapping = {}
const tops: {[key: string]: string[]} = {}
const tops_order: string[] = []
for (const [f0, f1] of factors) {
if (!(f0 in tops)) {
tops[f0] = []
tops_order.push(f0)
}
tops[f0].push(f1)
}
let suboffset = offset
let total_subpad = 0
for (const f0 of tops_order) {
const n = tops[f0].length
const [submap, subpad] = map_one_level(tops[f0], factor_pad, suboffset)
total_subpad += subpad
const subtot = sum(tops[f0].map((f1) => submap[f1].value))
mapping[f0] = {value: subtot/n, mapping: submap}
suboffset += n + outer_pad + subpad
}
return [mapping, tops_order, (tops_order.length-1)*outer_pad + total_subpad]
}
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:28,代码来源:factor_range.ts
示例5: _draw_axis_label
protected _draw_axis_label(ctx: Context2d, extents: Extents, _tick_coords: TickCoords): void {
if (this.model.axis_label == null || this.model.axis_label.length == 0)
return
let sx: number
let sy: number
switch (this.model.panel.side) {
case "above":
sx = this.model.panel._hcenter.value
sy = this.model.panel._bottom.value
break;
case "below":
sx = this.model.panel._hcenter.value
sy = this.model.panel._top.value
break;
case "left":
sx = this.model.panel._right.value
sy = this.model.panel._vcenter.value
break;
case "right":
sx = this.model.panel._left.value
sy = this.model.panel._vcenter.value
break;
default:
throw new Error(`unknown side: ${this.model.panel.side}`)
}
const coords: Coords = [[sx], [sy]]
const standoff = extents.tick + sum(extents.tick_label) + this.model.axis_label_standoff
const visuals = this.visuals.axis_label_text
this._draw_oriented_labels(ctx, [this.model.axis_label], coords, 'parallel', this.model.panel.side, standoff, visuals, "screen")
}
开发者ID:Zyell,项目名称:bokeh,代码行数:34,代码来源:axis.ts
示例6: _tick_label_extent
protected _tick_label_extent(): number {
return sum(this._tick_label_extents())
}
开发者ID:Zyell,项目名称:bokeh,代码行数:3,代码来源:axis.ts
注:本文中的core/util/array.sum函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论