JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 74
  • Score
    100M100P100Q110012F
  • License Apache-2.0

YASGUI plugin for visualizing SPARQL CONSTRUCT query results as interactive graphs

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@matdata/yasgui-graph-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    YASGUI Graph Plugin

    License npm version

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

    โœจ Features

    • ๐Ÿ”ท Interactive Graph Visualization: Automatic force-directed layout with smooth physics-based positioning
    • ๐ŸŽจ Smart Color Coding:
      • ๐Ÿ”ต Blue = URIs
      • ๐ŸŸข Green = rdf:type objects (classes)
      • ๐Ÿ”˜ Grey = Literals
      • ๐ŸŸก Yellow = Blank nodes
    • ๐Ÿ” Navigation: Mouse wheel zoom, drag to pan, "Zoom to Fit" button
    • โœ‹ Drag & Drop: Reorganize nodes by dragging them to new positions
    • ๐Ÿ’ฌ Tooltips: Hover for full URI/literal details (300ms delay)
    • โšก Performance: Handles up to 1,000 nodes with <2s render time
    • โ™ฟ Accessible: WCAG AA color contrast, keyboard navigation support

    ๐Ÿ“ฆ Installation

    NPM

    npm install yasgui-graph-plugin @zazuko/yasgui vis-network
    import Yasgui from '@zazuko/yasgui';
    import GraphPlugin from 'yasgui-graph-plugin';
    
    Yasgui.Yasr.registerPlugin('Graph', GraphPlugin);
    
    const yasgui = new Yasgui(document.getElementById('yasgui'));

    CDN (UMD)

    <!-- YASGUI -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazuko/yasgui@4/build/yasgui.min.css">
    <script src="https://cdn.jsdelivr.net/npm/@zazuko/yasgui@4/build/yasgui.min.js"></script>
    
    <!-- Graph Plugin -->
    <script src="https://cdn.jsdelivr.net/npm/yasgui-graph-plugin/dist/yasgui-graph-plugin.min.js"></script>
    
    <script>
      // Plugin auto-registers as 'graph'
      const yasgui = new Yasgui(document.getElementById('yasgui'));
    </script>

    ๐Ÿš€ Quick Start

    See the complete working example in demo/index.html.

    Basic Usage

    const yasgui = new Yasgui(document.getElementById('yasgui'), {
      requestConfig: { 
        endpoint: 'https://dbpedia.org/sparql' 
      }
    });

    Sample CONSTRUCT Query

    PREFIX ex: <http://example.org/>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    
    CONSTRUCT {
      ex:Alice rdf:type ex:Person .
      ex:Alice ex:knows ex:Bob .
      ex:Alice ex:name "Alice" .
      ex:Bob rdf:type ex:Person .
      ex:Bob ex:name "Bob" .
    }
    WHERE {}

    After running the query, click the "Graph" tab to see the visualization.

    ๐ŸŽฎ User Guide

    • Zoom: Mouse wheel (scroll up = zoom in, scroll down = zoom out)
    • Pan: Click and drag the background
    • Fit to View: Click the "Zoom to Fit" button to center the entire graph

    Interaction

    • Drag Nodes: Click and drag any node to reposition it
    • Tooltips: Hover over nodes/edges for 300ms to see full details

    Understanding Colors

    Color Meaning Example
    ๐Ÿ”ต Blue URI nodes ex:Person, ex:Alice
    ๐ŸŸข Green rdf:type objects (classes) ex:Person in ex:Alice rdf:type ex:Person
    ๐Ÿ”˜ Grey Literal values "Alice", "30"^^xsd:integer
    ๐ŸŸก Yellow Blank nodes _:b1, _:addr1

    โš™๏ธ Configuration

    The plugin uses sensible defaults but can be customized by extending the GraphPlugin class:

    class CustomGraphPlugin extends GraphPlugin {
      constructor(yasr) {
        super(yasr);
      }
      
      // Override network options
      getNetworkOptions() {
        return {
          ...super.getNetworkOptions(),
          physics: {
            enabled: true,
            stabilization: { iterations: 100 } // Faster but less optimal layout
          }
        };
      }
    }
    
    Yasgui.Yasr.registerPlugin('customGraph', CustomGraphPlugin);

    ๐Ÿ”ง Development

    Build

    npm install
    npm run build

    Output: dist/yasgui-graph-plugin.min.js

    Local Testing

    1. Build the plugin: npm run build
    2. Open example/index.html in a browser
    3. Try the sample queries in different tabs

    Code Quality

    npm run lint    # ESLint check
    npm run format  # Prettier format

    ๐Ÿ“š Documentation

    • Quickstart Guide - Installation, usage, troubleshooting
    • Data Model - Entity definitions and relationships
    • Contracts - API specifications for YASR plugin and vis-network integration
    • Specification - Complete feature specification
    • [Constitution](./. specify/memory/constitution.md) - Project governance and principles

    ๐Ÿงช Browser Compatibility

    Tested on latest 2 versions of:

    • โœ… Chrome
    • โœ… Firefox
    • โœ… Safari
    • โœ… Edge

    Requires ES2018+ support and Canvas API.

    ๐Ÿค Contributing

    Contributions welcome! Please follow the project constitution (.specify/memory/constitution.md) for governance principles:

    1. Plugin-First Architecture - No YASGUI core modifications
    2. Visualization Quality - Performance (<2s for 1k nodes), accessibility (WCAG AA)
    3. Configuration Flexibility - Sensible defaults, but customizable
    4. Browser Compatibility - ES2018+, latest 2 browser versions
    5. Documentation - Keep docs updated with changes

    ๐Ÿ“„ License

    Apache 2.0

    ๐Ÿ™ Acknowledgments

    ๐Ÿ“Š Project Status

    Current Version: 0.1.0 (MVP)

    Implemented Features (v0.1.0):

    • โœ… Basic graph visualization (US1)
    • โœ… Navigation controls (US2)
    • โœ… Color-coded nodes
    • โœ… Prefix abbreviation
    • โœ… Blank node support
    • โœ… Performance optimization

    Planned Features (Future):

    • โณ Enhanced tooltips with datatype display (US4)
    • โณ Manual testing across all browsers (US3 verification)
    • โณ Large graph optimization (>1k nodes)
    • โณ Custom color schemes
    • โณ Layout algorithm selection

    ๐Ÿ› Troubleshooting

    Plugin tab not showing

    • Ensure query type is CONSTRUCT (not SELECT/ASK/DESCRIBE)
    • Check browser console for errors
    • Verify YASGUI version is ^4.0.0

    Empty visualization

    • Confirm CONSTRUCT query returns triples (check "Table" or "Response" tab)
    • Verify results have subject/predicate/object structure

    Performance issues

    • Limit results to <1000 nodes for best performance
    • Disable physics after initial layout (automatic)
    • Consider using LIMIT clause in SPARQL query

    For more help, see Quickstart Guide - Troubleshooting.

    ๐Ÿ› ๏ธ Development

    Setup

    git clone https://github.com/yourusername/yasgui-graph-plugin.git
    cd yasgui-graph-plugin
    npm install

    Dev Workflow (Live Reload)

    The project supports live development - edit source files and see changes immediately without rebuilding:

    1. Start a local dev server (any HTTP server will work):

      # Using Python
      python -m http.server 8000
      
      # Using Node.js (http-server)
      npx http-server -p 8000
      
      # Using VS Code Live Server extension
      # Right-click demo/index.html โ†’ "Open with Live Server"
    2. Open demo in browser:

      http://localhost:8000/demo/index.html
    3. Edit source files (e.g., src/colorUtils.js):

      export function getNodeColor(node) {
        // Change colors here
        if (node.isBlankNode) return '#FF00FF'; // Magenta
        // ...
      }
    4. Refresh browser - changes appear immediately! โšก

    The demo automatically loads ES modules directly from src/ in development mode, so no rebuild is needed.

    Production Build

    Build the minified UMD bundle for distribution:

    npm run build

    Output: dist/yasgui-graph-plugin.min.js (bundled with vis-network)

    Testing

    npm test          # Run all tests
    npm run lint      # Check code style
    npm run format    # Auto-fix formatting