Skip to content

Commit 4491ce5

Browse files
committed
doc: also explain the possibility to use this plugin with DESCRIBE queries
1 parent ecd6d07 commit 4491ce5

File tree

10 files changed

+34
-17
lines changed

10 files changed

+34
-17
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
44
[![npm version](https://img.shields.io/npm/v/yasgui-graph-plugin.svg)](https://www.npmjs.com/package/yasgui-graph-plugin)
55

6-
A YASGUI plugin for visualizing SPARQL CONSTRUCT query results as interactive graphs with nodes (subjects/objects) and edges (predicates).
6+
A YASGUI plugin for visualizing SPARQL CONSTRUCT and DESCRIBE query results as interactive graphs with nodes (subjects/objects) and edges (predicates).
77

88
## ✨ Features
99

@@ -66,8 +66,9 @@ const yasgui = new Yasgui(document.getElementById('yasgui'), {
6666
});
6767
```
6868

69-
### Sample CONSTRUCT Query
69+
### Sample Queries
7070

71+
**CONSTRUCT Query:**
7172
```sparql
7273
PREFIX ex: <http://example.org/>
7374
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@@ -82,6 +83,14 @@ CONSTRUCT {
8283
WHERE {}
8384
```
8485

86+
**DESCRIBE Query:**
87+
```sparql
88+
PREFIX ex: <http://example.org/>
89+
90+
# Returns all triples about the specified resources
91+
DESCRIBE ex:Alice ex:Bob
92+
```
93+
8594
After running the query, click the **"Graph"** tab to see the visualization.
8695

8796
## 🎮 User Guide

demo/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ <h2 onclick="toggleInstructions()">
111111
</h2>
112112
<div class="instructions-content collapsed">
113113
<ul>
114-
<li>Click the <strong>"Graph"</strong> tab after running a CONSTRUCT query</li>
115-
<li><strong>Sample queries</strong> are pre-loaded (see tabs: Basic, Ontology, Blank Nodes, Multiple Edges)</li>
114+
<li>Click the <strong>"Graph"</strong> tab after running a CONSTRUCT or DESCRIBE query</li>
115+
<li><strong>Sample queries</strong> are pre-loaded (see tabs: Basic, Ontology, Blank Nodes, Multiple Edges, DESCRIBE)</li>
116116
<li><strong>Navigate</strong>: Mouse wheel to zoom, drag background to pan, click "Zoom to Fit" button</li>
117117
<li><strong>Reorganize</strong>: Drag individual nodes to rearrange the layout</li>
118118
<li><strong>Inspect</strong>: Hover over nodes/edges to see full details (300ms delay)</li>
@@ -225,7 +225,7 @@ <h2 onclick="toggleInstructions()">
225225
getOriginalResponseAsString: () => '',
226226
getOriginalResponse: () => null,
227227
getError: () => null,
228-
getContentType: () => 'application/sparql-results+json'
228+
getContentType: () => 'text/turtle'
229229
};
230230
}
231231

@@ -234,7 +234,8 @@ <h2 onclick="toggleInstructions()">
234234
{ name: 'Basic Graph', query: queries.basic },
235235
{ name: 'Ontology', query: queries.ontology },
236236
{ name: 'Blank Nodes', query: queries.blankNodes },
237-
{ name: 'Multiple Edges', query: queries.multiplePredicates }
237+
{ name: 'Multiple Edges', query: queries.multiplePredicates },
238+
{ name: 'DESCRIBE Query', query: queries.describe }
238239
];
239240

240241
// Clear default tab

demo/queries.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,12 @@ CONSTRUCT {
5656
ex:Person2 ex:knows ex:Person3 .
5757
ex:Person3 ex:knows ex:Person1 .
5858
}
59-
WHERE {}`
59+
WHERE {}`,
60+
61+
describe: `PREFIX ex: <http://example.org/>
62+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
63+
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
64+
65+
# DESCRIBE returns all triples about a resource
66+
DESCRIBE ex:Alice ex:Bob`
6067
};

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@matdata/yasgui-graph-plugin",
33
"private": false,
44
"version": "0.1.0",
5-
"description": "YASGUI plugin for visualizing SPARQL CONSTRUCT query results as interactive graphs",
5+
"description": "YASGUI plugin for visualizing SPARQL CONSTRUCT and DESCRIBE query results as interactive graphs",
66
"main": "dist/yasgui-graph-plugin.min.js",
77
"scripts": {
88
"dev": "vite",

specs/001-construct-graph-viz/plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
## Summary
99

10-
**Primary Requirement**: Create a YASGUI plugin that visualizes SPARQL CONSTRUCT query results as interactive graphs with nodes (subjects/objects) and edges (predicates), supporting zoom, drag, tooltips and color coding by node type.
10+
**Primary Requirement**: Create a YASGUI plugin that visualizes SPARQL CONSTRUCT and DESCRIBE query results as interactive graphs with nodes (subjects/objects) and edges (predicates), supporting zoom, drag, tooltips and color coding by node type.
1111

1212
**Technical Approach**: Implement a YASR plugin class following the yasgui-geo pattern (constructor, canHandleResults, draw, getIcon methods) using vis-network v9.x for graph rendering. Parse RDF triples from bindings format, transform to vis-network DataSets with color-coded nodes (grey literals, green rdf:type objects, blue other URIs), apply prefix abbreviation, and leverage vis-network's built-in force-directed layout and interaction. Build with esbuild to UMD format for `Yasgui.Yasr.registerPlugin()` registration.
1313

specs/001-construct-graph-viz/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const yasgui = new Yasgui(document.getElementById('yasgui'), {
6666

6767
## Basic Usage
6868

69-
### 1. Execute CONSTRUCT Query
69+
### 1. Execute CONSTRUCT or DESCRIBE Query
7070

7171
The plugin automatically activates for SPARQL CONSTRUCT queries that return triples:
7272

specs/001-construct-graph-viz/spec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
**Feature Branch**: `001-construct-graph-viz`
44
**Created**: 2025-12-05
55
**Status**: Draft
6-
**Input**: User description: "Visualize SPARQL CONSTRUCT query results as interactive graphs with nodes (subjects/objects) and edges (predicates), supporting zoom, drag, tooltips and color coding"
6+
**Input**: User description: "Visualize SPARQL CONSTRUCT and DESCRIBE query results as interactive graphs with nodes (subjects/objects) and edges (predicates), supporting zoom, drag, tooltips and color coding"
77

88
## Clarifications
99

@@ -105,7 +105,7 @@ While exploring the graph, the user wants to see detailed information about node
105105

106106
#### Data Parsing & Graph Construction
107107

108-
- **FR-001**: Plugin MUST detect when YASR receives CONSTRUCT query results (as opposed to SELECT/ASK/DESCRIBE)
108+
- **FR-001**: Plugin MUST detect when YASR receives CONSTRUCT or DESCRIBE query results (as opposed to SELECT/ASK)
109109
- **FR-002**: Plugin MUST parse RDF triples from SPARQL results and extract subject, predicate, object for each triple
110110
- **FR-003**: Plugin MUST create graph nodes for all unique subjects and objects appearing in triples
111111
- **FR-004**: Plugin MUST create graph edges for predicates connecting subject nodes to object nodes

specs/001-construct-graph-viz/tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
- [X] T010 [P] Implement getNodeColor(node, triples) in src/colorUtils.js to determine color: #FFFF00 (blank nodes), #808080 (literals), #00FF00 (rdf:type objects), #0000FF (other URIs)
4040
- [X] T011 [P] Implement getDefaultNetworkOptions() in src/networkConfig.js returning vis-network config: physics enabled with 200 max iterations, interactions (drag/zoom/pan/hover), autoResize, 100% width/height
4141
- [X] T012 Create GraphPlugin class skeleton in src/GraphPlugin.js with constructor(yasr), priority=20, label='Graph', and placeholder methods: canHandleResults(), draw(), getIcon()
42-
- [X] T013 Implement GraphPlugin.canHandleResults() to detect CONSTRUCT results by checking for subject/predicate/object variables in this.yasr.results
42+
- [X] T013 Implement GraphPlugin.canHandleResults() to detect CONSTRUCT and DESCRIBE results by checking for subject/predicate/object variables in this.yasr.results
4343
- [X] T014 Implement GraphPlugin.getIcon() to return Font Awesome icon element (fa-project-diagram) for YASR tab
4444
- [X] T015 Export GraphPlugin and auto-register with Yasgui.Yasr.registerPlugin('graph', GraphPlugin) in src/index.js (UMD compatibility)
4545

src/GraphPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class GraphPlugin {
3737

3838
/**
3939
* Check if plugin can handle the current results
40-
* @returns {boolean} True if results are from CONSTRUCT query
40+
* @returns {boolean} True if results are from CONSTRUCT or DESCRIBE query
4141
*/
4242
canHandleResults() {
4343
if (!this.yasr || !this.yasr.results) return false;
@@ -49,7 +49,7 @@ class GraphPlugin {
4949
const bindings = results.getBindings();
5050
if (bindings && bindings.length > 0) {
5151
const firstBinding = bindings[0];
52-
// CONSTRUCT results have subject, predicate, object variables
52+
// CONSTRUCT and DESCRIBE results have subject, predicate, object variables
5353
return (
5454
firstBinding.subject !== undefined &&
5555
firstBinding.predicate !== undefined &&

0 commit comments

Comments
 (0)