当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript array.concat函数代码示例

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


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

示例1: _set_data

  protected _set_data(indices: number[] | null): void {
    this._set_width_heigh_data()

    for (let i = 0, end = this._image.length; i < end; i++) {
      if (indices != null && indices.indexOf(i) < 0)
        continue

      let buf: ArrayBuffer
      if (this._image_shape != null && this._image_shape[i].length > 0) {
        buf = (this._image[i] as TypedArray).buffer
        const shape = this._image_shape[i]
        this._height[i] = shape[0]
        this._width[i] = shape[1]
      } else {
        const _image = this._image[i] as number[][]
        const flat = concat(_image)
        buf = new ArrayBuffer(flat.length * 4)
        const color = new Uint32Array(buf)
        for (let j = 0, endj = flat.length; j < endj; j++) {
          color[j] = flat[j]
        }
        this._height[i] = _image.length
        this._width[i] = _image[0].length
      }

      const buf8 = new Uint8Array(buf)
      this._set_image_data_from_buffer(i, buf8)

    }
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:30,代码来源:image_rgba.ts

示例2: get_ticks_no_defaults

  get_ticks_no_defaults(data_low: number, data_high: number, _cross_loc: any, _desired_n_ticks: number): TickSpec<number> {
    const month_dates = date_range_by_month(data_low, data_high)

    const days = this.days
    const days_of_month = (month_date: Date, interval: number) => {
      const dates = []
      for (const day of days) {
        const day_date = copy_date(month_date)
        day_date.setUTCDate(day)
        // We can't use all of the values in this.days, because they may not
        // fall within the current month.  In fact, if, e.g., our month is 28 days
        // and we're marking every third day, we don't want day 28 to show up
        // because it'll be right next to the 1st of the next month.  So we
        // make sure we have a bit of room before we include a day.
        const future_date = new Date(day_date.getTime() + (interval / 2))
        if (future_date.getUTCMonth() == month_date.getUTCMonth())
          dates.push(day_date)
      }
      return dates
    }

    const interval = this.interval
    const day_dates = concat(month_dates.map((date) => days_of_month(date, interval)))

    const all_ticks = day_dates.map((day_date) => day_date.getTime())
    // FIXME Since the ticks are sorted, this could be done more efficiently.
    const ticks_in_range = all_ticks.filter((tick) => data_low <= tick && tick <= data_high)

    return {
      major: ticks_in_range,
      minor: [],
    }
  }
开发者ID:gully,项目名称:bokeh,代码行数:33,代码来源:days_ticker.ts

示例3: it

  it("match between Python and bokehjs", () => {
    let fail_count = 0
    const all_view_model_names = concat([core_defaults.all_view_model_names(), widget_defaults.all_view_model_names()])
    for (const name of all_view_model_names) {
      const model = Models(name)
      const instance = new model({}, {silent: true, defer_initialization: true})
      const attrs = instance.attributes_as_json(true, deep_value_to_json)
      strip_ids(attrs)

      const python_defaults = get_defaults(name)
      const bokehjs_defaults = attrs
      if (!check_matching_defaults(name, python_defaults, bokehjs_defaults)) {
        console.log(name)
        // console.log('python defaults:')
        // console.log(python_defaults)
        // console.log('bokehjs defaults:')
        // console.log(bokehjs_defaults)
        console.log(difference(keys(python_defaults), keys(bokehjs_defaults)))
        fail_count += 1
      }
    }

    console.error(`Python/bokehjs matching defaults problems: ${fail_count}`)
    expect(fail_count).to.equal(0)
  })
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:25,代码来源:defaults.ts

示例4: _set_data

  protected _set_data(indices: number[] | null): void {
    if (this.image_data == null || this.image_data.length != this._image.length)
      this.image_data = new Array(this._image.length)

    if (this._width == null || this._width.length != this._image.length)
      this._width = new Array(this._image.length)

    if (this._height == null || this._height.length != this._image.length)
      this._height = new Array(this._image.length)

    for (let i = 0, end = this._image.length; i < end; i++) {
      if (indices != null && indices.indexOf(i) < 0)
        continue

      let buf: ArrayBuffer
      if (this._image_shape != null && this._image_shape[i].length > 0) {
        buf = (this._image[i] as TypedArray).buffer
        const shape = this._image_shape[i]
        this._height[i] = shape[0]
        this._width[i] = shape[1]
      } else {
        const _image = this._image[i] as number[][]
        const flat = concat(_image)
        buf = new ArrayBuffer(flat.length * 4)
        const color = new Uint32Array(buf)
        for (let j = 0, endj = flat.length; j < endj; j++) {
          color[j] = flat[j]
        }
        this._height[i] = _image.length
        this._width[i] = _image[0].length
      }

      const _image_data = this.image_data[i]
      let canvas: HTMLCanvasElement
      if (_image_data != null && _image_data.width == this._width[i] &&
                                 _image_data.height == this._height[i])
        canvas = _image_data
      else {
        canvas = document.createElement('canvas')
        canvas.width = this._width[i]
        canvas.height = this._height[i]
      }

      const ctx = canvas.getContext('2d')!
      const image_data = ctx.getImageData(0, 0, this._width[i], this._height[i])
      const buf8 = new Uint8Array(buf)
      image_data.data.set(buf8)
      ctx.putImageData(image_data, 0, 0)
      this.image_data[i] = canvas

      this.max_dw = 0
      if (this.model.properties.dw.units == "data")
        this.max_dw = max(this._dw)

      this.max_dh = 0
      if (this.model.properties.dh.units == "data")
        this.max_dh = max(this._dh)
    }
  }
开发者ID:jsignell,项目名称:bokeh,代码行数:59,代码来源:image_rgba.ts

示例5: _get_side_constraints

 private _get_side_constraints(): Constraint[] {
   const panels = (objs: Renderer[]) => objs.map((obj: any) => obj.panel)
   const above = vstack(this.above_panel,          panels(this.plot.above))
   const below = vstack(this.below_panel, reversed(panels(this.plot.below)))
   const left  = hstack(this.left_panel,           panels(this.plot.left))
   const right = hstack(this.right_panel, reversed(panels(this.plot.right)))
   return concat([above, below, left, right])
 }
开发者ID:gully,项目名称:bokeh,代码行数:8,代码来源:plot_canvas.ts

示例6: _set_data

  _set_data() {
    if ((this.image_data == null) || (this.image_data.length !== this._image.length)) {
      this.image_data = new Array(this._image.length);
    }

    if ((this._width == null) || (this._width.length !== this._image.length)) {
      this._width = new Array(this._image.length);
    }

    if ((this._height == null) || (this._height.length !== this._image.length)) {
      this._height = new Array(this._image.length);
    }

    for (let i = 0, end = this._image.length; i < end; i++) {
      let canvas, img;
      let shape = [];
      if (this._image_shape != null) {
        shape = this._image_shape[i];
      }

      if (shape.length > 0) {
        img = this._image[i];
        this._height[i] = shape[0];
        this._width[i] = shape[1];
      } else {
        img = concat(this._image[i]);
        this._height[i] = this._image[i].length;
        this._width[i] = this._image[i][0].length;
      }

      if ((this.image_data[i] != null) && (this.image_data[i].width === this._width[i]) && (this.image_data[i].height === this._height[i])) {
        canvas = this.image_data[i];
      } else {
        canvas = document.createElement('canvas');
        canvas.width = this._width[i];
        canvas.height = this._height[i];
      }

      const ctx = canvas.getContext('2d');
      const image_data = ctx.getImageData(0, 0, this._width[i], this._height[i]);
      const cmap = this.model.color_mapper;
      const buf = cmap.v_map_screen(img, true);
      const buf8 = new Uint8Array(buf);
      image_data.data.set(buf8);
      ctx.putImageData(image_data, 0, 0);
      this.image_data[i] = canvas;

      this.max_dw = 0;
      if (this._dw.units === "data") {
        this.max_dw = max(this._dw);
      }
      this.max_dh = 0;
      if (this._dh.units === "data") {
        this.max_dh = max(this._dh);
      }
    }
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:57,代码来源:image.ts

示例7: _set_data

  protected _set_data(): void {
    if (this.image_data == null || this.image_data.length != this._image.length)
      this.image_data = new Array(this._image.length)

    if (this._width == null || this._width.length != this._image.length)
      this._width = new Array(this._image.length)

    if (this._height == null || this._height.length != this._image.length)
      this._height = new Array(this._image.length)

    const cmap = this.model.color_mapper.rgba_mapper

    for (let i = 0, end = this._image.length; i < end; i++) {
      let img: Arrayable<number>
      if (this._image_shape != null && this._image_shape[i].length > 0) {
        img = this._image[i] as Arrayable<number>
        const shape = this._image_shape[i]
        this._height[i] = shape[0]
        this._width[i] = shape[1]
      } else {
        const _image = this._image[i] as number[][]
        img = concat(_image)
        this._height[i] = _image.length
        this._width[i] = _image[0].length
      }

      const _image_data = this.image_data[i]
      let canvas: HTMLCanvasElement
      if (_image_data != null && _image_data.width == this._width[i] &&
                                 _image_data.height == this._height[i])
        canvas = _image_data
      else {
        canvas = document.createElement('canvas')
        canvas.width = this._width[i]
        canvas.height = this._height[i]
      }

      const ctx = canvas.getContext('2d')!
      const image_data = ctx.getImageData(0, 0, this._width[i], this._height[i])
      const buf8 = cmap.v_compute(img)
      image_data.data.set(buf8)
      ctx.putImageData(image_data, 0, 0)
      this.image_data[i] = canvas

      this.max_dw = 0
      if (this.model.properties.dw.units == "data")
        this.max_dw = max(this._dw)

      this.max_dh = 0
      if (this.model.properties.dh.units == "data")
        this.max_dh = max(this._dh)
    }
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:53,代码来源:image.ts

示例8: get_ticks_no_defaults

  get_ticks_no_defaults(data_low: number, data_high: number, _cross_loc: any, _desired_n_ticks: number): TickSpec<number> {
    const year_dates = date_range_by_year(data_low, data_high)

    const months = this.months
    const months_of_year = (year_date: Date) => {
      return months.map((month) => {
        const month_date = copy_date(year_date)
        month_date.setUTCMonth(month)
        return month_date
      })
    }

    const month_dates = concat(year_dates.map(months_of_year))

    const all_ticks = month_dates.map((month_date) => month_date.getTime())
    const ticks_in_range = all_ticks.filter((tick) => data_low <= tick && tick <= data_high)

    return {
      major: ticks_in_range,
      minor: [],
    }
  }
开发者ID:gully,项目名称:bokeh,代码行数:22,代码来源:months_ticker.ts

示例9: _set_data

  protected _set_data(): void {
    this._set_width_heigh_data()

    const cmap = this.model.color_mapper.rgba_mapper

    for (let i = 0, end = this._image.length; i < end; i++) {
      let img: Arrayable<number>
      if (this._image_shape != null && this._image_shape[i].length > 0) {
        img = this._image[i] as Arrayable<number>
        const shape = this._image_shape[i]
        this._height[i] = shape[0]
        this._width[i] = shape[1]
      } else {
        const _image = this._image[i] as number[][]
        img = concat(_image)
        this._height[i] = _image.length
        this._width[i] = _image[0].length
      }

      const buf8 = cmap.v_compute(img)
      this._set_image_data_from_buffer(i, buf8)

    }
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:24,代码来源:image.ts


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