@matdata/yasgui-graph-plugin 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,8 @@ A YASGUI plugin for visualizing SPARQL CONSTRUCT and DESCRIBE query results as i
17
17
  - **� Compact Mode**: Hide literal and class nodes; show rdf:type and datatype properties in enhanced tooltips instead
18
18
  - **🔍 Navigation**: Mouse wheel zoom, drag to pan, "Zoom to Fit" button
19
19
  - **✋ Drag & Drop**: Reorganize nodes by dragging them to new positions (nodes stay pinned after manual drag)
20
- - **💬 Rich Tooltips**: Modern HTML tooltips with node type, value, namespace, and datatype information
20
+ - **� Node Expansion**: Double-click any URI node to fetch and merge related triples via DESCRIBE queries (see [Expand Nodes with Double Click](#-expand-nodes-with-double-click))
21
+ - **�💬 Rich Tooltips**: Modern HTML tooltips with node type, value, namespace, and datatype information
21
22
  - **🌓 Theme Support**: Automatic light/dark mode detection and dynamic color switching
22
23
  - **⚡ Performance**: Handles up to 1,000 nodes with <2s render time
23
24
  - **♿ Accessible**: WCAG AA color contrast, keyboard navigation support
@@ -105,6 +106,7 @@ After running the query, click the **"Graph"** tab to see the visualization.
105
106
 
106
107
  ### Interaction
107
108
  - **Drag Nodes**: Click and drag any node to reposition it (nodes are automatically pinned in place after dragging)
109
+ - **Expand Nodes**: 🆕 Double-click any blue URI node to fetch and merge additional RDF triples for that resource (see [Node Expansion](#expand-nodes-with-double-click) below)
108
110
  - **Tooltips**: Hover over nodes/edges to see rich HTML tooltips with type, value, namespace, and datatype information
109
111
 
110
112
  ### Understanding Colors
@@ -240,7 +242,100 @@ class CustomGraphPlugin extends GraphPlugin {
240
242
  Yasgui.Yasr.registerPlugin('customGraph', CustomGraphPlugin);
241
243
  ```
242
244
 
243
- ## 🔧 Development
245
+ ## Expand Nodes with Double Click
246
+
247
+ The graph plugin supports **interactive node expansion** via double-clicking. This allows you to progressively explore RDF graphs by fetching additional triples for any URI node without redrawing the entire graph.
248
+
249
+ ### How It Works
250
+
251
+ 1. **Double-click a blue URI node** in the graph
252
+ 2. The node's border turns **orange and thickens** (loading state)
253
+ 3. A `DESCRIBE <uri>` query is sent to the SPARQL endpoint
254
+ 4. **New triples are merged** into the existing graph
255
+ 5. Node's border returns to normal width with **thicker border (3px) to indicate expansion**
256
+ 6. Graph layout and zoom level are **preserved**
257
+
258
+ ### Visual Feedback
259
+
260
+ | State | Border | Meaning |
261
+ |-------|--------|---------|
262
+ | **Default** | 2px | Node has not been expanded |
263
+ | **Loading** | 4px, orange | DESCRIBE query in progress |
264
+ | **Expanded** | 3px, normal color | Successfully expanded |
265
+
266
+ ### Supported Node Types
267
+
268
+ | Node Type | Can Expand? | Reason |
269
+ |-----------|-------|----|
270
+ | 🔵 **URI nodes** | ✅ Yes | DESCRIBE works on URIs |
271
+ | 🟢 **Literals** | ❌ No | Cannot run DESCRIBE on literal values |
272
+ | ⚪ **Blank nodes** | ❌ No | Blank nodes have no resolvable identity |
273
+
274
+ ### Example: Exploring a Knowledge Graph
275
+
276
+ **Initial Query**:
277
+ ```sparql
278
+ PREFIX ex: <http://example.org/>
279
+ PREFIX foaf: <http://xmlns.com/foaf/0.1/>
280
+
281
+ CONSTRUCT {
282
+ ex:alice foaf:knows ex:bob .
283
+ ex:alice foaf:name "Alice" .
284
+ ex:bob foaf:name "Bob" .
285
+ }
286
+ WHERE {}
287
+ ```
288
+
289
+ **Initial Graph**: 3 nodes (Alice, "Alice", Bob, "Bob"), 2 edges
290
+
291
+ **User Action**: Double-click the `ex:bob` node
292
+
293
+ **What Happens**:
294
+ - System executes: `DESCRIBE <http://example.org/bob>`
295
+ - Endpoint returns all triples about Bob (from your SPARQL endpoint)
296
+ - New nodes and edges appear in the graph
297
+ - Graph layout shifts smoothly to accommodate new nodes
298
+ - `ex:bob` node gets a thicker border
299
+
300
+ **Result**: You can now see Bob's relationships, properties, and connections without losing your current view
301
+
302
+ ### Requirements
303
+
304
+ The node expansion feature requires:
305
+
306
+ 1. **SPARQL 1.1 DESCRIBE support**: Your endpoint must support DESCRIBE queries
307
+ 2. **Query execution callback**: YASR must provide `yasr.executeQuery()` for background queries
308
+ 3. **RDF response format**: Endpoint must return results in RDF (JSON-LD, Turtle, N-Triples, etc.)
309
+
310
+ ### Limitations & Behavior
311
+
312
+ - Only new triples are added (existing triples are skipped if already in graph)
313
+ - Expansion is **one-level deep** - only triples directly about the URI are added
314
+ - For very large result sets (1000+ triples from DESCRIBE), performance may be affected
315
+ - Blank nodes returned by DESCRIBE may not connect properly if disconnected from existing nodes
316
+
317
+ ### Troubleshooting Expansion
318
+
319
+ **"Nothing happens when I double-click"**
320
+ - Ensure the node is blue (URI node, not literal or blank node)
321
+ - Check browser console for warnings about `yasr.executeQuery`
322
+ - Verify your SPARQL endpoint supports DESCRIBE queries
323
+
324
+ **"Graph becomes slow after many expansions"**
325
+ - Disable physics simulation in Settings panel for faster UI response
326
+ - Consider limiting query results with WHERE clause constraints
327
+ - Each expansion adds more triples to the visualization
328
+
329
+ **"New nodes don't appear where I expect"**
330
+ - The force-directed layout will position new nodes to minimize overlaps
331
+ - Disable Physics in Settings to lock positions if desired
332
+ - Manually drag new nodes to preferred positions
333
+
334
+ ### Demo
335
+
336
+ See [demo/expand.html](./demo/expand.html) for a working example with mock DESCRIBE responses and detailed logging.
337
+
338
+ ## �🔧 Development
244
339
 
245
340
  ### Build
246
341
 
@@ -272,6 +367,7 @@ npm run format # Prettier format
272
367
  ## 📚 Documentation
273
368
 
274
369
  - **[Quickstart Guide](./specs/001-construct-graph-viz/quickstart.md)** - Installation, usage, troubleshooting
370
+ - **[Node Expansion Feature](./specs/001-construct-graph-viz/EXPAND_FEATURE.md)** - Complete guide to double-click expansion (FR-001 through FR-009)
275
371
  - **[Data Model](./specs/001-construct-graph-viz/data-model.md)** - Entity definitions and relationships
276
372
  - **[Contracts](./specs/001-construct-graph-viz/contracts/)** - API specifications for YASR plugin and vis-network integration
277
373
  - **[Specification](./specs/001-construct-graph-viz/spec.md)** - Complete feature specification
@@ -312,19 +408,18 @@ Contributions welcome! Please follow the project constitution (`.specify/memory/
312
408
  **Current Version**: 0.1.0 (MVP)
313
409
 
314
410
  **Implemented Features** (v0.1.0):
315
- - ✅ Basic graph visualization (US1)
316
- - ✅ Navigation controls (US2)
317
- - ✅ Color-coded nodes
318
- - ✅ Prefix abbreviation
319
- - ✅ Blank node support
320
- - ✅ Performance optimization
321
-
322
- **Planned Features** (Future):
323
- - Enhanced tooltips with datatype display (US4)
324
- - Manual testing across all browsers (US3 verification)
325
- - Large graph optimization (>1k nodes)
326
- - Custom color schemes
327
- - ⏳ Layout algorithm selection
411
+ - ✅ **Basic graph visualization** (US1) - CONSTRUCT/DESCRIBE results as interactive graphs
412
+ - ✅ **Navigation controls** (US2) - Zoom, pan, "Fit to View" button
413
+ - ✅ **Color-coded nodes** - URIs, literals, blank nodes, rdf:type objects
414
+ - ✅ **Prefix abbreviation** - Display prefixed URIs instead of full URLs
415
+ - ✅ **Blank node support** - Handle anonymous RDF nodes
416
+ - ✅ **Drag & repositioning** - Manually adjust node positions
417
+ - ✅ **Rich tooltips** - Hover for detailed node/edge information
418
+ - ✅ **Theme support** - Light/dark mode detection and switching
419
+ - **Settings panel** - Configurable display options with localStorage persistence
420
+ - **Node icons & images** - Display images via schema:image property
421
+ - **Compact mode** - Hide literals and classes for cleaner visualization
422
+ - **Double-click expansion** (US5) - Fetch and merge related triples via DESCRIBE queries (see [Expand Nodes with Double Click](#-expand-nodes-with-double-click))
328
423
 
329
424
  ## 🐛 Troubleshooting
330
425