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

TypeScript array.range函数代码示例

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

本文整理汇总了TypeScript中core/util/array.range函数的典型用法代码示例。如果您正苦于以下问题:TypeScript range函数的具体用法?TypeScript range怎么用?TypeScript range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了range函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: get_ticks_no_defaults

  get_ticks_no_defaults(data_low: number, data_high: number, _cross_loc: any, desired_n_ticks: number) {
    const num_minor_ticks = this.num_minor_ticks
    const minor_ticks = []

    const base = this.base

    const log_low = Math.log(data_low) / Math.log(base)
    const log_high = Math.log(data_high) / Math.log(base)
    const log_interval = log_high - log_low

    let ticks: number[]

    if (!isFinite(log_interval)) {
      ticks = []
    } else if (log_interval < 2) { // treat as linear ticker
      const interval = this.get_interval(data_low, data_high, desired_n_ticks)
      const start_factor = Math.floor(data_low / interval)
      const end_factor   = Math.ceil(data_high / interval)

      ticks = range(start_factor, end_factor + 1)
        .filter((factor) => factor != 0)
        .map((factor) => factor*interval)
        .filter((tick) => data_low <= tick && tick <= data_high)

      if (num_minor_ticks > 0 && ticks.length > 0) {
        const minor_interval = interval / num_minor_ticks
        const minor_offsets = range(0, num_minor_ticks).map((i) => i*minor_interval)
        for (const x of minor_offsets.slice(1)) {
          minor_ticks.push(ticks[0] - x)
        }
        for (const tick of ticks) {
          for (const x of minor_offsets) {
            minor_ticks.push(tick + x)
          }
        }
      }
    } else {
      const startlog = Math.ceil(log_low * 0.999999)
      const endlog = Math.floor(log_high * 1.000001)
      const interval = Math.ceil((endlog - startlog) / 9.0)

      ticks = range(startlog, endlog + 1, interval)
        .map((i) => Math.pow(base, i))
        .filter((tick) => data_low <= tick && tick <= data_high)

      if (num_minor_ticks > 0 && ticks.length > 0) {
        const minor_interval = Math.pow(base, interval) / num_minor_ticks
        const minor_offsets = range(1, num_minor_ticks+1).map((i) => i*minor_interval)
        for (const x of minor_offsets) {
          minor_ticks.push(ticks[0] / x)
        }
        minor_ticks.push(ticks[0])
        for (const tick of ticks) {
          for (const x of minor_offsets) {
            minor_ticks.push(tick * x)
          }
        }
      }
    }

    return {
      major: ticks,
      minor: minor_ticks,
    }
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:65,代码来源:log_ticker.ts


示例2: get_indices

 get_indices(): number[] {
   const length = this.get_length()
   return range(0, length != null ? length : 1)
 }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:4,代码来源:columnar_data_source.ts


示例3: _get_new_list_array

 _get_new_list_array(length: number): number[][] {
   return (range(0, length).map((_i) => []))
 }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:3,代码来源:geojson_data_source.ts


示例4: _get_new_nan_array

 _get_new_nan_array(length: number): number[] {
   return (range(0, length).map((_i) => NaN))
 }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:3,代码来源:geojson_data_source.ts


示例5: range

 const values = (c: number) => range(10).map((v) => c*v)
开发者ID:paddymul,项目名称:bokeh,代码行数:1,代码来源:integration.ts


示例6: it

 it("should allow MultiSelect", async () => {
   const options = range(16).map((i) => `Option ${i+1}`)
   const obj = new MultiSelect({options, size: 6})
   await display(obj, [500, 300])
 })
开发者ID:paddymul,项目名称:bokeh,代码行数:5,代码来源:integration.ts


示例7: render

  render(): void {
    if (!this.model.visible)
      return

    const t0 = Date.now()

    const glsupport = this.glyph.glglyph

    this.glyph.map_data()
    const dtmap = Date.now() - t0

    const tmask = Date.now()
    // all_indices is in full data space, indices is converted to subset space
    // either by mask_data (that uses the spatial index) or manually
    let indices = this.glyph.mask_data(this.all_indices)
    if (indices.length === this.all_indices.length) {
      indices = range(0, this.all_indices.length)
    }
    const dtmask = Date.now() - tmask

    const {ctx} = this.plot_view.canvas_view
    ctx.save()

    // selected is in full set space
    const {selected} = this.model.data_source
    let selected_full_indices: number[]
    if (!selected || selected.is_empty()) {
      selected_full_indices = []
    } else {
      if (this.glyph instanceof LineView && selected.selected_glyph === this.glyph.model) {
        selected_full_indices = this.model.view.convert_indices_from_subset(indices)
      } else {
        selected_full_indices = selected.indices
      }
    }

    // inspected is in full set space
    const {inspected} = this.model.data_source
    let inspected_full_indices: number[]
    if (!inspected || (inspected.length === 0)) {
      inspected_full_indices = []
    } else {
      if (inspected['0d'].glyph) {
        inspected_full_indices = this.model.view.convert_indices_from_subset(indices)
      } else if (inspected['1d'].indices.length > 0) {
        inspected_full_indices = inspected['1d'].indices
      } else {
        inspected_full_indices = ((() => {
          const result = []
          for (const i of Object.keys(inspected["2d"].indices)) {
            result.push(parseInt(i))
          }
          return result
        })())
      }
    }

    // inspected is transformed to subset space
    const inspected_subset_indices: number[] = ((() => {
      const result = []
      for (const i of indices) {
        if (includes(inspected_full_indices, this.all_indices[i]))
          result.push(i)
      }
      return result
    })())

    const {lod_threshold} = this.plot_model
    let glyph: GlyphView
    let nonselection_glyph: GlyphView
    let selection_glyph: GlyphView
    if ((this.model.document != null ? this.model.document.interactive_duration() > 0 : false)
        && !glsupport && lod_threshold != null && this.all_indices.length > lod_threshold) {
      // Render decimated during interaction if too many elements and not using GL
      indices = this.decimated
      glyph = this.decimated_glyph
      nonselection_glyph = this.decimated_glyph
      selection_glyph = this.selection_glyph
    } else {
      glyph = this.model.muted && this.muted_glyph != null ? this.muted_glyph : this.glyph
      nonselection_glyph = this.nonselection_glyph
      selection_glyph = this.selection_glyph
    }

    if (this.hover_glyph != null && inspected_subset_indices.length)
      indices = difference(indices, inspected_subset_indices)

    // Render with no selection
    let dtselect: number | null = null
    let trender: number
    if (!(selected_full_indices.length && this.have_selection_glyphs())) {
      trender = Date.now()
      if (this.glyph instanceof LineView) {
        if (this.hover_glyph && inspected_subset_indices.length)
          this.hover_glyph.render(ctx, this.model.view.convert_indices_from_subset(inspected_subset_indices), this.glyph)
        else
          glyph.render(ctx, this.all_indices, this.glyph)
      } else {
        glyph.render(ctx, indices, this.glyph)
        if (this.hover_glyph && inspected_subset_indices.length)
//.........这里部分代码省略.........
开发者ID:jsignell,项目名称:bokeh,代码行数:101,代码来源:glyph_renderer.ts


示例8: initialize

 initialize(): void {
   super.initialize()
   this._resolutions = range(this.min_zoom, this.max_zoom+1).map((z) => this.get_resolution(z))
 }
开发者ID:,项目名称:,代码行数:4,代码来源:


示例9: indices_map_to_subset

 indices_map_to_subset() {
   this.indices_map = {}
   return range(0, this.indices.length).map((i) =>
     (this.indices_map[this.indices[i]] = i))
 }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:5,代码来源:cds_view.ts



注:本文中的core/util/array.range函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript array.removeBy函数代码示例发布时间:2022-05-24
下一篇:
TypeScript array.min函数代码示例发布时间: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