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

TypeScript document.Document类代码示例

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

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



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

示例1: it

  it("sets proper document on models added during construction", () => {
    const d = new Document()
    expect(d.roots().length).to.equal(0)
    expect(Object.keys(d._all_models).length).to.equal(0)

    const root1 = new ModelWithConstructTimeChanges()
    // change it so it doesn't match what initialize() does
    root1.foo = 3
    root1.child = null
    d.add_root(root1)

    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 root1_copy = copy.get_model_by_id(root1.id) as ModelWithConstructTimeChanges

    expect(root1.foo).to.equal(3)
    expect(root1.child).to.equal(null)

    // when unpacking the copy, initialize() was supposed to overwrite
    // what we unpacked.
    expect(root1_copy.foo).to.equal(4)
    expect(root1_copy.child).to.be.an.instanceof(AnotherModel)
    expect(root1_copy.document).to.equal(copy)
    expect(root1_copy.child!.document).to.equal(copy)
  })
开发者ID:jsignell,项目名称:bokeh,代码行数:28,代码来源: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:jsignell,项目名称:bokeh,代码行数:35,代码来源:graph_hit_test_policy.ts


示例3: create_glyph_renderer_view

export function create_glyph_renderer_view(glyph: Glyph, data: {[key: string]: Arrayable} = {}): GlyphRendererView {
  /*
   * Requires stubbing the canvas and solver before calling.
   */
  const doc = new Document()
  const plot = new Plot({
    x_range: new Range1d({start: 0, end: 1}),
    y_range: new Range1d({start: 0, end: 1}),
  })
  const plot_view = new plot.default_view({model: plot, parent: null}) as PlotView
  doc.add_root(plot)

  const plot_canvas_view = plot_view.plot_canvas_view
  sinon.stub(plot_canvas_view, "update_constraints")

  const data_source = new ColumnDataSource({data})

  const glyph_renderer = new GlyphRenderer({
    glyph,
    data_source: data_source,
  })

  const glyph_renderer_view = new glyph_renderer.default_view({
    model: glyph_renderer,
    plot_view: plot_canvas_view,
    parent: plot_canvas_view,
  }) as GlyphRendererView

  return glyph_renderer_view
}
开发者ID:,项目名称:,代码行数:30,代码来源:


示例4: 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:jsignell,项目名称:bokeh,代码行数:10,代码来源:zoom_out_tool.ts


示例5: 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:jsignell,项目名称:bokeh,代码行数:12,代码来源:customjs_hover.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript events.ModelChangedEvent类代码示例发布时间:2022-05-25
下一篇:
TypeScript doctrine.type类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap