@matdata/yasgui-graph-plugin 1.0.1 โ†’ 1.0.3

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
@@ -1,301 +1,301 @@
1
- # YASGUI Graph Plugin
2
-
3
- [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4
- [![npm version](https://img.shields.io/npm/v/yasgui-graph-plugin.svg)](https://www.npmjs.com/package/yasgui-graph-plugin)
5
-
6
- A YASGUI plugin for visualizing SPARQL CONSTRUCT and DESCRIBE query results as interactive graphs with nodes (subjects/objects) and edges (predicates).
7
-
8
- ## โœจ Features
9
-
10
- - **๐Ÿ”ท Interactive Graph Visualization**: Automatic force-directed layout with smooth physics-based positioning
11
- - **๐ŸŽจ Smart Color Coding**:
12
- - ๐Ÿ”ต Light Blue (#97C2FC) = URIs
13
- - ๐ŸŸข Light Green (#a6c8a6ff) = Literals
14
- - โšช Light Grey (#c5c5c5ff) = Blank nodes
15
- - ๐ŸŸ  Orange (#e15b13ff) = rdf:type objects (classes)
16
- - **๐Ÿ” Navigation**: Mouse wheel zoom, drag to pan, "Zoom to Fit" button
17
- - **โœ‹ Drag & Drop**: Reorganize nodes by dragging them to new positions
18
- - **๐Ÿ’ฌ Tooltips**: Hover for full URI/literal details (300ms delay)
19
- - **โšก Performance**: Handles up to 1,000 nodes with <2s render time
20
- - **โ™ฟ Accessible**: WCAG AA color contrast, keyboard navigation support
21
-
22
- ## ๐Ÿ“ฆ Installation
23
-
24
- ### NPM
25
-
26
- ```bash
27
- npm install yasgui-graph-plugin @zazuko/yasgui vis-network
28
- ```
29
-
30
- ```javascript
31
- import Yasgui from '@zazuko/yasgui';
32
- import GraphPlugin from 'yasgui-graph-plugin';
33
-
34
- Yasgui.Yasr.registerPlugin('Graph', GraphPlugin);
35
-
36
- const yasgui = new Yasgui(document.getElementById('yasgui'));
37
- ```
38
-
39
- ### CDN (UMD)
40
-
41
- ```html
42
- <!-- YASGUI -->
43
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazuko/yasgui@4/build/yasgui.min.css">
44
- <script src="https://cdn.jsdelivr.net/npm/@zazuko/yasgui@4/build/yasgui.min.js"></script>
45
-
46
- <!-- Graph Plugin -->
47
- <script src="https://cdn.jsdelivr.net/npm/yasgui-graph-plugin/dist/yasgui-graph-plugin.min.js"></script>
48
-
49
- <script>
50
- // Plugin auto-registers as 'graph'
51
- const yasgui = new Yasgui(document.getElementById('yasgui'));
52
- </script>
53
- ```
54
-
55
- ## ๐Ÿš€ Quick Start
56
-
57
- See the complete working example in [`demo/index.html`](./demo/index.html).
58
-
59
- ### Basic Usage
60
-
61
- ```javascript
62
- const yasgui = new Yasgui(document.getElementById('yasgui'), {
63
- requestConfig: {
64
- endpoint: 'https://dbpedia.org/sparql'
65
- }
66
- });
67
- ```
68
-
69
- ### Sample Queries
70
-
71
- **CONSTRUCT Query:**
72
- ```sparql
73
- PREFIX ex: <http://example.org/>
74
- PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
75
-
76
- CONSTRUCT {
77
- ex:Alice rdf:type ex:Person .
78
- ex:Alice ex:knows ex:Bob .
79
- ex:Alice ex:name "Alice" .
80
- ex:Bob rdf:type ex:Person .
81
- ex:Bob ex:name "Bob" .
82
- }
83
- WHERE {}
84
- ```
85
-
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
-
94
- After running the query, click the **"Graph"** tab to see the visualization.
95
-
96
- ## ๐ŸŽฎ User Guide
97
-
98
- ### Navigation
99
- - **Zoom**: Mouse wheel (scroll up = zoom in, scroll down = zoom out)
100
- - **Pan**: Click and drag the background
101
- - **Fit to View**: Click the "Zoom to Fit" button to center the entire graph
102
-
103
- ### Interaction
104
- - **Drag Nodes**: Click and drag any node to reposition it
105
- - **Tooltips**: Hover over nodes/edges for 300ms to see full details
106
-
107
- ### Understanding Colors
108
-
109
- | Color | Meaning | Example |
110
- |-------|---------|---------||
111
- | ๐Ÿ”ต Light Blue (#97C2FC) | URI nodes | `ex:Person`, `ex:Alice` |
112
- | ๐ŸŸข Light Green (#a6c8a6ff) | Literal values | `"Alice"`, `"30"^^xsd:integer` |
113
- | โšช Light Grey (#c5c5c5ff) | Blank nodes | `_:b1`, `_:addr1` |
114
- | ๐ŸŸ  Orange (#e15b13ff) | rdf:type objects (classes) | `ex:Person` in `ex:Alice rdf:type ex:Person` |
115
-
116
- ## โš™๏ธ Configuration
117
-
118
- The plugin uses sensible defaults but can be customized by extending the `GraphPlugin` class:
119
-
120
- ```javascript
121
- class CustomGraphPlugin extends GraphPlugin {
122
- constructor(yasr) {
123
- super(yasr);
124
- }
125
-
126
- // Override network options
127
- getNetworkOptions() {
128
- return {
129
- ...super.getNetworkOptions(),
130
- physics: {
131
- enabled: true,
132
- stabilization: { iterations: 100 } // Faster but less optimal layout
133
- }
134
- };
135
- }
136
- }
137
-
138
- Yasgui.Yasr.registerPlugin('customGraph', CustomGraphPlugin);
139
- ```
140
-
141
- ## ๐Ÿ”ง Development
142
-
143
- ### Build
144
-
145
- ```bash
146
- npm install
147
- npm run build
148
- ```
149
-
150
- Output: `dist/yasgui-graph-plugin.min.js`
151
-
152
- ### Local Testing
153
-
154
- 1. Build the plugin: `npm run build`
155
- 2. Open `example/index.html` in a browser
156
- 3. Try the sample queries in different tabs
157
-
158
- ### Code Quality
159
-
160
- ```bash
161
- npm run lint # ESLint check
162
- npm run format # Prettier format
163
- ```
164
-
165
- ## ๐Ÿ“š Documentation
166
-
167
- - **[Quickstart Guide](./specs/001-construct-graph-viz/quickstart.md)** - Installation, usage, troubleshooting
168
- - **[Data Model](./specs/001-construct-graph-viz/data-model.md)** - Entity definitions and relationships
169
- - **[Contracts](./specs/001-construct-graph-viz/contracts/)** - API specifications for YASR plugin and vis-network integration
170
- - **[Specification](./specs/001-construct-graph-viz/spec.md)** - Complete feature specification
171
- - **[Constitution](./. specify/memory/constitution.md)** - Project governance and principles
172
-
173
- ## ๐Ÿงช Browser Compatibility
174
-
175
- Tested on latest 2 versions of:
176
- - โœ… Chrome
177
- - โœ… Firefox
178
- - โœ… Safari
179
- - โœ… Edge
180
-
181
- Requires ES2018+ support and Canvas API.
182
-
183
- ## ๐Ÿค Contributing
184
-
185
- Contributions welcome! Please follow the project constitution (`.specify/memory/constitution.md`) for governance principles:
186
-
187
- 1. **Plugin-First Architecture** - No YASGUI core modifications
188
- 2. **Visualization Quality** - Performance (<2s for 1k nodes), accessibility (WCAG AA)
189
- 3. **Configuration Flexibility** - Sensible defaults, but customizable
190
- 4. **Browser Compatibility** - ES2018+, latest 2 browser versions
191
- 5. **Documentation** - Keep docs updated with changes
192
-
193
- ## ๐Ÿ“„ License
194
-
195
- [Apache 2.0](./LICENSE)
196
-
197
- ## ๐Ÿ™ Acknowledgments
198
-
199
- - Built with [vis-network](https://visjs.github.io/vis-network/) for graph rendering
200
- - Integrates with [YASGUI](https://github.com/zazuko/yasgui) SPARQL editor
201
- - Follows the [yasgui-geo](https://github.com/zazuko/yasgui-geo) plugin pattern
202
-
203
- ## ๐Ÿ“Š Project Status
204
-
205
- **Current Version**: 0.1.0 (MVP)
206
-
207
- **Implemented Features** (v0.1.0):
208
- - โœ… Basic graph visualization (US1)
209
- - โœ… Navigation controls (US2)
210
- - โœ… Color-coded nodes
211
- - โœ… Prefix abbreviation
212
- - โœ… Blank node support
213
- - โœ… Performance optimization
214
-
215
- **Planned Features** (Future):
216
- - โณ Enhanced tooltips with datatype display (US4)
217
- - โณ Manual testing across all browsers (US3 verification)
218
- - โณ Large graph optimization (>1k nodes)
219
- - โณ Custom color schemes
220
- - โณ Layout algorithm selection
221
-
222
- ## ๐Ÿ› Troubleshooting
223
-
224
- ### Plugin tab not showing
225
- - Verify plugin is registered correctly
226
- - Check browser console for errors
227
- - Verify YASGUI version is ^4.0.0
228
-
229
- ### Empty visualization
230
- - Ensure query type is **CONSTRUCT** or **DESCRIBE**
231
- - Confirm query returns triples (check "Table" or "Response" tab)
232
- - Verify results have RDF structure
233
-
234
- ### Performance issues
235
- - Limit results to <1000 nodes for best performance
236
- - Disable physics after initial layout
237
- - Consider using LIMIT clause in SPARQL query
238
-
239
- For more help, see [Quickstart Guide - Troubleshooting](./specs/001-construct-graph-viz/quickstart.md#troubleshooting).
240
-
241
- ## ๐Ÿ› ๏ธ Development
242
-
243
- ### Setup
244
-
245
- ```bash
246
- git clone https://github.com/yourusername/yasgui-graph-plugin.git
247
- cd yasgui-graph-plugin
248
- npm install
249
- ```
250
-
251
- ### Dev Workflow (Live Reload)
252
-
253
- The project supports **live development** - edit source files and see changes immediately without rebuilding:
254
-
255
- 1. **Start a local dev server** (any HTTP server will work):
256
- ```bash
257
- # Using Python
258
- python -m http.server 8000
259
-
260
- # Using Node.js (http-server)
261
- npx http-server -p 8000
262
-
263
- # Using VS Code Live Server extension
264
- # Right-click demo/index.html โ†’ "Open with Live Server"
265
- ```
266
-
267
- 2. **Open demo in browser**:
268
- ```
269
- http://localhost:8000/demo/index.html
270
- ```
271
-
272
- 3. **Edit source files** (e.g., `src/colorUtils.js`):
273
- ```javascript
274
- export function getNodeColor(node) {
275
- // Change colors here
276
- if (node.isBlankNode) return '#FF00FF'; // Magenta
277
- // ...
278
- }
279
- ```
280
-
281
- 4. **Refresh browser** - changes appear immediately! โšก
282
-
283
- The demo automatically loads ES modules directly from `src/` in development mode, so no rebuild is needed.
284
-
285
- ### Production Build
286
-
287
- Build the minified UMD bundle for distribution:
288
-
289
- ```bash
290
- npm run build
291
- ```
292
-
293
- Output: `dist/yasgui-graph-plugin.min.js` (bundled with vis-network)
294
-
295
- ### Testing
296
-
297
- ```bash
298
- npm test # Run all tests
299
- npm run lint # Check code style
300
- npm run format # Auto-fix formatting
301
- ```
1
+ # YASGUI Graph Plugin
2
+
3
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4
+ [![npm version](https://img.shields.io/npm/v/yasgui-graph-plugin.svg)](https://www.npmjs.com/package/yasgui-graph-plugin)
5
+
6
+ A YASGUI plugin for visualizing SPARQL CONSTRUCT and DESCRIBE query results as interactive graphs with nodes (subjects/objects) and edges (predicates).
7
+
8
+ ## โœจ Features
9
+
10
+ - **๐Ÿ”ท Interactive Graph Visualization**: Automatic force-directed layout with smooth physics-based positioning
11
+ - **๐ŸŽจ Smart Color Coding**:
12
+ - ๐Ÿ”ต Light Blue (#97C2FC) = URIs
13
+ - ๐ŸŸข Light Green (#a6c8a6ff) = Literals
14
+ - โšช Light Grey (#c5c5c5ff) = Blank nodes
15
+ - ๐ŸŸ  Orange (#e15b13ff) = rdf:type objects (classes)
16
+ - **๐Ÿ” Navigation**: Mouse wheel zoom, drag to pan, "Zoom to Fit" button
17
+ - **โœ‹ Drag & Drop**: Reorganize nodes by dragging them to new positions
18
+ - **๐Ÿ’ฌ Tooltips**: Hover for full URI/literal details (300ms delay)
19
+ - **โšก Performance**: Handles up to 1,000 nodes with <2s render time
20
+ - **โ™ฟ Accessible**: WCAG AA color contrast, keyboard navigation support
21
+
22
+ ## ๐Ÿ“ฆ Installation
23
+
24
+ ### NPM
25
+
26
+ ```bash
27
+ npm install yasgui-graph-plugin @zazuko/yasgui vis-network
28
+ ```
29
+
30
+ ```javascript
31
+ import Yasgui from '@zazuko/yasgui';
32
+ import GraphPlugin from 'yasgui-graph-plugin';
33
+
34
+ Yasgui.Yasr.registerPlugin('Graph', GraphPlugin);
35
+
36
+ const yasgui = new Yasgui(document.getElementById('yasgui'));
37
+ ```
38
+
39
+ ### CDN (UMD)
40
+
41
+ ```html
42
+ <!-- YASGUI -->
43
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazuko/yasgui@4/build/yasgui.min.css">
44
+ <script src="https://cdn.jsdelivr.net/npm/@zazuko/yasgui@4/build/yasgui.min.js"></script>
45
+
46
+ <!-- Graph Plugin -->
47
+ <script src="https://cdn.jsdelivr.net/npm/yasgui-graph-plugin/dist/yasgui-graph-plugin.min.js"></script>
48
+
49
+ <script>
50
+ // Plugin auto-registers as 'graph'
51
+ const yasgui = new Yasgui(document.getElementById('yasgui'));
52
+ </script>
53
+ ```
54
+
55
+ ## ๐Ÿš€ Quick Start
56
+
57
+ See the complete working example in [`demo/index.html`](./demo/index.html).
58
+
59
+ ### Basic Usage
60
+
61
+ ```javascript
62
+ const yasgui = new Yasgui(document.getElementById('yasgui'), {
63
+ requestConfig: {
64
+ endpoint: 'https://dbpedia.org/sparql'
65
+ }
66
+ });
67
+ ```
68
+
69
+ ### Sample Queries
70
+
71
+ **CONSTRUCT Query:**
72
+ ```sparql
73
+ PREFIX ex: <http://example.org/>
74
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
75
+
76
+ CONSTRUCT {
77
+ ex:Alice rdf:type ex:Person .
78
+ ex:Alice ex:knows ex:Bob .
79
+ ex:Alice ex:name "Alice" .
80
+ ex:Bob rdf:type ex:Person .
81
+ ex:Bob ex:name "Bob" .
82
+ }
83
+ WHERE {}
84
+ ```
85
+
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
+
94
+ After running the query, click the **"Graph"** tab to see the visualization.
95
+
96
+ ## ๐ŸŽฎ User Guide
97
+
98
+ ### Navigation
99
+ - **Zoom**: Mouse wheel (scroll up = zoom in, scroll down = zoom out)
100
+ - **Pan**: Click and drag the background
101
+ - **Fit to View**: Click the "Zoom to Fit" button to center the entire graph
102
+
103
+ ### Interaction
104
+ - **Drag Nodes**: Click and drag any node to reposition it
105
+ - **Tooltips**: Hover over nodes/edges for 300ms to see full details
106
+
107
+ ### Understanding Colors
108
+
109
+ | Color | Meaning | Example |
110
+ |-------|---------|---------||
111
+ | ๐Ÿ”ต Light Blue (#97C2FC) | URI nodes | `ex:Person`, `ex:Alice` |
112
+ | ๐ŸŸข Light Green (#a6c8a6ff) | Literal values | `"Alice"`, `"30"^^xsd:integer` |
113
+ | โšช Light Grey (#c5c5c5ff) | Blank nodes | `_:b1`, `_:addr1` |
114
+ | ๐ŸŸ  Orange (#e15b13ff) | rdf:type objects (classes) | `ex:Person` in `ex:Alice rdf:type ex:Person` |
115
+
116
+ ## โš™๏ธ Configuration
117
+
118
+ The plugin uses sensible defaults but can be customized by extending the `GraphPlugin` class:
119
+
120
+ ```javascript
121
+ class CustomGraphPlugin extends GraphPlugin {
122
+ constructor(yasr) {
123
+ super(yasr);
124
+ }
125
+
126
+ // Override network options
127
+ getNetworkOptions() {
128
+ return {
129
+ ...super.getNetworkOptions(),
130
+ physics: {
131
+ enabled: true,
132
+ stabilization: { iterations: 100 } // Faster but less optimal layout
133
+ }
134
+ };
135
+ }
136
+ }
137
+
138
+ Yasgui.Yasr.registerPlugin('customGraph', CustomGraphPlugin);
139
+ ```
140
+
141
+ ## ๐Ÿ”ง Development
142
+
143
+ ### Build
144
+
145
+ ```bash
146
+ npm install
147
+ npm run build
148
+ ```
149
+
150
+ Output: `dist/yasgui-graph-plugin.min.js`
151
+
152
+ ### Local Testing
153
+
154
+ 1. Build the plugin: `npm run build`
155
+ 2. Open `example/index.html` in a browser
156
+ 3. Try the sample queries in different tabs
157
+
158
+ ### Code Quality
159
+
160
+ ```bash
161
+ npm run lint # ESLint check
162
+ npm run format # Prettier format
163
+ ```
164
+
165
+ ## ๐Ÿ“š Documentation
166
+
167
+ - **[Quickstart Guide](./specs/001-construct-graph-viz/quickstart.md)** - Installation, usage, troubleshooting
168
+ - **[Data Model](./specs/001-construct-graph-viz/data-model.md)** - Entity definitions and relationships
169
+ - **[Contracts](./specs/001-construct-graph-viz/contracts/)** - API specifications for YASR plugin and vis-network integration
170
+ - **[Specification](./specs/001-construct-graph-viz/spec.md)** - Complete feature specification
171
+ - **[Constitution](./. specify/memory/constitution.md)** - Project governance and principles
172
+
173
+ ## ๐Ÿงช Browser Compatibility
174
+
175
+ Tested on latest 2 versions of:
176
+ - โœ… Chrome
177
+ - โœ… Firefox
178
+ - โœ… Safari
179
+ - โœ… Edge
180
+
181
+ Requires ES2018+ support and Canvas API.
182
+
183
+ ## ๐Ÿค Contributing
184
+
185
+ Contributions welcome! Please follow the project constitution (`.specify/memory/constitution.md`) for governance principles:
186
+
187
+ 1. **Plugin-First Architecture** - No YASGUI core modifications
188
+ 2. **Visualization Quality** - Performance (<2s for 1k nodes), accessibility (WCAG AA)
189
+ 3. **Configuration Flexibility** - Sensible defaults, but customizable
190
+ 4. **Browser Compatibility** - ES2018+, latest 2 browser versions
191
+ 5. **Documentation** - Keep docs updated with changes
192
+
193
+ ## ๐Ÿ“„ License
194
+
195
+ [Apache 2.0](./LICENSE)
196
+
197
+ ## ๐Ÿ™ Acknowledgments
198
+
199
+ - Built with [vis-network](https://visjs.github.io/vis-network/) for graph rendering
200
+ - Integrates with [YASGUI](https://github.com/zazuko/yasgui) SPARQL editor
201
+ - Follows the [yasgui-geo](https://github.com/zazuko/yasgui-geo) plugin pattern
202
+
203
+ ## ๐Ÿ“Š Project Status
204
+
205
+ **Current Version**: 0.1.0 (MVP)
206
+
207
+ **Implemented Features** (v0.1.0):
208
+ - โœ… Basic graph visualization (US1)
209
+ - โœ… Navigation controls (US2)
210
+ - โœ… Color-coded nodes
211
+ - โœ… Prefix abbreviation
212
+ - โœ… Blank node support
213
+ - โœ… Performance optimization
214
+
215
+ **Planned Features** (Future):
216
+ - โณ Enhanced tooltips with datatype display (US4)
217
+ - โณ Manual testing across all browsers (US3 verification)
218
+ - โณ Large graph optimization (>1k nodes)
219
+ - โณ Custom color schemes
220
+ - โณ Layout algorithm selection
221
+
222
+ ## ๐Ÿ› Troubleshooting
223
+
224
+ ### Plugin tab not showing
225
+ - Verify plugin is registered correctly
226
+ - Check browser console for errors
227
+ - Verify YASGUI version is ^4.0.0
228
+
229
+ ### Empty visualization
230
+ - Ensure query type is **CONSTRUCT** or **DESCRIBE**
231
+ - Confirm query returns triples (check "Table" or "Response" tab)
232
+ - Verify results have RDF structure
233
+
234
+ ### Performance issues
235
+ - Limit results to <1000 nodes for best performance
236
+ - Disable physics after initial layout
237
+ - Consider using LIMIT clause in SPARQL query
238
+
239
+ For more help, see [Quickstart Guide - Troubleshooting](./specs/001-construct-graph-viz/quickstart.md#troubleshooting).
240
+
241
+ ## ๐Ÿ› ๏ธ Development
242
+
243
+ ### Setup
244
+
245
+ ```bash
246
+ git clone https://github.com/yourusername/yasgui-graph-plugin.git
247
+ cd yasgui-graph-plugin
248
+ npm install
249
+ ```
250
+
251
+ ### Dev Workflow (Live Reload)
252
+
253
+ The project supports **live development** - edit source files and see changes immediately without rebuilding:
254
+
255
+ 1. **Start a local dev server** (any HTTP server will work):
256
+ ```bash
257
+ # Using Python
258
+ python -m http.server 8000
259
+
260
+ # Using Node.js (http-server)
261
+ npx http-server -p 8000
262
+
263
+ # Using VS Code Live Server extension
264
+ # Right-click demo/index.html โ†’ "Open with Live Server"
265
+ ```
266
+
267
+ 2. **Open demo in browser**:
268
+ ```
269
+ http://localhost:8000/demo/index.html
270
+ ```
271
+
272
+ 3. **Edit source files** (e.g., `src/colorUtils.js`):
273
+ ```javascript
274
+ export function getNodeColor(node) {
275
+ // Change colors here
276
+ if (node.isBlankNode) return '#FF00FF'; // Magenta
277
+ // ...
278
+ }
279
+ ```
280
+
281
+ 4. **Refresh browser** - changes appear immediately! โšก
282
+
283
+ The demo automatically loads ES modules directly from `src/` in development mode, so no rebuild is needed.
284
+
285
+ ### Production Build
286
+
287
+ Build the minified UMD bundle for distribution:
288
+
289
+ ```bash
290
+ npm run build
291
+ ```
292
+
293
+ Output: `dist/yasgui-graph-plugin.min.js` (bundled with vis-network)
294
+
295
+ ### Testing
296
+
297
+ ```bash
298
+ npm test # Run all tests
299
+ npm run lint # Check code style
300
+ npm run format # Auto-fix formatting
301
+ ```