Description

A named query template determines how query results from a Named Query are displayed. Each template is associated with a Named Query using the SPARQL comment # @view. When this comment is present in the query, the queries' view tab will return the markup in the template. The template can then use JavaScript to load the query results (shown below) or if the query has exactly one variable in the SELECT clause, the template can walk the graph from the results of that variable binding as described in View Templates for Named Queries.

Named Query code

# @view pie-chart.xhtml
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
PREFIX vcard:<http://www.w3.org/2006/vcard/ns#>
PREFIX directory:<http://dir.w3.org/rdf/2012/directory/>
SELECT ?label (count(distinct ?proj) as ?value) {
    ?proj directory:isOrganizationType [ skos:prefLabel ?label ]
} GROUP BY ?label ORDER BY desc(?value)

View template code

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Pie Chart</title>
    <script src="https://www.google.com/jsapi" type="text/javascript"> </script>
    <script type="text/javascript">
        google.load("visualization", "1", {callback: function(){
            var chart = new google.visualization.ChartWrapper({
                dataSourceUrl:"?results",
                options:{"hasLabelsColumn":true,is3D:false,height:300},
                chartType:"PieChart"
            });
            chart.setContainerId("pie-chart");
            chart.draw();
        }});
    </script>
</head>
<body>
    <h1>Pie Chart</h1>
    <div id="pie-chart" class="chart" style="height:300px;width:400px"></div>
</body>
</html>