【发布时间】:2016-08-16 03:10:05
【问题描述】:
我想从数据库中获取特定员工的姓名、职位和图片,并使用 Gojs 将其显示在图表中。我是 Gojs 的新手,我只知道静态方面。我不知道该把查询放在哪里。
<script>
var $ = go.GraphObject.make;
var myDiagram =
$(go.Diagram, "myDiagramDiv",
{
initialContentAlignment: go.Spot.Center, // center Diagram contents
"undoManager.isEnabled": true, // enable Ctrl-Z to undo and Ctrl-Y to redo
layout: $(go.TreeLayout, // specify a Diagram.layout that arranges trees
{ angle: 90, layerSpacing: 40 })
});
// the template we defined earlier
myDiagram.nodeTemplate =
$(go.Node, "Vertical",
{ background: "#44CCFF" },
$(go.Picture,
{ margin: 10, width: 100, height: 100, background: "red" },
new go.Binding("source")),
$(go.TextBlock, "Default Text",
{ margin: 12, stroke: "white", font: "bold 13px sans-serif" },
new go.Binding("text", "name")),
$(go.TextBlock, "Default Text",
{ margin: 12, stroke: "white", font: "bold 13px sans-serif" },
new go.Binding("text", "position"))
);
// define a Link template that routes orthogonally, with no arrowhead
myDiagram.linkTemplate =
$(go.Link,
{ routing: go.Link.Orthogonal, corner: 5 },
$(go.Shape, { strokeWidth: 3, stroke: "#555" })); // the link shape
var model = $(go.TreeModel);
model.nodeDataArray =
[
{ key: "1", name: "JAMES BRYAN B. JUVENTUD", position: " (Regional Director)", source: "james.jpg" },
{ key: "2", parent: "1", name: "VERGIL H. MEDIDAS", position: "OIC", source: "vergil.jpg" }
];
myDiagram.model = model;
</script>
【问题讨论】:
-
GoJS 仅提供表示层功能——这通常意味着仅在 Web 浏览器中。在您的机器上本地运行时,您上面显示的代码是否有效? GoJS 库无法知道如何连接到您的组织数据库,也无法知道它使用什么模式。您有责任以一种或另一种方式将数据发送到 Web 浏览器,无论是通过使用某些 Web 服务或 Web API,甚至是由 Web 服务器嵌入到页面中。
-
好的,先生。 @WalterNorthwoods :) 感谢您提供信息。
标签: gojs