本文整理匯總了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
}