JSPM

  • Created
  • Published
  • Downloads 1565
  • Score
    100M100P100Q105242F
  • License MIT

Yet Another SPARQL GUI

Package Exports

  • @triply/yasgui

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 (@triply/yasgui) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

YASGUI

YASGUI (Yet Another SPARQL Graphical User Interface) is the most popular SPARQL editor and result set visualizer.

This file only includes user documentation; see [DEV.md] for the developer documentation.

Usage

YASGUI can be used locally and online.

Running YASGUI locally

The following command starts YASGUI at http://localhost:4002:

npm run dev

Running YASGUI online

This is the minimal HTML file that is needed in order to run YASGUI online:

<html>
  <head>
    <!-- TODO: CSS INCLUDE -->
  </head>
  <body>
    <!-- TODO: YASGUI DOM ELEMENT -->
    <!-- TODO: JS INCLUDE -->
  </body>
</html>

Bootstrap integration

Some aspects of YASGUI styling conflict with Bootstrap. In order to make YASGUI play nice with Bootstrap, the following dependency must also be included in the head tag of the HTML page:

<link href="https://nightly.yasgui.triply.cc/yasgui.bootstrap.css" rel="stylesheet" type="text/css">

Internet Explorer 11 support

In order to support IE11, the following dependency must be included at the end of the body tag of the HTML page:

<script src="https://nightly.yasgui.triply.cc/yasgui.polyfill.min.js"></script>

SPARQL Editor (YASQE)

Supported key combinations

The following key combinations are supported within the SPARQL Editor (YASQE).

We sometimes use the notion of a group, wich is either one word (space-delimited sequence of non-space characters), a sequences of multiple whitespace characters, or one newline.

Key combination Behavior
Alt + Left Move the cursor to the beginning of the current line.
Alt + Right Move the cursor to the end of the current line.
Alt + U Redo the last change within the current selection.
Ctrl + Backspace Delete to the beginning of the group before the cursor.
Ctrl + Delete Delete to the beginning of the group after the cursor.
Ctrl + End Move the cursor to the end of the query.
Ctrl + Home Move the cursor to the start of the query.
Ctrl + Left Move the cursor to the left of the group before the cursor.
Ctrl + Right Move the cursor to the right of the group the cursor.
Ctrl + [ Decrements the indentation for the current line or the lines involved in the current selection.
Ctrl + ] Increments the indentation for the current line or the lines involved in the current selection.
Ctrl + / Toggles on/off the commenting of the current line or the lines involved in the current selection.
Ctrl + A Select the whole query.
Ctrl + D Deletes the current line or all lines involved in the current selection.
Ctrl + U Unfo the last change within the current selection.
Ctrl + Y Redo the last undone edit action.
Ctrl + Z Undo the last edit action.
Ctrl + Shift + F Auto-formats the whole query or the lines involved in the current selection.
Shift + Tab Auto-indents the current line or the lines involved in the current selection.
Tab Indents the current line or the lines involved in the current selection.

SPARQL Result Set Viewer (YASR)

SPARQL 2D

The following SPARQL variable names are used in the 2D visualization:

Variable name Purpose
?shape An arbitrary variable name that gets bound to literals with datatype geo:wktLiteral, and whose name is the prefix of the other variable names in this table.
?shapeColor The color of the shape bound to ?shape.
?shapeLabel The text or HTML content of popups that appear when clicking the shape bound to ?shape.

Color values

Variable ?shapeColor can bind values of the following types:

  • CSS color names
  • RGB color codes
  • HSL color codes
  • Gradients: Strings of the form PALETTE,VALUE, where VALUE is a floating-point number between 0.0 and 1.0 and PALETTE is the name of a color palette. The following two libraries define the supported color palette names:

SPARQL 3D

In addition to the variables supported by SPARQL 2D, the following SPARQL variable names are used in the 3D visualization:

Variable name Purpose
?shapeHeight The height in meters of the 2.5D shape that is based on the 2D shape that is bound to ?shape.
?shapeOffset The height in meters at which the 2.5D shape that is based on the 2D shape that is bound to ?shape starts.

The following variable names are used in the gallery visualization:

Variable name Purpose
?widget A plain string or a literal with datatype IRI rdf:HTML, which is used as the content of the widgets that are displayed in gallery rows.

SPARQL Timeline

The SPARQL timeline allows you to represent data in a Timeline To get started with this visualization you need at least a result containing a ?eventStart or ?eventDate with either a ?eventDescription, ?eventLabel or a ?eventMedia. (Combinations are also possible) The following parameters are supported:

Variable name Purpose
?eventStart A date when an event started
?eventEnd A date when an event Stopped
?eventDate A date when an event happened
?eventDescription Text/HTML about the event
?eventLabel Text/HTML title
?eventMedia Link to most forms of media see documentation for which type of links are supported

SPARQL Templating

It is often useful to create HTML snippets within a SPARQL query: this allows for moderately intuitive and human-readable visualizations of query results (e.g., in SPARQL Gallery, SPARQL 2D, or SPARQL 3D).

Perfoming all string insertions in SPARQL works, but results in queries that are difficult to read and maintain:

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix rvo: <https://data.labs.pdok.nl/def/>
select * {
  [ a rvo:Land;
    rdfs:label ?land;
    rvo:hoofdstad/rdfs:label ?hoofdstad;
    rvo:munteenheid/rdfs:label ?munteenheid;
    rvo:vlag ?vlag].
    bind(strdt(concat(
         '<h1>',str(?land),'</h1>',
         '<figure>',
           '<img src="',str(?vlag),'" style="width: 300px;">',
           '<figcaption>In ',str(?land),' hanteert men als munteenheid de ',str(?munteenheid),'. De hoofdstad van ',str(?land),' is ',str(?hoofdstad),'.</figcaption>',
         '</figure>'), rdf:HTML, ?widget))
}

YASGUI introduces SPARQL Templating, which allows one large string to be used, rather than a large number of small strings that are arguments to concat/n. SPARQL variables ?abc can be inserted into this one large string by using the {{abc}} templating notation.

In order for a SPARQL variable to be used in this way, it must occur in the outer projection, because YASGUI (and not the server) performs template substitution.

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix rvo: <https://data.labs.pdok.nl/def/>
select * {
  [ a rvo:Land;
    rdfs:label ?land;
    rvo:hoofdstad/rdfs:label ?hoofdstad;
    rvo:munteenheid/rdfs:label ?munteenheid;
    rvo:vlag ?vlag].
  bind('''
       <h1>{{land}}</h1>
         <figure>
           <img src={{vlag}} style="width: 300px;">
           <figcaption>In {{land}} hanteert men als munteenheid de {{munteenheid}}. De hoofdstad van {{land}} is {{hoofdstad}}.</figcaption>
         </figure>'''^^rdf:HTML as ?widget)
}