@matdata/yasgui-graph-plugin 1.0.3 → 1.0.5
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/LICENSE +201 -201
- package/README.md +301 -301
- package/dist/index.d.ts +43 -0
- package/dist/yasgui-graph-plugin.cjs.js.map +1 -1
- package/dist/yasgui-graph-plugin.esm.js.map +1 -1
- package/dist/yasgui-graph-plugin.min.js.map +1 -1
- package/package.json +55 -48
package/README.md
CHANGED
|
@@ -1,301 +1,301 @@
|
|
|
1
|
-
# YASGUI Graph Plugin
|
|
2
|
-
|
|
3
|
-
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
|
-
[](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
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
|
+
[](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
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Type definitions for @matdata/yasgui-graph-plugin
|
|
2
|
+
// Project: https://github.com/Matdata-eu/yasgui-graph-plugin
|
|
3
|
+
|
|
4
|
+
declare module '@matdata/yasgui-graph-plugin' {
|
|
5
|
+
import type { Plugin } from '@zazuko/yasgui/build/ts/plugins';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* YASGUI plugin for visualizing SPARQL CONSTRUCT and DESCRIBE query results as interactive graphs
|
|
9
|
+
*/
|
|
10
|
+
export default class GraphPlugin extends Plugin {
|
|
11
|
+
/**
|
|
12
|
+
* Plugin priority (higher = shown first in tabs)
|
|
13
|
+
*/
|
|
14
|
+
static priority: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Plugin label for tab display
|
|
18
|
+
*/
|
|
19
|
+
static label: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Check if plugin can handle the current results
|
|
23
|
+
* @returns True if results are from CONSTRUCT or DESCRIBE query
|
|
24
|
+
*/
|
|
25
|
+
canHandleResults(): boolean;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Render the graph visualization
|
|
29
|
+
*/
|
|
30
|
+
draw(): void;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Download the current visualization as PNG
|
|
34
|
+
*/
|
|
35
|
+
download(): void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get vis-network configuration options
|
|
39
|
+
* @returns Network options for vis-network
|
|
40
|
+
*/
|
|
41
|
+
getNetworkOptions(): any;
|
|
42
|
+
}
|
|
43
|
+
}
|