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


TypeScript bbox.BBox类代码示例

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


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

示例1: on_hit

  on_hit(sx, sy) {
    let yoffset;
    const { glyph_width } = this.model;
    const { legend_padding } = this;
    const legend_spacing = this.model.spacing;
    const { label_standoff } = this.model;

    let xoffset = (yoffset = legend_padding);

    const legend_bbox = this.compute_legend_bbox();
    const vertical = this.model.orientation === "vertical";

    for (const item of this.model.items) {
      const labels = item.get_labels_list_from_label_prop();

      for (const label of labels) {
        const x1 = legend_bbox.x + xoffset;
        const y1 = legend_bbox.y + yoffset;

        let h: number
        let w: number
        if (vertical)
          [w, h] = [legend_bbox.width-(2*legend_padding), this.max_label_height];
        else
          [w, h] = [this.text_widths[label] + glyph_width + label_standoff, this.max_label_height];

        const bbox = new BBox({x: x1, y: y1, width: w, height: h});

        if (bbox.contains(sx, sy)) {
          switch (this.model.click_policy) {
            case "hide": {
              for (const r of item.renderers)
                r.visible = !r.visible;
              break
            }
            case "mute": {
              for (const r of item.renderers)
                r.muted = !r.muted;
              break;
            }
          }
          return true
        }

        if (vertical) {
          yoffset += this.max_label_height + legend_spacing;
        } else {
          xoffset += this.text_widths[label] + glyph_width + label_standoff + legend_spacing;
        }
      }
    }

    return false;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:54,代码来源:legend.ts

示例2: on_hit

  on_hit(sx: number, sy: number): boolean {
    let yoffset
    const { glyph_width } = this.model
    const { legend_padding } = this
    const legend_spacing = this.model.spacing
    const { label_standoff } = this.model

    let xoffset = (yoffset = legend_padding)

    const legend_bbox = this.compute_legend_bbox()
    const vertical = this.model.orientation == "vertical"

    for (const item of this.model.items) {
      const labels = item.get_labels_list_from_label_prop()

      for (const label of labels) {
        const x1 = legend_bbox.x + xoffset
        const y1 = legend_bbox.y + yoffset + this.title_height

        let w: number, h: number
        if (vertical)
          [w, h] = [legend_bbox.width - 2*legend_padding, this.max_label_height]
        else
          [w, h] = [this.text_widths[label] + glyph_width + label_standoff, this.max_label_height]

        const bbox = new BBox({left: x1, top: y1, width: w, height: h})

        if (bbox.contains(sx, sy)) {
          switch (this.model.click_policy) {
            case "hide": {
              for (const r of item.renderers)
                r.visible = !r.visible
              break
            }
            case "mute": {
              for (const r of item.renderers)
                r.muted = !r.muted
              break
            }
          }
          return true
        }

        if (vertical)
          yoffset += this.max_label_height + legend_spacing
        else
          xoffset += this.text_widths[label] + glyph_width + label_standoff + legend_spacing
      }
    }

    return false
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:52,代码来源:legend.ts


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