本文整理汇总了TypeScript中document.Document.add_root方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Document.add_root方法的具体用法?TypeScript Document.add_root怎么用?TypeScript Document.add_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类document.Document
的用法示例。
在下文中一共展示了Document.add_root方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("can have all_models with multiple references", () => {
const d = new Document()
expect(d.roots().length).to.equal(0)
expect(size(d._all_models)).to.equal(0)
const root1 = new SomeModel()
const root2 = new SomeModel()
const child1 = new AnotherModel()
root1.child = child1
root2.child = child1
d.add_root(root1)
d.add_root(root2)
expect(d.roots().length).to.equal(2)
expect(size(d._all_models)).to.equal(3)
root1.child = null
expect(size(d._all_models)).to.equal(3)
root2.child = null
expect(size(d._all_models)).to.equal(2)
root1.child = child1
expect(size(d._all_models)).to.equal(3)
root2.child = child1
expect(size(d._all_models)).to.equal(3)
d.remove_root(root1)
expect(size(d._all_models)).to.equal(2)
d.remove_root(root2)
expect(size(d._all_models)).to.equal(0)
})
示例2: 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
}