MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / setKey

Function setKey

chapter18/docs/d3-graphviz.js:1015–1043  ·  view source on GitHub ↗
(datum, index)

Source from the content-addressed store, hash-verified

1013 var nodeDictionary = {};
1014 var prevNodeDictionary = this._nodeDictionary || {};
1015 function setKey(datum, index) {
1016 var tag = datum.tag;
1017 if (keyMode == 'index') {
1018 datum.key = index;
1019 } else if (tag[0] != '#') {
1020 if (keyMode == 'id') {
1021 datum.key = datum.attributes.id;
1022 } else if (keyMode == 'title') {
1023 var title = datum.children.find(function (childData) {
1024 return childData.tag == 'title';
1025 });
1026 if (title) {
1027 if (title.children.length > 0) {
1028 datum.key = title.children[0].text;
1029 } else {
1030 datum.key = '';
1031 }
1032 }
1033 }
1034 }
1035 if (datum.key == null) {
1036 if (tweenShapes) {
1037 if (tag == 'ellipse' || tag == 'polygon') {
1038 tag = 'path';
1039 }
1040 }
1041 datum.key = tag + '-' + index;
1042 }
1043 }
1044 function setId(datum, parentData) {
1045 var id = (parentData ? parentData.id + '.' : '') + datum.key;
1046 datum.id = id;

Callers 1

Calls 1

findMethod · 0.45

Tested by

no test coverage detected