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


TypeScript Plot.add_tools方法代碼示例

本文整理匯總了TypeScript中models/plots/plot.Plot.add_tools方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Plot.add_tools方法的具體用法?TypeScript Plot.add_tools怎麽用?TypeScript Plot.add_tools使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models/plots/plot.Plot的用法示例。


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

示例1: function

const make_testcase = function(): BoxEditTestCase {
  // Note default plot dimensions is 600 x 600 (height x width)
  const plot = new Plot({
    x_range: new Range1d({start: -1, end: 1}),
    y_range: new Range1d({start: -1, end: 1}),
  });

  const plot_view: any = new plot.default_view({model: plot, parent: null});
  plot_view.layout();

  const plot_canvas_view = plot_view.plot_canvas_view;

  const data = {
    x: [0, 0.5, 1],
    y: [0, 0.5, 1],
    width: [0.1, 0.2, 0.3],
    height: [0.3, 0.2, 0.1],
    z: [null, null, null],
  };
  const data_source = new ColumnDataSource({data: data});

  const glyph = new Rect({
    x: {field: "x"},
    y: {field: "y"},
    width: {field: "width"},
    height: {field: "height"},
  });

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

  // Untyped to access GlyphView
  const glyph_renderer_view: any = new glyph_renderer.default_view({
    model: glyph_renderer,
    plot_view: plot_canvas_view,
    parent: plot_canvas_view,
  });

  const draw_tool = new BoxEditTool({
    active: true,
    renderers: [glyph_renderer],
    empty_value: "Test",
  });
  plot.add_tools(draw_tool);
  const draw_tool_view = plot_canvas_view.tool_views[draw_tool.id];
  plot_canvas_view.renderer_views[glyph_renderer.id] = glyph_renderer_view;

  return {
    data: data,
    data_source: data_source,
    draw_tool_view: draw_tool_view,
    glyph_view: glyph_renderer_view.glyph,
  }
}
開發者ID:Zyell,項目名稱:bokeh,代碼行數:56,代碼來源:box_edit_tool.ts

示例2: 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

示例3: function

const make_testcase = function(): PolyDrawTestCase {
  // Note default plot dimensions is 600 x 600 (height x width)
  const plot = new Plot({
    x_range: new Range1d({start: -1, end: 1}),
    y_range: new Range1d({start: -1, end: 1}),
  });

  const plot_view: any = new plot.default_view({model: plot, parent: null});
  plot_view.layout();

  const plot_canvas_view = plot_view.plot_canvas_view;

  const data = {
    xs: [[0, 0.5, 1], [0, 0.5, 1]],
    ys: [[0, -0.5, -1], [0, -0.5, -1]],
    z: [null, null],
  };
  const data_source = new ColumnDataSource({data: data});

  const glyph = new Patches({
    xs: {field: "xs"},
    ys: {field: "ys"},
  });

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

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

  const draw_tool = new PolyDrawTool({
    active: true,
    empty_value: "Test",
    renderers: [glyph_renderer],
  });
  plot.add_tools(draw_tool);
  const draw_tool_view = plot_canvas_view.tool_views[draw_tool.id];
  plot_canvas_view.renderer_views[glyph_renderer.id] = glyph_renderer_view;
  sinon.stub(glyph_renderer_view, "set_data");

  return {
    data: data,
    data_source: data_source,
    draw_tool_view: draw_tool_view,
    glyph_view: glyph_renderer_view.glyph,
  }
}
開發者ID:Zyell,項目名稱:bokeh,代碼行數:52,代碼來源:poly_draw_tool.ts

示例4: function

const make_testcase = function(): PointDrawTestCase {
  // Note default plot dimensions is 600 x 600 (height x width)
  const plot = new Plot({
    x_range: new Range1d({start: -1, end: 1}),
    y_range: new Range1d({start: -1, end: 1}),
  })

  const plot_view: any = new plot.default_view({model: plot, parent: null}).build()

  const data = {x: [0, 0.5, 1], y: [0, 0.5, 1], z: [null, null, null]}
  const data_source = new ColumnDataSource({data})

  const glyph = new Circle({
    x: {field: "x"},
    y: {field: "y"},
    size: {units: "screen", value: 20},
  })

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

  // Untyped to access GlyphView
  const glyph_renderer_view: any = new glyph_renderer.default_view({
    model: glyph_renderer,
    parent: plot_view,
  })

  const draw_tool = new PointDrawTool({
    renderers: [glyph_renderer],
    active: true,
    empty_value: "Test",
  })
  plot.add_tools(draw_tool)
  const draw_tool_view = plot_view.tool_views[draw_tool.id]
  plot_view.renderer_views[glyph_renderer.id] = glyph_renderer_view

  return {
    data,
    data_source,
    draw_tool_view,
    glyph_view: glyph_renderer_view.glyph,
  }
}
開發者ID:jsignell,項目名稱:bokeh,代碼行數:42,代碼來源:point_draw_tool.ts

示例5: function

const make_testcase = function(): PolyEditTestCase {
  // Note default plot dimensions is 600 x 600 (height x width)
  const plot = new Plot({
    x_range: new Range1d({start: -1, end: 1}),
    y_range: new Range1d({start: -1, end: 1}),
  })

  const plot_view: any = new plot.default_view({model: plot, parent: null}).build()

  const data = {
    xs: [[0, 0.5, 1], [0, 0.5, 1]],
    ys: [[0, -0.5, -1], [0, -0.5, -1]],
    z: [null, null],
  }
  const data_source = new ColumnDataSource({data})
  const vertex_source = new ColumnDataSource({data: {x: [], y: []}})

  const vertex_glyph = new Circle({
    x: {field: "x"},
    y: {field: "y"},
  })
  const glyph = new Patches({
    xs: {field: "xs"},
    ys: {field: "ys"},
  })

  const vertex_renderer: any = new GlyphRenderer({
    glyph: vertex_glyph,
    data_source: vertex_source,
  })

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

  // Untyped to access GlyphView
  const glyph_renderer_view: any = new glyph_renderer.default_view({
    model: glyph_renderer,
    parent: plot_view,
  })
  sinon.stub(glyph_renderer_view, "set_data")

  // Untyped to access GlyphView
  const vertex_renderer_view: any = new vertex_renderer.default_view({
    model: vertex_renderer,
    parent: plot_view,
  })

  const draw_tool = new PolyEditTool({
    active: true,
    empty_value: "Test",
    renderers: [glyph_renderer],
    vertex_renderer,
  })
  plot.add_tools(draw_tool)
  const draw_tool_view = plot_view.tool_views[draw_tool.id]
  plot_view.renderer_views[glyph_renderer.id] = glyph_renderer_view
  plot_view.renderer_views[vertex_renderer.id] = vertex_renderer_view

  return {
    data,
    data_source,
    draw_tool_view,
    glyph_view: glyph_renderer_view.glyph,
    glyph_renderer,
    vertex_glyph_view: vertex_renderer_view.glyph,
    vertex_source,
    vertex_renderer,
  }
}
開發者ID:jsignell,項目名稱:bokeh,代碼行數:68,代碼來源:poly_edit_tool.ts


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