diff --git a/brick-studio.js b/brick-studio.js index 2efedb2..9935e8c 100644 --- a/brick-studio.js +++ b/brick-studio.js @@ -294,8 +294,8 @@ $(function() { .nodeLabel(node => { if(node.show){ try{ - - return `${minifyIRI(node.type)} : ${node.id.split('#')[node.id.split('#').length - 1]} : ${node.out.length}` + let name = node.label != "undefined" ? node.label : node.id.split('#')[node.id.split('#').length - 1]; + return `${minifyIRI(node.type)} : ${name} : ${node.out.length}` } catch (e) { console.log('Invalid node ID: ', node.id) @@ -360,7 +360,7 @@ $(function() { ctx.strokeStyle = "#0006" ctx.stroke(); }; - const label = minifyIRI(node.id); + const label = node.label != "undefined" ? node.label : minifyIRI(node.id); const fontSize = 15 / globalScale; ctx.font = `${fontSize}px Sans-Serif`; const textWidth = ctx.measureText(label).width; diff --git a/rdf-studio.js b/rdf-studio.js index 630161e..b9f1caf 100644 --- a/rdf-studio.js +++ b/rdf-studio.js @@ -307,16 +307,20 @@ const analyze = function(store = quadStore, storeIn = 'rdf', callback = preproce const typoOfSubject = function(subject) { const types = quadStore.getObjects(subject, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); - var type = types.length ? types[0].id : 'undefined'; - return type; + return types.length ? types[0].id : 'undefined'; }; const getType = memoize(typoOfSubject); +const getLabel = function(subject) { + const labels = quadStore.getObjects(subject, "http://www.w3.org/2000/01/rdf-schema#label"); + return labels.length ? labels[0].id : 'undefined'; +}; + const preprocess = function(callback = draw) { emitter.emit('preprocessing', { status: 'start' - }) + }); console.log('START: PREPROCESSING'); exportStore.addQuads(quadStore.getQuads()); @@ -351,7 +355,8 @@ const preprocess = function(callback = draw) { show: false, collapsed: true, out: quadStore.getQuads(node).filter(quads=>quads.predicate.id!=='http://www.w3.org/1999/02/22-rdf-syntax-ns#type').map((quad)=>quad.object.id), - type: getType(node) + type: getType(node), + label: getLabel(node), }; }))]; // var newData = {nodes:[], links:[]}