• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript array.sum函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript array.union函数代码示例发布时间:2022-05-24
下一篇:
TypeScript array.sortBy函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap