2D
//2D
function init() {
dataModel = new ht.DataModel();
g2d = new ht.graph.GraphView(dataModel);
view = g2d.getView();
view.className = 'main';
document.body.appendChild(view);
window.addEventListener('resize', function (e) {
g2d.invalidate();
}, false);
3D
//3D function init() { dataModel = new ht.DataModel(); g3d = new ht.graph3d.Graph3dView(dataModel); view = g3d.getView(); view.className = 'main'; document.body.appendChild(view); window.addEventListener('resize', function (e) { g3d.invalidate(); }, false); // 3D相关其他 g3d.setEye([0, 300, 1000]); //决定眼睛(或Camera)所在位置,默认值为 g3d.getCenter([0, 0, 0]); //getCenter()|setCenter([x, y, z]),决定目标中心点(或Target)所在位置,默认值为[0, 0, 0] g3d.setUp([0, 1, 0]);//getUp()|setUp([x, y, z]),决定摄像头正上方向,该参数一般较少改动,默认值为[0, 1, 0] g3d.setNear(10) // getNear()|setNear(near),决定近端截面位置,默认值为10 g3d.setFar(10000) // getFar()|setFar(far),决定远端截面位置,默认值为10000 g3d.setFovy(Math.PI/4)// getFovy()|setFovy(fovy),fovy决定垂直方向的视觉张角弧度,默认值为Math.PI/4
上面2D 下面3D
//上面2D 下面3D function init() { dataModel = new ht.DataModel(); g2d = new ht.graph.GraphView(dataModel); g3d = new ht.graph3d.Graph3dView(dataModel); //2d 和 3d 切割 mainSplit = new ht.widget.SplitView(g2d, g3d, 'v', 0.5); view = mainSplit.getView(); view.className = 'main'; document.body.appendChild(view); window.addEventListener('resize', function (e) { mainSplit.invalidate(); }, false);