var dataModel = new ht.DataModel(); var graphView = new ht.graph.GraphView(dataModel); var treeView = new ht.widget.TreeView(dataModel); var splitView = new ht.widget.SplitView(treeView, graphView, 'horizontal', .3);
function init() { // Add circle at left bottom corner represented new alarm initTreeIcon();
// Add Group var group = new ht.Group(); group.setExpanded(true); group.setName('Group'); dataModel.add(group);
// Iterate HT default AlarmSeverity, add node with related AlarmSeverity var x = -50, y = 100; ht.AlarmSeverity.each(function (severity) { var node = new ht.Node(); node.setName(severity.name); node.setPosition(x += 100, 100); node.getAlarmState().increaseNewAlarm(severity); group.addChild(node); dataModel.add(node); });
// Expand all tree nodes treeView.expandAll();
// Add spliteView to document body splitView.addToDOM(); }
function initTreeIcon() { ht.Default.getImage('__alarmIcon__').comps.push({ type: 'circle', gradient: 'radial.center', gradientColor: '#FFFFFF', background: { func: function (data) { var severity = data.getAlarmState().getHighestNewAlarmSeverity(); if (severity) { return severity.color; } return null; } }, visible: { func: function (data) { return !!data.getAlarmState().getHighestNewAlarmSeverity(); }, }, rect: [1, 8, 8, 8] }); }
function init(){ var dataModel = new ht.DataModel(); var graphView = new ht.graph.GraphView(dataModel); return graphView; } var obj = cache.obj = init()
obj.layoutHTML = function () { gv.layoutHTML(data, obj, false); } }
/*注意,数据模型需要主动清空dm.clear(),否则场景视图GraphicView多次反序列化加载,只会让 关联的数据模型,dataModel重复追加数据,导致场景视图叠加!!!内存也会持续增加!应用平台更 需要注意这里避免问题出现*/ function clear(){ var graphView = cache.obj graphView.dm().clear() graphView.reset() }