Skip to content

Commit e397839

Browse files
committed
up
1 parent a362b92 commit e397839

File tree

1,928 files changed

+447027
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,928 files changed

+447027
-69
lines changed

Dymatrix3D/src/data/corpus_ner_geo.tsv

Lines changed: 90812 additions & 0 deletions
Large diffs are not rendered by default.

Dymatrix3D/src/js/dynamicnet3D_webworker.js

Lines changed: 97 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ let DynamicNet3D = function () {
105105
// isneedrender = true;
106106
// }
107107
// },
108+
forceType: {
109+
text: "Order by Force",
110+
type: "checkbox",
111+
variable: 'usingForce',
112+
values: false,
113+
width: '100px',
114+
callback: () => {
115+
start();
116+
}
117+
},
108118
showLineConnect: {
109119
text: "Show timelines",
110120
type: "checkbox",
@@ -140,29 +150,15 @@ let DynamicNet3D = function () {
140150
isneedrender = true;
141151
}
142152
},
143-
filterLine: {
144-
text: `Link period ≥ <span class='Link_period'>${graphicopt.filterLine}</span>`,
145-
range: [1, 10],
146-
id: 'Link_period',
147-
type: "slider",
148-
variableRoot: graphicopt,
149-
variable: 'filterLine',
153+
labelMarker: {
154+
text: "Show Labels",
155+
type: "checkbox",
156+
variable: 'label_enable',
157+
values: true,
150158
width: '100px',
151-
step: 1,
152-
callback: ()=>{
153-
d3.select('.Link_period').text(graphicopt.filterLine);
154-
onFilterLine();
155-
}
159+
callback: ()=>{svg.select('#modelNodeLabel').selectAll('.name').remove();
160+
updatelabelCluster();}
156161
},
157-
// labelMarker: {
158-
// text: "Show Labels",
159-
// type: "checkbox",
160-
// variableRoot: graphicopt.component.label,
161-
// variable: 'label_enable',
162-
// values: true,
163-
// width: '100px',
164-
// callback: updatelabelCluster
165-
// },
166162
// linkConnect: {
167163
// text: "Link type",
168164
// type: "selection",
@@ -214,6 +210,7 @@ let DynamicNet3D = function () {
214210
}
215211
},
216212
connectType: {
213+
content:'graphic',
217214
text: "Connection Type",
218215
type: "selection",
219216
variable: 'connectType',
@@ -228,6 +225,21 @@ let DynamicNet3D = function () {
228225

229226
onFilterLine();
230227
}
228+
},
229+
filterLine: {
230+
content:'graphic',
231+
text: `Link period ≥ <span class='Link_period'>${graphicopt.filterLine}</span>`,
232+
range: [1, 10],
233+
id: 'Link_period',
234+
type: "slider",
235+
variableRoot: graphicopt,
236+
variable: 'filterLine',
237+
width: '100px',
238+
step: 1,
239+
callback: ()=>{
240+
d3.select('.Link_period').text(graphicopt.filterLine);
241+
onFilterLine();
242+
}
231243
}
232244
},
233245
formatTable = {
@@ -261,7 +273,7 @@ let DynamicNet3D = function () {
261273
runopt = {},
262274
isBusy = false,
263275
stop = false;
264-
let xScale,yScale, colorscale, reset;
276+
let xScale,yScale, rScale, reset;
265277
let solution, datain = [], filterbyClustername = [], visibledata, table_info, path, cluster = [], scaleTime;
266278
let scaleNormalTimestep = d3.scaleLinear();
267279
// grahic
@@ -423,8 +435,10 @@ let DynamicNet3D = function () {
423435
// reduceRenderWeight();
424436
mouseoverTrigger = false;
425437
// terminateWorker();
426-
updateProcess({percentage: 10, text: 'Transfer data to projection function'})
427-
forceFunc(data.net,(data) => {
438+
updateProcess({percentage: 10, text: 'Transfer data to projection function'});
439+
440+
if (graphicopt.usingForce){
441+
forceFunc(data,(data) => {
428442
switch (data.action) {
429443
case "stable":
430444
debugger
@@ -458,10 +472,11 @@ let DynamicNet3D = function () {
458472
break;
459473
}
460474
})
461-
// updateProcess();
462-
// isneedCompute = true;
463-
// // render(true);
464-
// onFilterLine();
475+
}else{
476+
updateProcess();
477+
isneedCompute = true;
478+
// render(true);
479+
onFilterLine();}
465480
}
466481

467482
let controll_metrics = {old: {zoom: undefined}};
@@ -911,8 +926,9 @@ let DynamicNet3D = function () {
911926
colors[i * 3 + 2] = color.b / 255;
912927
alpha[i] = target.filterd ? graphicopt.component.dot.filter.opacity : graphicopt.component.dot.opacity;
913928
_alpha[i] = (target.color || colorIn)?graphicopt.component.dot.opacity:0;
914-
texIndex[i] = mapType[target.type];
915-
sizes[i] = (graphicopt.component.dot[target.type] ?? graphicopt.component.dot).size;
929+
texIndex[i] = mapType[target.type]??0;
930+
// sizes[i] = (graphicopt.component.dot[target.type] ?? graphicopt.component.dot).size;
931+
sizes[i] = rScale(target.value);
916932
}
917933
pointsGeometry.setAttribute('position', new THREE.BufferAttribute(pos, 3));
918934
pointsGeometry.setAttribute('customColor', new THREE.BufferAttribute(colors, 3));
@@ -964,9 +980,9 @@ let DynamicNet3D = function () {
964980
}
965981

966982
function updatelabelCluster() {
967-
svg.select('#modelNodeLabel').selectAll('.name').remove();
968-
if (dynamicVizs[0]) {
969-
if (graphicopt.label_enable) {
983+
if (graphicopt.label_enable){
984+
svg.select('#modelNodeLabel').selectAll('.name').remove();
985+
if (dynamicVizs[0]) {
970986
let orient = ({
971987
top: text => text.attr("text-anchor", "middle").attr("y", -3),
972988
right: text => text.attr("text-anchor", "start").attr("dy", "0.35em").attr("x", 3),
@@ -1355,11 +1371,11 @@ let DynamicNet3D = function () {
13551371
var frustum = new THREE.Frustum();
13561372
frustum.setFromMatrix(new THREE.Matrix4().multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse));
13571373
dynamicVizs.forEach((net, ni) => {
1358-
net.nodes._alpha.forEach((d, i) => {
1374+
net.nodes.geometry.attributes.alpha.array.forEach((d, i) => {
13591375
if (d > 0.1) {
1360-
data.net[ni].links[i].inscreen = frustum.containsPoint(new THREE.Vector3(net.nodes.geometry.attributes.position.array[i * 3], net.nodes.geometry.attributes.position.array[i * 3 + 1], net.nodes.geometry.attributes.position.array[i * 3 + 2]))
1376+
net.nodes.data.arr[i].inscreen = frustum.containsPoint(new THREE.Vector3(net.nodes.geometry.attributes.position.array[i * 3], net.nodes.geometry.attributes.position.array[i * 3 + 1], net.nodes.geometry.attributes.position.array[i * 3 + 2]))
13611377
} else {
1362-
data.net[ni].links[i].inscreen = false;
1378+
net.nodes.data.arr[i].inscreen = false;
13631379
}
13641380
})
13651381
});
@@ -1494,7 +1510,7 @@ let DynamicNet3D = function () {
14941510
// }
14951511
// });
14961512

1497-
// updatelabelCluster();
1513+
updatelabelCluster();
14981514

14991515
// console.log(controll_metrics.zoom)
15001516
if (iscameraMove || onrendercalled) {
@@ -1567,7 +1583,10 @@ let DynamicNet3D = function () {
15671583

15681584
xScale = d3.scaleBand().domain(type1List.map(d=>d.id)).range([-(bandwidth*type1List.length)/2,(bandwidth*type1List.length)/2]);
15691585
yScale = d3.scalePoint().domain(type2List.map(d=>d.id)).range([(bandwidth*type2List.length)/2,-(bandwidth*type2List.length)/2]);
1586+
rScale = d3.scaleSqrt().domain([d3.min(data.net,n=>d3.min(n.links,d=>d.value)),d3.max(data.net,n=>d3.max(n.links,d=>d.value))]).range([3,25]);
1587+
15701588
dynamicVizs.links = {};
1589+
15711590
data.net.forEach((net, ni) => {
15721591
// time slice generate
15731592
net.links.forEach(l=>{
@@ -1684,21 +1703,35 @@ let DynamicNet3D = function () {
16841703
],
16851704
[
16861705
{text: "Output", type: "title"},
1706+
],
1707+
[
1708+
{text: "Graphic", type: "title"},
16871709
]
16881710
];
16891711
d3.values(self.controlPanel).forEach(d => {
16901712
tableData[1].push({label: d.text, type: d.type, content: d, variable: d.variable, class: d.class})
16911713
});
16921714
d3.values(controlPanelGeneral).forEach(d => {
1693-
tableData[1].push({
1694-
label: d.text,
1695-
type: d.type,
1696-
content: d,
1697-
variable: d.variable,
1698-
variableRoot: d.variableRoot,
1699-
id: d.id,
1700-
class: d.class
1701-
})
1715+
if (d.content==='graphic'){
1716+
tableData[3].push({
1717+
label: d.text,
1718+
type: d.type,
1719+
content: d,
1720+
variable: d.variable,
1721+
variableRoot: d.variableRoot,
1722+
id: d.id,
1723+
class: d.class
1724+
})
1725+
}else
1726+
tableData[1].push({
1727+
label: d.text,
1728+
type: d.type,
1729+
content: d,
1730+
variable: d.variable,
1731+
variableRoot: d.variableRoot,
1732+
id: d.id,
1733+
class: d.class
1734+
})
17021735
});
17031736
d3.keys(self.formatTable).forEach(k => formatTable[k] = self.formatTable[k]);
17041737
tableData[2] = [...tableData[2], ...self.outputSelection];
@@ -2082,30 +2115,25 @@ function forceFunc(data,postMessage) {
20822115
postMessage({action: 'message', value: {'percentage': 20, 'message': 'Data received. Process data...'}});
20832116
totalTime_marker = performance.now();
20842117

2085-
const net = data;
2086-
const root_nodes = {};
2118+
const net = data.net;
2119+
const root_nodes = data.root_nodes;
2120+
root_nodes.forEach(d=>{
2121+
delete d.x;
2122+
delete d.vx;
2123+
delete d.y;
2124+
delete d.vy;
2125+
d.fy =0;
2126+
});
20872127
const linksObjs={};
20882128
if (net.length) {
20892129
net.forEach(function (n, ni) {
2090-
const nodes = n.nodes;
2091-
if (ni) {
2092-
nodes.forEach(n => {
2093-
root_nodes[n.id] = n.parent;
2094-
delete n.parent.x;
2095-
delete n.parent.vx;
2096-
delete n.parent.y;
2097-
delete n.parent.vy;
2098-
})
2099-
} else {
2100-
nodes.forEach(n => {
2101-
root_nodes[n.id] = n.parent;
2102-
n.parent.fy=0;
2103-
});
2104-
}
2105-
n.links.forEach(l=>{
2106-
linksObjs[l.source+l.target] = {source: root_nodes[l.source],
2107-
target: root_nodes[l.target]};
2108-
});
2130+
n.links.forEach(l=> {
2131+
if (!linksObjs[l.source + l.target])
2132+
linksObjs[l.source + l.target] = {
2133+
source: l.source,
2134+
target: l.target
2135+
};
2136+
})
21092137
});
21102138

21112139

@@ -2127,6 +2155,8 @@ function forceFunc(data,postMessage) {
21272155
});
21282156
});
21292157

2158+
console.log('#nodes ',nodes.length);
2159+
console.log('#nodes ',Object.values(linksObjs).length);
21302160
force.nodes(nodes);
21312161
force.force("link").links(Object.values(linksObjs));
21322162
} else {

0 commit comments

Comments
 (0)