當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript document.Document類代碼示例

本文整理匯總了TypeScript中@bokehjs/document.Document的典型用法代碼示例。如果您正苦於以下問題:TypeScript Document類的具體用法?TypeScript Document怎麽用?TypeScript Document使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Document類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it("can have all_models with cycles through lists", () => {
    const d = new Document()
    expect(d.roots().length).to.equal(0)
    expect(size(d._all_models)).to.equal(0)

    const root1 = new SomeModelWithChildren()
    const root2 = new SomeModelWithChildren()
    const child1 = new SomeModelWithChildren()
    root1.children = [child1]
    root2.children = [child1]
    child1.children = [root1]
    d.add_root(root1)
    d.add_root(root2)
    expect(d.roots().length).to.equal(2)
    expect(size(d._all_models)).to.equal(3)

    root1.children = []
    expect(size(d._all_models)).to.equal(3)

    root2.children = []
    expect(size(d._all_models)).to.equal(2)

    root1.children = [child1]
    expect(size(d._all_models)).to.equal(3)
  })
開發者ID:digitalsatori,項目名稱:Bokeh,代碼行數:25,代碼來源:document.ts

示例2: beforeEach

  beforeEach(() => {
    const doc = new Document()

    const plot = new Plot({
       x_range: new Range1d({start: 0, end: 1}),
       y_range: new Range1d({start: 0, end: 1}),
    })
    doc.add_root(plot)
    const plot_view = new plot.default_view({model: plot, parent: null}).build()

    node_source = new ColumnDataSource({
      data: {
        index: [10, 20, 30, 40],
      },
    })
    edge_source = new ColumnDataSource({
      data: {
        start: [10, 10, 30],
        end: [20, 30, 20],
      },
    })
    const node_renderer = new GlyphRenderer({data_source: node_source, glyph: new Circle()})
    const edge_renderer = new GlyphRenderer({data_source: edge_source, glyph: new MultiLine()})

    gr = new GraphRenderer({
      node_renderer,
      edge_renderer,
      layout_provider: new TrivialLayoutProvider(),
    })

    gv = new gr.default_view({model: gr, parent: plot_view}) as GraphRendererView

    node_stub = sinon.stub(gv.node_view.glyph, "hit_test")
    edge_stub = sinon.stub(gv.edge_view.glyph, "hit_test")
  })
開發者ID:digitalsatori,項目名稱:Bokeh,代碼行數:35,代碼來源:graph_hit_test_policy.ts

示例3: mkplot

 function mkplot(tool: Tool): PlotView {
   const plot = new Plot({
     x_range: new Range1d({start: -1, end: 1}),
     y_range: new Range1d({start: -1, end: 1}),
   })
   plot.add_tools(tool)
   const document = new Document()
   document.add_root(plot)
   return new plot.default_view({model: plot, parent: null}).build()
 }
開發者ID:digitalsatori,項目名稱:Bokeh,代碼行數:10,代碼來源:box_zoom_tool.ts

示例4: it

 it("should round-trip through document serialization", () => {
   const d = new Document()
   d.add_root(r)
   const json = d.to_json_string()
   const parsed = JSON.parse(json)
   parsed.version = js_version
   const copy = Document.from_json_string(JSON.stringify(parsed))
   const r_copy = copy.get_model_by_id(r.id)! as CustomJSHover
   const rng_copy = copy.get_model_by_id(rng.id)! as CustomJSHover
   expect(r.values).to.be.deep.equal([rng])
   expect(r_copy.values).to.be.deep.equal([rng_copy])
 })
開發者ID:digitalsatori,項目名稱:Bokeh,代碼行數:12,代碼來源:customjs_hover.ts


注:本文中的@bokehjs/document.Document類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。