Please show your support of Waihekepedia by adding a link to us from your web site. Waihekepedia T Shirts now available at the Ostend Market
Sparql Result Format Documentation
Step 1. Define one or more sparql endpoint in LocalSettings.php
$wgSparqlEndpointDefinition['<endpoint name>'] = array(You can optionally specify credentials for http basic authentication.
You can optionally specify a list of prefixes. These are automatically added to sparql query (No need to redefine each time).
Step 2. Export sparql result in different format using magic words described below
Html Table
Description
Usage
Parameters
Name | Description | Mandatory | Default value | Example | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
divId | Identifier of this element. Must be unique inside the page | True | |||||||||||||||||||||||||||||||||||||
sparqlEscapedQuery | Sparql query to execute | True | |||||||||||||||||||||||||||||||||||||
sparqlEndpoint | Name of the endpoint to invoke defined in LocalSettings.php | True | |||||||||||||||||||||||||||||||||||||
spinnerImagePath | Url of image to show while the query is in execution. | False | |||||||||||||||||||||||||||||||||||||
divStyle | css definitions to put inline the container div | False | |||||||||||||||||||||||||||||||||||||
tableClass | output html table css class | False | |||||||||||||||||||||||||||||||||||||
columnConfiguration | Javascript array of object for data presentation (see table below).
| False | columnConfiguration=[{queryField:'type_label', label:'Asset type', showLink:'false',cellValuePattern:'value={%s}'}] columnConfiguration=[{queryField:'totalCost', label:'Total cost', showLink:'false',cellValuePattern:'€ {%n[0,00.00]@it}'}] | ||||||||||||||||||||||||||||||||||||
cssEvenRowClass | Css class of even elements of output table | False | |||||||||||||||||||||||||||||||||||||
cssOddRowClass | Css class of odd elements of output table | False | |||||||||||||||||||||||||||||||||||||
cssEvenTdClass | Css class of all elements of all even rows of output table | False | |||||||||||||||||||||||||||||||||||||
cssOddTdClass | Css class of all elements of all odd rows of output table | False | |||||||||||||||||||||||||||||||||||||
noResultMessage | Text message to be shown when the query returns no elements | False | |||||||||||||||||||||||||||||||||||||
csvExport | true/false. If true, generates a link to download the content of the table as csv file | False | false | ||||||||||||||||||||||||||||||||||||
csvFileName | The name of the output csv file | False | export.csv | ||||||||||||||||||||||||||||||||||||
csvLinkLabel | Label of the link to download the csv | False | |||||||||||||||||||||||||||||||||||||
linkBasePath deprecated | ⧼sprf.param.linkBasePath⧽ | False |
Sparql query structure
CSV
Description
Usage
Parameters
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
divId | Identifier of this element. Must be unique inside the page | True | ||
sparqlEndpoint | Name of the endpoint to invoke defined in LocalSettings.php | True | ||
sparqlEscapedQuery | Sparql query to execute | True | ||
divStyle | css definitions to put inline the container div | False | ||
scriptPath deprecated | Value of variable {{SCRIPTPATH}} | False | ||
headerMapping | JSON object to map each column in the sparql query to another label | False | |headerMapping={comp_label:"Application Component",app_label:"Application", proc_label:"Business Process"} | |
filename | Name of the output csv file | False | export.csv | |
separator | Separator char to be used in csv file | False | ; | |
linkButtonLabel | If defined, the magic word will produce a <button> element with this parameter as label | False | ||
linkButtonCSSClass | if linkButtonLabel is defined you can specify the css class to the <button> element | False | ||
label | if linkButtonLabel is not defined, the magic word will produce a <a> element with this parameter as label | False | Download as CSV |
Sparql query structure
Pie Chart
Description
Usage
Parameters
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
divId | Identifier of this element. Must be unique inside the page | True | ||
sparqlEndpoint | Name of the endpoint to invoke defined in LocalSettings.php | True | ||
sparqlEscapedQuery | Sparql query to execute | True | ||
divStyle | css definitions to put inline the container div | False | ||
spinnerImagePath | Url of image to show while the query is in execution. | False | ||
divCssClass | Css class applied to container div | False | ||
divCssClassFullScreen | Css class applied to container div in fullscreen mode | False | ||
extraOption | You can specify as many extraOption parameter as you want. Each option must be specified in the following format: propName:propValue.The list of all supported options is listed in the table below. | False |
Extra Options
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
chart.title | Title of the chart | False | |extraOption=chart.title:New Title | |
chart.series.color | List of colour to use in series | False | |extraOption=chart.series.color:[ 'red','#000000','FFAACC'] | |
chart.serie.label | Label of the series | False | |extraOption=chart.serie.label:series label | |
chart.tooltip.label.link.show | true or false to specify if the label in tooltip is linkable | False | |extraOption=chart.tooltip.label.link.show:false | |
chart.tooltip.label.link.pattern | Pattern to generate the url in label link | False | |extraOption=chart.tooltip.label.link.pattern:http://www.google.it?q={%s} | |
chart.tooltip.label.pattern | Pattern applied to label in tooltip | False | {%s} | |extraOption=chart.tooltip.label.pattern:Category {%s} |
chart.tooltip.value.pattern | Pattern applied to the numeric value in tooltip | False | {%d} | |extraOption=chart.tooltip.value.pattern:{%d} € |
Sparql query structure
The query must adjust to the following rules:
- The first column in select list represent each slice of the pie.
- The second column in select list must be composed by numerical values.
select ?person count(?property) as ?num
Donut Chart
Description
Usage
Parameters
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
divId | Identifier of this element. Must be unique inside the page | True | ||
sparqlEndpoint | Name of the endpoint to invoke defined in LocalSettings.php | True | ||
sparqlEscapedQuery | Sparql query to execute | True | ||
divStyle | css definitions to put inline the container div | False | ||
spinnerImagePath | Url of image to show while the query is in execution. | False | ||
divCssClass | Css class applied to container div | False | ||
divCssClassFullScreen | Css class applied to container div in fullscreen mode | False | ||
extraOption | You can specify as many extraOption parameter as you want. Each option must be specified in the following format: propName:propValue.The list of all supported options is listed in the table below. | False |
Extra Options
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
chart.title | Title of the chart | False | |extraOption=chart.title:New Title |
Sparql query structure
The query must adjust to the following rules:
- The first column in select list represent each slice of the donut.
- The following columns in select list must be composed by numerical values. Each of these columns represent a numerical series.
select ?person count(?property) as ?num count(?property2)as ?num2
Bar Chart
Description
Usage
Parameters
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
divId | Identifier of this element. Must be unique inside the page | True | ||
sparqlEndpoint | Name of the endpoint to invoke defined in LocalSettings.php | True | ||
sparqlEscapedQuery | Sparql query to execute | True | ||
divStyle | css definitions to put inline the container div | False | ||
spinnerImagePath | Url of image to show while the query is in execution. | False | ||
divCssClass | Css class applied to container div | False | ||
divCssClassFullScreen | Css class applied to container div in fullscreen mode | False | ||
seriesConfiguration | JSON array to configure every series. For each element you can specify:
| False | |seriesConfiguration=[{label:'Applications', color:'blue',showLink:'true',assetLinkPattern:'http://www.google.it?q={%s}' },{label:'Components',color:'red' ,showLink:'true',assetLinkPattern:'http://www.google.it?q={%s}'} ] | |
extraOption | You can specify as many extraOption parameter as you want. Each option must be specified in the following format: propName:propValue.The list of all supported options is listed in the table below. | False |
Extra Options
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
chart.title | Title of the chart | False | |extraOption=sprf.options.chart.title:New title | |
chart.direction | Direction of bars (vertical or horizontal) | False | vertical | |extraOption=chart.direction:horizontal |
chart.bar.width | Width of the bar in pixels | False | auto | |extraOption=chart.bar.width:10 |
chart.bar.margin | Number of pixels between groups of bars at adjacent axis values | False | 8 | |extraOption=chart.bar.margin:10 |
chart.bar.padding | Number of pixels between adjacent bars at the same axis value | False | 10 | |extraOption=chart.bar.margin:10 |
chart.axis.x.label | Name of x axis | False | ||
chart.axis.y.label | Name of y axis | False | ||
chart.axis.x.label.font.size | Font size for x axis label | False | 14pt | |extraOption=chart.axis.x.label.font.size:20pt |
chart.axis.y.label.font.size | Font size for y axis label | False | 14pt | |extraOption=chart.axis.y.label.font.size:20pt |
chart.axis.x.font.size | Font size for values in x axis | False | 10pt | |extraOption=chart.axis.x.font.size:14pt |
chart.axis.y.font.size | Font size for values in y axis | False | 10pt | |extraOption=chart.axis.y.font.size:14pt |
chart.axis.x.angle | Angle of text of x axis values, measured clockwise | False | -30 | |extraOption=chart.axis.x.angle:-20 |
chart.axis.y.angle | Angle of text of y axis values, measured clockwise | False | 0 | |extraOption=chart.axis.y.angle:-20 |
chart.legend.show | True or false to specify to show the legend | False | true | |extraOption=chart.legend.show:false |
chart.legend.location | Location for legend. Possible values: nw, n, ne, e, se, s, sw, w | False | ne | |extraOption=chart.legend.location:s |
chart.height.automatic | Only for horizontal barchart it computes automatically the height of the container based on number of results | False | false | |extraOption=chart.height.automatic:true |
chart.axis.label.max.length | Maximum value for automatic height | False | 15 | |extraOption=chart.axis.label.max.length:30 |
Sparql query structure
The query must adjust to the following rules:
- The first column in select list represent each element in the x axis (for vertical chart) or y axis (for horizontal chart).
- The following columns in select list must be composed by numerical values. Each of these columns represent a numerical series.
select ?person count(?property) as ?num count(?property2)as ?num2
Bubble Chart
Description
Usage
Parameters
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
divId | Identifier of this element. Must be unique inside the page | True | ||
sparqlEndpoint | Name of the endpoint to invoke defined in LocalSettings.php | True | ||
sparqlEscapedQuery | Sparql query to execute | True | ||
divStyle | css definitions to put inline the container div | False | ||
spinnerImagePath | Url of image to show while the query is in execution. | False | ||
divCssClass | Css class applied to container div | False | ||
divCssClassFullScreen | Css class applied to container div in fullscreen mode | False | ||
extraOption | You can specify as many extraOption parameter as you want. Each option must be specified in the following format: propName:propValue.The list of all supported options is listed in the table below. | False |
Extra Options
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
chart.title | Title of the chart | False | |extraOption=sprf.options.chart.title:New title | |
chart.axis.x.label | Name of x axis | False | ||
chart.axis.y.label | Name of y axis | False | ||
chart.axis.x.label.font.size | Name of x axis | False | 14pt | |extraOption=chart.axis.x.label.font.size:20pt |
chart.axis.y.label.font.size | Font size for y axis label | False | 14pt | |extraOption=chart.axis.y.label.font.size:20pt |
chart.axis.x.font.size | Font size for values in x axis | False | 10pt | |extraOption=chart.axis.x.font.size:14pt |
chart.axis.y.font.size | Font size for values in y axis | False | 10pt | |extraOption=chart.axis.y.font.size:14pt |
chart.legend.column.asset | The column name in legend for asset element (the single bubble element name) | False | |extraOption= | |
chart.legend.column.radius | The column name in legend for the r coordinate | False | |extraOption= | |
chart.legend.show | True or false to specify to show the legend | False | |extraOption= | |
chart.tooltip.x.label | Name of x coordinate shown in tooltip | False | |extraOption=chart.tooltip.x.label: | |
chart.tooltip.y.label | Name of y coordinate shown in tooltip | False | |extraOption= | |
chart.tooltip.r.label | Name of r coordinate shown in tooltip | False | |extraOption= | |
chart.tooltip.asset.label.pattern | Text pattern applied to show the asset element (the single bubble element) in tooltip. Refer to current name using the placeholder {%s} | False | |extraOption= | |
chart.tooltip.asset.link.show | true or false if the asset label must be also a link | False | |extraOption= | |
chart.tooltip.asset.label.link.pattern | Text pattern to generate the link for asset label. Refer to current name using the placeholder {%s} | False | |extraOption= | |
chart.tooltip.x.value.pattern | Text pattern applied to show the value of x coordinate. Refer to current value using the placeholder {%d} | False | |extraOption= | |
chart.tooltip.y.value.pattern | Text pattern applied to show the value of y coordinate. Refer to current value using the placeholder {%d} | False | |extraOption= | |
chart.tooltip.r.value.pattern | Text pattern applied to show the value of r coordinate. Refer to current value using the placeholder {%d} | False | |extraOption= |
Sparql query structure
The query must adjust to the following rules:
- The first column in select list represent each bubble on the chart.
- The 2nd, 3rd e 4th column in select list must be composed by numerical values. They represent the x, y and r coordinate of the bubble.
select ?person count(?property) as ?x count(?property2) as ?y count(?property3) as ?r
Treemap
Description
Usage
Parameters
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
divId | Identifier of this element. Must be unique inside the page | True | ||
sparqlEndpoint | Name of the endpoint to invoke defined in LocalSettings.php | True | ||
sparqlEscapedQuery | Sparql query to execute | True | ||
divStyle | css definitions to put inline the container div | False | ||
spinnerImagePath | Url of image to show while the query is in execution. | False | ||
divCssClass | Css class applied to container div | False | ||
divCssClassFullScreen | Css class applied to container div in fullscreen mode | False | ||
rootElement | The top element in the hierarchy. This could be styled in different way from other nodes. If the sparql query return object uris you must specify the uri ot the root element. Otherwise you must specify the label. | True | ||
leavesLinkPattern | Pattern to generate url in leaves node. Refer to leaf value using {%s} | False | ||
openLinkOnLeaves | true/false. If specified on leaves node it will open the url specified. | False |
Sparql query structure
The query must adjust to the following rules:
- All rows must represent a couple: parent value e child value with an optional numerical value
- The first column is the parent. The second is the child. The third (optional) is the weight for leaves node.
- If the third column is not specified the weight of all leaves will be set to 1
select ?parent ?child
Node Graph
Description
Usage
Parameters
Name | Description | Mandatory | Default value | Example |
---|---|---|---|---|
divId | Identifier of this element. Must be unique inside the page | True | ||
sparqlEndpoint | Name of the endpoint to invoke defined in LocalSettings.php | True | ||
sparqlEscapedQuery | Sparql query to execute | True | ||
queryTimeout | Maximum time for execution of a query (in milliseconds) | False | 20000 | |
divStyle | css definitions to put inline the container div | False | ||
spinnerImagePath | Url of image to show while the query is in execution. | False | ||
divCssClass | Css class applied to container div | False | ||
nodeConfiguration | Configuration of nodes aspect based on their category (rdf:type). JSON syntax of array containing a definition for each node category. For each element you can specify:
| False | |nodeConfiguration=[ { category:"Application",nodeColor:"#000000", image:"{{filepath:Application_icon.png}}"}, { category:"Application Component",nodeColor:"#00FF00", image:"{{filepath:Component_icon.png}}"}, { category:"Person",nodeColor:"#FF0000",image:"{{filepath:Person.png}}", dataTypeProps:[ {prop:'foaf:name', format:'Name: {%s}'}, {prop:'foaf:surname', format:'Surname: {%s}'} ], objectProps:[ {prop:'skos:broader',direction:'OUT', label:'Has broader'} ]} ] | |
edgeConfiguration | Configuration of edges aspect based on the relationship. JSON syntax of array containing a definition for each object property. For each element you can specify:
| False | |edgeConfiguration=[{ relation:"Belongs to application",edgeColor:"#00FF00"}] | |
rootElement | The top element in the hierarchy. This could be styled in different way from other nodes. If the sparql query return object uris you must specify the uri ot the root element. Otherwise you must specify the label. | False | ||
rootElementColor | The color of rootElement node | False | ||
rootElementImage | The image of rootElement node (this will override the rootElementColor property) | False | ||
showLegend | true/false | False | ||
defaultNodeColor | Html default color for nodes (if not specified in nodeConfiguration param) | False | |defaultNodeColor=#CCC | |
defaultEdgeColor | Html default color for edge (if not specified in edgeConfiguration param) | False | |defaultEdgeColor=#CCC | |
splitQueryByUnion | If the sparql param contains UNION parts and this parameter is set to 'true' it will split the query with n unions in n query with 1 query condition. | False | ||
minZoom | Min value for zoom | False | ||
maxZoom | Max value for zoom | False | ||
layout | Name of layout to use. Possible values: dagre, random, preset, grid, circle, concentric, breadthfirst, cose. [1] | False | dagre | |
layoutOptions | Extra layout options. [1] | False | |layoutOptions={rankSep:200} | |
maxWordLength | Maximum word lenght in node label. | False | ||
maxLabelLength | Maximum label lenght | False | ||
nodeStyle | Style of all nodes. [1] | False | |nodeStyle={shape:'roundrectangle', width:120, height:80,'text-valign': 'center','text-halign': 'center','font-size':'12','border-color' : '#000','border-width' : 1,'text-max-width':120} | |
edgeStyle | Style of all edges [1] | False | ||
labelLinkPattern | Text pattern to generate the link of node label in tooltip. Refer to node label with placeholder {%s} | False | ||
categoryLinkPattern | Text pattern to generate the link of node category in tooltip. Refer to node category with placeholder {%s} | False | ||
maxNumNodes | Maximum number of nodes to be drawn. If the sparql query returns more records than this parameter no graph will be shown | False | 200 | |
action.fullscreen.visible since 1.0.15 | Specify if the fullscreen button must be visible or not | False | true | |action.fullscreen.visible=false |
action.donwload.image.visible since 1.0.15 | Specify if the download image button must be visible or not | False | true | action.donwload.image.visible|false |
action.zoom.controls.visible since 1.0.15 | Specify if zoom controls must be visible or not | False | true | |action.zoom.controls.visible=false |
Sparql query structure
The query must adjust to the following rules:
- The select list must contains exactly this variable names: ?parent_uri ?parent_name ?child_uri ?child_name ?parent_type ?parent_type_uri ?child_type ?child_type_uri ?relation_uri ?relation_name
select distinct ?parent_uri ?parent_name ?child_uri ?child_name ?parent_type ?parent_type_uri ?child_type ?child_type_uri ?relation_uri ?relation_name
Old Version (for retro-compatibility) Do not use!
The query must adjust to the following rules:
- The select list must contains exactly this values: ?parent_name ?child_name ?parent_type ?child_type ?relation_name
select distinct ?parent_name ?child_name ?parent_type ?child_type ?relation_name