當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。