Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
fb15dba9
Commit
fb15dba9
authored
Jun 15, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
harmonize assumption node type 0 points to catSem as default
parent
9f94f18e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
81 additions
and
150 deletions
+81
-150
developer_manual.md
doc/developer_manual.md
+2
-2
explorerjs.html
explorerjs.html
+2
-2
extras_explorerjs.js
extras_explorerjs.js
+3
-3
settings_explorerjs.js
settings_explorerjs.js
+6
-8
Tinaweb.js
tinawebJS/Tinaweb.js
+18
-64
enviroment.js
tinawebJS/enviroment.js
+4
-3
main.js
tinawebJS/main.js
+7
-25
methods.js
tinawebJS/methods.js
+15
-22
sigma.parseCustom.js
tinawebJS/sigma.parseCustom.js
+10
-10
sigmaUtils.js
tinawebJS/sigmaUtils.js
+14
-11
No files found.
doc/developer_manual.md
View file @
fb15dba9
...
@@ -38,8 +38,8 @@ This will still evolve but the main steps for any graph initialization messily u
...
@@ -38,8 +38,8 @@ This will still evolve but the main steps for any graph initialization messily u
#### About source data
#### About source data
-
doc/sem typing: follows the node property "
`type`
" or if absent, "
`category`
"
-
doc/sem typing: follows the node property "
`type`
" or if absent, "
`category`
"
-
if the category name
is "document" => catSoc
(type 0)
-
if the category name
contains the str "term" => catSem
(type 0)
-
if the category name
contains the str "term" => catSem
(type 1)
-
if the category name
is "document" => catSoc
(type 1)
-
`somenode.attributes`
: the
`attributes`
property is always an object
-
`somenode.attributes`
: the
`attributes`
property is always an object
-
any attribute listed in the sourcenode.attributes will be indexed if the TW.scanClusters flag is true
-
any attribute listed in the sourcenode.attributes will be indexed if the TW.scanClusters flag is true
...
...
explorerjs.html
View file @
fb15dba9
...
@@ -201,7 +201,7 @@
...
@@ -201,7 +201,7 @@
</a></li>
</a></li>
<li
class=
"weight-selectors for-nodecategory-0"
>
<li
class=
"weight-selectors for-nodecategory-0"
>
<!-- Create a subgraph over nodes from TW.categories[0] (
doc
s or def nodes)-->
<!-- Create a subgraph over nodes from TW.categories[0] (
term
s or def nodes)-->
<table>
<table>
<tr>
<tr>
<td
class=
"slider-legend"
>
<td
class=
"slider-legend"
>
...
@@ -220,7 +220,7 @@
...
@@ -220,7 +220,7 @@
</table>
</table>
</li>
</li>
<li
class=
"weight-selectors for-nodecategory-1"
>
<li
class=
"weight-selectors for-nodecategory-1"
>
<!-- Create a subgraph over nodes from TW.categories[1] (
terms
)-->
<!-- Create a subgraph over nodes from TW.categories[1] (
docs or people
)-->
<table>
<table>
<tr
class=
"weight-selector"
>
<tr
class=
"weight-selector"
>
<td
class=
"slider-legend"
>
<td
class=
"slider-legend"
>
...
...
extras_explorerjs.js
View file @
fb15dba9
...
@@ -27,7 +27,7 @@ function changeGraphAppearanceByFacets( manualflag ) {
...
@@ -27,7 +27,7 @@ function changeGraphAppearanceByFacets( manualflag ) {
if
(
$
(
"#colorgraph-menu"
).
length
>
0
)
{
if
(
$
(
"#colorgraph-menu"
).
length
>
0
)
{
var
actypes
=
getActivetypes
()
var
actypes
=
getActivetypes
Names
()
for
(
var
tid
in
actypes
)
{
for
(
var
tid
in
actypes
)
{
let
ty
=
actypes
[
tid
]
let
ty
=
actypes
[
tid
]
...
@@ -229,7 +229,7 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
...
@@ -229,7 +229,7 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
$
(
"#legend-for-clusters"
).
html
(
""
)
$
(
"#legend-for-clusters"
).
html
(
""
)
if
(
daclass
==
null
)
return
;
if
(
daclass
==
null
)
return
;
var
actypes
=
getActivetypes
()
var
actypes
=
getActivetypes
Names
()
// we have no specifications yet for colors (and legends) on multiple types
// we have no specifications yet for colors (and legends) on multiple types
if
(
actypes
.
length
>
1
)
{
if
(
actypes
.
length
>
1
)
{
...
@@ -697,7 +697,7 @@ function activateModules() {
...
@@ -697,7 +697,7 @@ function activateModules() {
// NB condition on dataType could be on an extended meta "attrType"
// NB condition on dataType could be on an extended meta "attrType"
// cf. doc/developer_manual.md autodiagnose remark)
// cf. doc/developer_manual.md autodiagnose remark)
function
fillAttrsInForm
(
menuId
,
optionalAttTypeConstraint
)
{
function
fillAttrsInForm
(
menuId
,
optionalAttTypeConstraint
)
{
var
actypes
=
getActivetypes
()
var
actypes
=
getActivetypes
Names
()
for
(
let
tid
in
actypes
)
{
for
(
let
tid
in
actypes
)
{
let
ty
=
actypes
[
tid
]
let
ty
=
actypes
[
tid
]
...
...
settings_explorerjs.js
View file @
fb15dba9
...
@@ -146,13 +146,11 @@ TW.conf = (function(TW){
...
@@ -146,13 +146,11 @@ TW.conf = (function(TW){
// TINA BEHAVIOR
// TINA BEHAVIOR
// =============
// =============
// Node typology (searched in nodes data, overridden if data has other types)
// Node typology: categories (resp. 0 and 1) will get these default labels
TWConf
.
catSem
=
"Terms"
;
// (FIXME cf. comment in sortNodeTypes and swActual functions
// about the limits of how these 2 values and
// TW.categories are used in older functions)
TWConf
.
catSoc
=
"Document"
;
TWConf
.
catSoc
=
"Document"
;
TWConf
.
catSem
=
"NGram"
;
// NB: these labels may be superseded by the input data's node types values
// cf. sortNodeTypes()
// Active modules
// Active modules
// --------------
// --------------
...
@@ -283,8 +281,8 @@ TW.conf = (function(TW){
...
@@ -283,8 +281,8 @@ TW.conf = (function(TW){
// relative sizes (iff ChangeType == both nodetypes)
// relative sizes (iff ChangeType == both nodetypes)
TWConf
.
sizeMult
=
[];
TWConf
.
sizeMult
=
[];
TWConf
.
sizeMult
[
0
]
=
3.0
;
// ie for node type 0
TWConf
.
sizeMult
[
0
]
=
1.0
;
// ie for node type 0 (<=> sem)
TWConf
.
sizeMult
[
1
]
=
1.0
;
// ie for node type 1
TWConf
.
sizeMult
[
1
]
=
3.0
;
// ie for node type 1 (<=> soc)
...
...
tinawebJS/Tinaweb.js
View file @
fb15dba9
...
@@ -371,6 +371,7 @@ var TinaWebJS = function ( sigmacanvas ) {
...
@@ -371,6 +371,7 @@ var TinaWebJS = function ( sigmacanvas ) {
});
});
// register an index for nodes by type and size (<= origNode.size||origNode.weight)
// register an index for nodes by type and size (<= origNode.size||origNode.weight)
// £TODO use it for type-constrained loops
sigmaModule
.
classes
.
graph
.
addIndex
(
'nodesBySize'
,
{
sigmaModule
.
classes
.
graph
.
addIndex
(
'nodesBySize'
,
{
constructor
:
function
()
{
constructor
:
function
()
{
this
.
nodesBySize
=
{};
this
.
nodesBySize
=
{};
...
@@ -384,6 +385,10 @@ var TinaWebJS = function ( sigmacanvas ) {
...
@@ -384,6 +385,10 @@ var TinaWebJS = function ( sigmacanvas ) {
this
.
nodesBySize
[
n
.
type
][
sizekey
]
=
{}
this
.
nodesBySize
[
n
.
type
][
sizekey
]
=
{}
this
.
nodesBySize
[
n
.
type
][
sizekey
][
n
.
id
]
=
true
this
.
nodesBySize
[
n
.
type
][
sizekey
][
n
.
id
]
=
true
}
}
else
{
// should never happen
console
.
warn
(
"warning: couldn't add node to index ?"
,
n
)
}
},
},
dropNode
:
function
(
n
)
{
dropNode
:
function
(
n
)
{
if
(
n
.
type
&&
n
.
size
)
{
if
(
n
.
type
&&
n
.
size
)
{
...
@@ -711,33 +716,6 @@ var TinaWebJS = function ( sigmacanvas ) {
...
@@ -711,33 +716,6 @@ var TinaWebJS = function ( sigmacanvas ) {
TW
.
gui
.
circleSlider
.
setValue
(
0
)
TW
.
gui
.
circleSlider
.
setValue
(
0
)
});
});
// //finished
// $("#slidercat1nodessize").freshslider({
// step:1,
// min:-20,
// max:20,
// value:0,
// bgcolor:"#FFA500",
// onchange:function(value){
// setTimeout(function (){
// // new sigma.js loop on nodes POSS optimize
// nds = TW.partialGraph.graph.nodes()
// console.log("init: slider resize")
// for(j=0 ; j<TW.partialGraph.nNodes ; j++){
// if (nds[j]
// && nds[j].type == TW.conf.catSem) {
// var n = nds[j]
// var newval = parseFloat(TW.Nodes[n.id].size) + parseFloat((value-1))*0.3
// n.size = (newval<1.0)?1:newval;
// sizeMult[TW.conf.catSem] = parseFloat(value-1)*0.3;
// }
// }
// partialGraph.render()
// },
// 100);
// }
// });
// costly entire refresh (~400ms) only after stopped resizing for 3s
// costly entire refresh (~400ms) only after stopped resizing for 3s
// NB: rescale middleware already reacted and, except for large win size changes, it handles the resize fine
// NB: rescale middleware already reacted and, except for large win size changes, it handles the resize fine
...
@@ -776,6 +754,8 @@ var TinaWebJS = function ( sigmacanvas ) {
...
@@ -776,6 +754,8 @@ var TinaWebJS = function ( sigmacanvas ) {
// args: @partialGraph = a sigma instance
// args: @partialGraph = a sigma instance
this
.
initSigmaListeners
=
function
(
partialGraph
,
initialActivetypes
)
{
this
.
initSigmaListeners
=
function
(
partialGraph
,
initialActivetypes
)
{
console
.
log
(
"initSigmaListeners TW.categories"
,
TW
.
categories
)
var
selInst
=
this
.
selNgn
var
selInst
=
this
.
selNgn
// sigma events bindings
// sigma events bindings
...
@@ -958,15 +938,19 @@ var TinaWebJS = function ( sigmacanvas ) {
...
@@ -958,15 +938,19 @@ var TinaWebJS = function ( sigmacanvas ) {
if
(
TW
.
conf
.
filterSliders
)
{
if
(
TW
.
conf
.
filterSliders
)
{
// the indice of the first cat to be active (ex: '1')
let
activeId
=
initialActivetypes
.
indexOf
(
true
)
// args: for display: target div ,
// args: for display: target div ,
// for context: family/type prop value,
// for context: family/type prop value,
// for values: the property to filter
// for values: the property to filter
NodeWeightFilter
(
"#slidercat0nodesweight"
,
NodeWeightFilter
(
`#slidercat
${
activeId
}
nodesweight`
,
TW
.
categories
[
0
]
,
TW
.
categories
[
activeId
]
,
"size"
"size"
);
);
EdgeWeightFilter
(
"#slidercat0edgesweight"
,
// ex: #slidercat1edgesweight
EdgeWeightFilter
(
`#slidercat
${
activeId
}
edgesweight`
,
getActivetypesKey
(),
getActivetypesKey
(),
"weight"
"weight"
);
);
...
@@ -1031,45 +1015,15 @@ var TinaWebJS = function ( sigmacanvas ) {
...
@@ -1031,45 +1015,15 @@ var TinaWebJS = function ( sigmacanvas ) {
}
}
// our current choice: show only the last cat
// POSS make it a configuration settings
this
.
initialActivetypes
=
function
(
categories
)
{
this
.
initialActivetypes
=
function
(
categories
)
{
var
firstActivetypes
=
[]
var
firstActivetypes
=
[]
for
(
var
i
=
0
;
i
<
categories
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
categories
.
length
;
i
++
)
{
if
(
i
==
0
)
firstActivetypes
.
push
(
true
)
// <==> show the cat stored in 0
if
(
i
==
categories
.
length
-
1
)
firstActivetypes
.
push
(
true
)
else
firstActivetypes
.
push
(
false
)
// <==> hide the cat stored in 1
else
firstActivetypes
.
push
(
false
)
}
}
return
firstActivetypes
;
return
firstActivetypes
;
}
}
this
.
allPossibleActivetypes
=
function
(
cats
)
{
if
(
TW
.
conf
.
debug
.
logSettings
)
console
.
debug
(
`allPossibleActivetypes(cats=
${
cats
}
)`
)
var
possibleActivetypes
=
{}
var
N
=
Math
.
pow
(
2
,
cats
.
length
);
for
(
var
i
=
0
;
i
<
N
;
i
++
)
{
let
bin
=
(
i
).
toString
(
2
)
let
bin_splitted
=
[]
for
(
var
j
in
bin
)
bin_splitted
.
push
(
bin
[
j
])
let
bin_array
=
[];
let
toadd
=
cats
.
length
-
bin_splitted
.
length
;
for
(
var
k
=
0
;
k
<
toadd
;
k
++
)
bin_array
.
push
(
"0"
)
for
(
var
j
in
bin
)
bin_array
.
push
(
bin
[
j
])
bin_array
=
bin_array
.
map
(
Number
)
let
sum
=
bin_array
.
reduce
(
function
(
a
,
b
){
return
a
+
b
;})
if
(
sum
!=
0
&&
sum
<
3
)
{
let
id
=
bin_array
.
join
(
"|"
)
possibleActivetypes
[
id
]
=
bin_array
.
map
(
Boolean
)
}
}
return
possibleActivetypes
;
}
};
};
tinawebJS/enviroment.js
View file @
fb15dba9
...
@@ -610,8 +610,8 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
...
@@ -610,8 +610,8 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
range
:
true
,
range
:
true
,
step
:
1
,
step
:
1
,
min
:
0
,
min
:
0
,
// green for docs, orange for terms
// green for docs
/people
, orange for terms
bgcolor
:
(
typestr
==
"1|0"
||
typestr
==
"1"
)?
"#
27c470"
:
"#FFA50
0"
,
bgcolor
:
(
typestr
==
"1|0"
||
typestr
==
"1"
)?
"#
FFA500"
:
"#27c47
0"
,
max
:
steps
-
1
,
max
:
steps
-
1
,
value
:[
0
,
steps
-
1
],
value
:[
0
,
steps
-
1
],
onchange
:
function
(
low
,
high
)
{
onchange
:
function
(
low
,
high
)
{
...
@@ -688,6 +688,7 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
...
@@ -688,6 +688,7 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
// console.log("adding "+ids.join())
// console.log("adding "+ids.join())
for
(
var
i
in
eids
)
{
for
(
var
i
in
eids
)
{
let
eid
=
eids
[
i
]
let
eid
=
eids
[
i
]
TW
.
Edges
[
eid
].
lock
=
false
;
TW
.
Edges
[
eid
].
lock
=
false
;
// global level case
// global level case
...
@@ -844,7 +845,7 @@ function NodeWeightFilter( sliderDivID , tgtNodeType , criteria) {
...
@@ -844,7 +845,7 @@ function NodeWeightFilter( sliderDivID , tgtNodeType , criteria) {
step
:
1
,
step
:
1
,
min
:
0
,
min
:
0
,
max
:
steps
-
1
,
max
:
steps
-
1
,
bgcolor
:(
tgtNodeType
==
TW
.
categories
[
0
]
)?
"#
27c470"
:
"#FFA50
0"
,
bgcolor
:(
tgtNodeType
==
TW
.
categories
[
0
]
)?
"#
FFA500"
:
"#27c47
0"
,
value
:[
0
,
steps
-
1
],
value
:[
0
,
steps
-
1
],
// handler
// handler
...
...
tinawebJS/main.js
View file @
fb15dba9
...
@@ -359,7 +359,6 @@ function mainStartGraph(inFormat, inData, twInstance) {
...
@@ -359,7 +359,6 @@ function mainStartGraph(inFormat, inData, twInstance) {
// activetypes: the node categorie(s) that is (are) currently displayed
// activetypes: the node categorie(s) that is (are) currently displayed
// ex: [true,false] = [nodes of type 0 shown ; nodes of type 1 not drawn]
// ex: [true,false] = [nodes of type 0 shown ; nodes of type 1 not drawn]
var
initialActivetypes
=
TW
.
instance
.
initialActivetypes
(
TW
.
categories
)
var
initialActivetypes
=
TW
.
instance
.
initialActivetypes
(
TW
.
categories
)
var
possibleActivetypes
=
TW
.
instance
.
allPossibleActivetypes
(
TW
.
categories
)
// remember it
// remember it
TW
.
pushState
({
'activetypes'
:
initialActivetypes
})
TW
.
pushState
({
'activetypes'
:
initialActivetypes
})
...
@@ -381,38 +380,21 @@ function mainStartGraph(inFormat, inData, twInstance) {
...
@@ -381,38 +380,21 @@ function mainStartGraph(inFormat, inData, twInstance) {
if
(
inData
.
clusters
)
TW
.
Clusters
=
inData
.
clusters
if
(
inData
.
clusters
)
TW
.
Clusters
=
inData
.
clusters
// £TODO remove from parseCustom or start using
// TW.nodes1 = dicts.n1;//not used
// main console info
// main console info
// ===================
// ===================
console
.
info
(
`== new graph
${
TW
.
nodeIds
.
length
}
nodes,
${
TW
.
edgeIds
.
length
}
edges ==`
)
console
.
info
(
`== new graph
${
TW
.
nodeIds
.
length
}
nodes
(
${
TW
.
categories
.
length
>
1
?
'bipartite'
:
'monopartite'
}
)
,
${
TW
.
edgeIds
.
length
}
edges ==`
)
// a posteriori categories diagnostic
// a posteriori categories diagnostic
// ----------------------------------
// ----------------------------------
// by default TW.categories now match user-suggested catSoc/Sem if present
// by default TW.categories now match user-suggested catSoc/Sem if present
// so we just need to handle mismatches here (when user-suggested cats were absent)
// so we just need to handle mismatches here (when user-suggested cats were absent)
if
(
TW
.
categories
.
length
==
2
)
{
if
(
TW
.
conf
.
catSem
!=
TW
.
categories
[
0
])
{
console
.
info
(
"== 'bipartite' case =="
)
console
.
warn
(
`Observed semantic category "
${
TW
.
categories
[
0
]}
" overwrites user-suggested TW.conf.catSem "(
${
TW
.
conf
.
catSem
}
)"`
)
if
(
TW
.
conf
.
catSoc
!=
TW
.
categories
[
0
])
{
TW
.
conf
.
catSem
=
TW
.
categories
[
0
]
console
.
warn
(
`Observed social category "
${
TW
.
categories
[
0
]}
" overwrites user-suggested TW.conf.catSoc ("
${
TW
.
conf
.
catSoc
}
")`
)
TW
.
conf
.
catSoc
=
TW
.
categories
[
0
]
}
if
(
TW
.
conf
.
catSem
!=
TW
.
categories
[
1
])
{
console
.
warn
(
`Observed semantic category "
${
TW
.
categories
[
1
]}
" overwrites user-suggested TW.conf.catSem "(
${
TW
.
conf
.
catSem
}
)"`
)
TW
.
conf
.
catSem
=
TW
.
categories
[
1
]
}
}
}
else
if
(
TW
.
categories
.
length
==
1
)
{
if
(
TW
.
categories
.
length
>
1
&&
TW
.
conf
.
catSoc
!=
TW
.
categories
[
1
])
{
console
.
info
(
"== monopartite case =="
)
console
.
warn
(
`Observed social category "
${
TW
.
categories
[
1
]}
" overwrites user-suggested TW.conf.catSoc ("
${
TW
.
conf
.
catSoc
}
")`
)
// FIXME it would be more coherent with all tina usecases (like gargantext or tweetoscope) for the default category to be catSem instead of Soc
TW
.
conf
.
catSoc
=
TW
.
categories
[
1
]
if
(
TW
.
conf
.
catSoc
!=
TW
.
categories
[
0
])
{
console
.
warn
(
`Observed unique category "
${
TW
.
categories
[
0
]}
" overwrites user-suggested TW.conf.catSoc ("
${
TW
.
conf
.
catSoc
}
")`
)
TW
.
conf
.
catSoc
=
TW
.
categories
[
0
]
}
}
else
{
console
.
error
(
"== currently unhandled categorization of node types =="
,
TW
.
categories
)
}
}
// [ Poblating the Sigma-Graph ]
// [ Poblating the Sigma-Graph ]
...
...
tinawebJS/methods.js
View file @
fb15dba9
...
@@ -48,24 +48,23 @@ TW.pushState = function( args ) {
...
@@ -48,24 +48,23 @@ TW.pushState = function( args ) {
||
typesKey
!=
lastState
.
activetypes
.
map
(
Number
).
join
(
"|"
)))
{
||
typesKey
!=
lastState
.
activetypes
.
map
(
Number
).
join
(
"|"
)))
{
// terms
// terms
if
(
typesKey
==
"1|0"
)
{
$
(
".for-nodecategory-0"
).
show
()
$
(
".for-nodecategory-1"
).
hide
();
NodeWeightFilter
(
"#slidercat0nodesweight"
,
TW
.
categories
[
0
],
"size"
);
EdgeWeightFilter
(
"#slidercat0edgesweight"
,
typesKey
,
"weight"
);
}
// docs
if
(
typesKey
==
"0|1"
)
{
if
(
typesKey
==
"0|1"
)
{
$
(
".for-nodecategory-0"
).
hide
()
$
(
".for-nodecategory-0"
).
hide
()
$
(
".for-nodecategory-1"
).
show
();
$
(
".for-nodecategory-1"
).
show
();
NodeWeightFilter
(
"#slidercat1nodesweight"
,
TW
.
categories
[
1
],
"size"
);
NodeWeightFilter
(
"#slidercat1nodesweight"
,
TW
.
categories
[
1
],
"size"
);
EdgeWeightFilter
(
"#slidercat1edgesweight"
,
typesKey
,
"weight"
);
EdgeWeightFilter
(
"#slidercat1edgesweight"
,
typesKey
,
"weight"
);
}
}
// docs
if
(
typesKey
==
"1|0"
)
{
$
(
".for-nodecategory-0"
).
show
()
$
(
".for-nodecategory-1"
).
hide
();
NodeWeightFilter
(
"#slidercat0nodesweight"
,
TW
.
categories
[
0
],
"size"
);
EdgeWeightFilter
(
"#slidercat0edgesweight"
,
typesKey
,
"weight"
);
}
// terms and docs
// terms and docs
if
(
typesKey
==
"1|1"
)
{
if
(
typesKey
==
"1|1"
)
{
$
(
".for-nodecategory-0"
).
show
()
$
(
".for-nodecategory-0"
).
show
()
...
@@ -163,14 +162,13 @@ function cancelSelection (fromTagCloud, settings) {
...
@@ -163,14 +162,13 @@ function cancelSelection (fromTagCloud, settings) {
// this area is quite underspecified so we assume here
// this area is quite underspecified so we assume here
// - that all typenames have a mapping to cat[0] (terms) or cat[1] (contexts)
// - that all typenames have a mapping to cat[0] (terms) or cat[1] (contexts)
// - that currentState.activetypes is an array of 2 bools for the currently displayed cat(s)
// - that currentState.activetypes is an array of 2 bools for the currently displayed cat(s)
function
getActivetypes
()
{
function
getActivetypes
Names
()
{
let
currentTypes
=
[]
let
currentTypes
=
[]
let
currentTypeIdx
let
currentTypeIdx
let
lastState
=
TW
.
states
.
slice
(
-
1
)[
0
]
for
(
var
possType
in
TW
.
catDict
)
{
for
(
var
possType
in
TW
.
catDict
)
{
currentTypeIdx
=
TW
.
catDict
[
possType
]
currentTypeIdx
=
TW
.
catDict
[
possType
]
if
(
lastState
.
activetypes
[
currentTypeIdx
])
{
if
(
TW
.
SystemState
()
.
activetypes
[
currentTypeIdx
])
{
currentTypes
.
push
(
possType
)
currentTypes
.
push
(
possType
)
}
}
}
}
...
@@ -195,12 +193,7 @@ function getActivetypesKey() {
...
@@ -195,12 +193,7 @@ function getActivetypesKey() {
// - 1st change: types described as type 0 and type 1 and possible default type
// - 1st change: types described as type 0 and type 1 and possible default type
// - 2nd change default type of monopartite case changed from document to semantic
// - 2nd change default type of monopartite case changed from document to semantic
function
swActual
(
aNodetype
)
{
function
swActual
(
aNodetype
)
{
if
(
TW
.
categories
.
length
==
1
)
{
return
(
aNodetype
==
TW
.
categories
[
0
])
?
'semantic'
:
'social'
return
'semantic'
}
else
if
(
TW
.
categories
.
length
==
2
)
{
return
(
aNodetype
==
TW
.
categories
[
0
])
?
'social'
:
'semantic'
}
}
}
...
@@ -329,7 +322,7 @@ function htmlfied_nodesatts(elems){
...
@@ -329,7 +322,7 @@ function htmlfied_nodesatts(elems){
var
id
=
elems
[
i
]
var
id
=
elems
[
i
]
var
node
=
TW
.
Nodes
[
id
]
var
node
=
TW
.
Nodes
[
id
]
if
(
node
.
type
==
TW
.
conf
.
catSoc
){
if
(
swActual
(
node
.
type
)
==
'social'
){
information
+=
'<li><b>'
+
node
.
label
+
'</b></li>'
;
information
+=
'<li><b>'
+
node
.
label
+
'</b></li>'
;
if
(
node
.
htmlCont
==
""
){
if
(
node
.
htmlCont
==
""
){
if
(
!
isUndef
(
node
.
level
))
{
if
(
!
isUndef
(
node
.
level
))
{
...
@@ -341,7 +334,7 @@ function htmlfied_nodesatts(elems){
...
@@ -341,7 +334,7 @@ function htmlfied_nodesatts(elems){
socnodes
.
push
(
information
)
socnodes
.
push
(
information
)
}
}
if
(
node
.
type
==
TW
.
conf
.
catSem
){
if
(
swActual
(
node
.
type
)
==
'semantic'
){
information
+=
'<li><b>'
+
node
.
label
+
'</b></li>'
;
information
+=
'<li><b>'
+
node
.
label
+
'</b></li>'
;
let
google
=
'<a href=http://www.google.com/#hl=en&source=hp&q=%20'
+
node
.
label
.
replace
(
" "
,
"+"
)
+
'%20><img src="'
+
'img/google.png"></img></a>'
;
let
google
=
'<a href=http://www.google.com/#hl=en&source=hp&q=%20'
+
node
.
label
.
replace
(
" "
,
"+"
)
+
'%20><img src="'
+
'img/google.png"></img></a>'
;
let
wiki
=
'<a href=http://en.wikipedia.org/wiki/'
+
node
.
label
.
replace
(
" "
,
"_"
)
+
'><img src="'
+
'img/wikipedia.png"></img></a>'
;
let
wiki
=
'<a href=http://en.wikipedia.org/wiki/'
+
node
.
label
.
replace
(
" "
,
"_"
)
+
'><img src="'
+
'img/wikipedia.png"></img></a>'
;
...
@@ -452,7 +445,7 @@ function updateRelatedNodesPanel( sels , same, oppos ) {
...
@@ -452,7 +445,7 @@ function updateRelatedNodesPanel( sels , same, oppos ) {
$
(
"#tips"
).
html
(
""
);
$
(
"#tips"
).
html
(
""
);
if
(
TW
.
categories
.
length
==
1
)
getTopPapers
(
"semantic"
);
if
(
TW
.
categories
.
length
==
1
)
getTopPapers
(
"semantic"
);
else
getTopPapers
(
swActual
(
getActivetypes
()[
0
]));
else
getTopPapers
(
swActual
(
getActivetypes
Names
()[
0
]));
}
}
// just css
// just css
...
...
tinawebJS/sigma.parseCustom.js
View file @
fb15dba9
...
@@ -218,12 +218,11 @@ function sortNodeTypes(observedTypesDict) {
...
@@ -218,12 +218,11 @@ function sortNodeTypes(observedTypesDict) {
var
nTypes
=
observedTypes
.
length
var
nTypes
=
observedTypes
.
length
if
(
nTypes
==
0
)
{
if
(
nTypes
==
0
)
{
observedTypes
[
0
]
=
"
Document
"
;
observedTypes
[
0
]
=
"
Terms
"
;
catDict
[
"
Document
"
]
=
0
;
catDict
[
"
Terms
"
]
=
0
;
}
}
if
(
nTypes
==
1
)
{
if
(
nTypes
==
1
)
{
// if we have only one category, it gets the same code 0 as Document
// if we have only one category, it gets code 0 as Terms
// but in practice it's more often terms. anyways doesn't affect much
catDict
[
observedTypes
[
0
]]
=
0
;
catDict
[
observedTypes
[
0
]]
=
0
;
if
(
TW
.
conf
.
debug
.
logParsers
)
if
(
TW
.
conf
.
debug
.
logParsers
)
...
@@ -232,16 +231,17 @@ function sortNodeTypes(observedTypesDict) {
...
@@ -232,16 +231,17 @@ function sortNodeTypes(observedTypesDict) {
if
(
nTypes
>
1
)
{
if
(
nTypes
>
1
)
{
var
newcats
=
[]
var
newcats
=
[]
//
POSSible: allow more than 2 cat
s
//
NB: only 2 cat labels are allowed by thi
s
for
(
var
i
in
observedTypes
)
{
for
(
var
i
in
observedTypes
)
{
let
c
=
observedTypes
[
i
]
let
c
=
observedTypes
[
i
]
if
(
c
==
TW
.
conf
.
catSoc
||
(
c
!=
TW
.
conf
.
catSem
&&
c
.
indexOf
(
"term"
)
==-
1
))
{
// NOT
a term-category
if
(
c
==
TW
.
conf
.
catSoc
)
{
// conf says that it's not
a term-category
newcats
[
0
]
=
c
;
newcats
[
1
]
=
c
;
catDict
[
c
]
=
0
;
catDict
[
c
]
=
1
;
}
}
// else: term-category is the new default
else
{
else
{
newcats
[
1
]
=
c
;
// IS a term-category
newcats
[
0
]
=
c
;
catDict
[
c
]
=
1
;
catDict
[
c
]
=
0
;
}
}
}
}
observedTypes
=
newcats
;
observedTypes
=
newcats
;
...
...
tinawebJS/sigmaUtils.js
View file @
fb15dba9
...
@@ -9,8 +9,10 @@ var SigmaUtils = function () {
...
@@ -9,8 +9,10 @@ var SigmaUtils = function () {
console
.
log
(
"FillGraph catDict"
,
catDict
)
console
.
log
(
"FillGraph catDict"
,
catDict
)
// console.log("FillGraph nodes",nodes)
// console.log("FillGraph nodes",nodes)
// console.log("FillGraph edges",edges)
// console.log("FillGraph edges",edges)
for
(
var
i
in
nodes
)
{
var
n
=
nodes
[
i
];
let
i
=
0
for
(
var
nid
in
nodes
)
{
var
n
=
nodes
[
nid
];
// console.debug('tr >>> fgr node', n)
// console.debug('tr >>> fgr node', n)
if
(
initialActivetypes
[
catDict
[
n
.
type
]]
||
TW
.
conf
.
debug
.
initialShowAll
)
{
if
(
initialActivetypes
[
catDict
[
n
.
type
]]
||
TW
.
conf
.
debug
.
initialShowAll
)
{
...
@@ -36,6 +38,8 @@ var SigmaUtils = function () {
...
@@ -36,6 +38,8 @@ var SigmaUtils = function () {
// fill the "labels" global variable
// fill the "labels" global variable
updateSearchLabels
(
n
.
id
,
n
.
label
,
n
.
type
);
updateSearchLabels
(
n
.
id
,
n
.
label
,
n
.
type
);
i
++
}
}
}
}
...
@@ -43,11 +47,10 @@ var SigmaUtils = function () {
...
@@ -43,11 +47,10 @@ var SigmaUtils = function () {
// the typestring of the activetypes is the key to stored Relations (<=> edges)
// the typestring of the activetypes is the key to stored Relations (<=> edges)
var
activetypesKey
=
initialActivetypes
.
map
(
Number
).
join
(
"|"
)
var
activetypesKey
=
initialActivetypes
.
map
(
Number
).
join
(
"|"
)
for
(
var
i
in
TW
.
Relations
[
activetypesKey
])
{
for
(
let
srcnid
in
TW
.
Relations
[
activetypesKey
])
{
let
s
=
i
;
for
(
var
j
in
TW
.
Relations
[
activetypesKey
][
srcnid
])
{
for
(
var
j
in
TW
.
Relations
[
activetypesKey
][
i
])
{
let
tgtnid
=
TW
.
Relations
[
activetypesKey
][
srcnid
][
j
]
let
t
=
TW
.
Relations
[
activetypesKey
][
i
][
j
]
let
e
=
TW
.
Edges
[
srcnid
+
";"
+
tgtnid
]
let
e
=
TW
.
Edges
[
s
+
";"
+
t
]
if
(
e
)
{
if
(
e
)
{
if
(
e
.
source
!=
e
.
target
)
{
if
(
e
.
source
!=
e
.
target
)
{
graph
.
edges
.
push
(
e
);
graph
.
edges
.
push
(
e
);
...
@@ -280,7 +283,7 @@ var SigmaUtils = function () {
...
@@ -280,7 +283,7 @@ var SigmaUtils = function () {
// NB cost of this condition seems small:
// NB cost of this condition seems small:
// - without: [11 - 30] ms for 23 nodes
// - without: [11 - 30] ms for 23 nodes
// - with : [11 - 33] ms for 23 nodes
// - with : [11 - 33] ms for 23 nodes
var
catS
emFlag
=
(
TW
.
categories
.
length
>
1
&&
node
.
type
=
=
TW
.
categories
[
0
])
var
catS
ocFlag
=
(
node
.
type
!
=
TW
.
categories
[
0
])
// mode variants 1: if a coloringFunction is active
// mode variants 1: if a coloringFunction is active
...
@@ -332,7 +335,7 @@ var SigmaUtils = function () {
...
@@ -332,7 +335,7 @@ var SigmaUtils = function () {
context
.
fillStyle
=
borderColor
context
.
fillStyle
=
borderColor
context
.
beginPath
();
context
.
beginPath
();
if
(
catS
em
Flag
)
{
if
(
catS
oc
Flag
)
{
// (Square shape)
// (Square shape)
// thinner borderSize for squares looks better
// thinner borderSize for squares looks better
// otherwise hb = (nodeSize + borderSize) / 2
// otherwise hb = (nodeSize + borderSize) / 2
...
@@ -361,7 +364,7 @@ var SigmaUtils = function () {
...
@@ -361,7 +364,7 @@ var SigmaUtils = function () {
context
.
beginPath
();
context
.
beginPath
();
if
(
catS
em
Flag
)
{
if
(
catS
oc
Flag
)
{
// (Square shape)
// (Square shape)
let
hn
=
nodeSize
/
2
let
hn
=
nodeSize
/
2
context
.
moveTo
(
X
+
hn
,
Y
+
hn
);
context
.
moveTo
(
X
+
hn
,
Y
+
hn
);
...
@@ -777,7 +780,7 @@ function repaintEdges() {
...
@@ -777,7 +780,7 @@ function repaintEdges() {
function
heatmapColoring
(
daclass
)
{
function
heatmapColoring
(
daclass
)
{
var
binColors
var
binColors
var
doModifyLabel
=
false
var
doModifyLabel
=
false
var
actypes
=
getActivetypes
()
var
actypes
=
getActivetypes
Names
()
// default value
// default value
let
nColors
=
TW
.
conf
.
legendsBins
||
5
let
nColors
=
TW
.
conf
.
legendsBins
||
5
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment