GSS-Cogs / chart-builder

The Chart Builder is a proof-of-concept app to understand the feasibility of using a CSV file (or SPARQL query) to generate and customise a chart or data visualisation
https://chart-builder-no4vxskx7a-nw.a.run.app
2 stars 0 forks source link

Conditionally load Plotly basic or geo bundles #162

Closed charlesons closed 1 year ago

charlesons commented 1 year ago

Notes:

We have to lazily load Plotly to prevent SSR errors (as in the previous implementation) The sub component approach was necessary because there's no way to conditionally and lazily load and use the sub bundles in one component. Solution assumes bundles to be installed locally:

In dd-cms:

yarn add plotly.js-geo-dist-min -W
yarn add plotly.js-basic-dist-min -W

In Chart builder:

yarn add plotly.js-geo-dist-min
yarn add plotly.js-basic-dist-min

Closes #138

charlesons commented 1 year ago
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX geo: <http://statistics.data.gov.uk/def/statistical-geography#>
PREFIX data: <http://gss-data.org.uk/data/gss_data/climate-change/beis-2005-to-2019-local-authority-carbon-dioxide-co2-emissions#>
PREFIX dim: <http://gss-data.org.uk/data/gss_data/climate-change/beis-2005-to-2019-local-authority-carbon-dioxide-co2-emissions#dimension/>
PREFIX meas: <http://gss-data.org.uk/def/climate-change/measure/>

SELECT ?geography_uri ?label  (ROUND((SUM(xsd:float(?val)) * 100) / 100) AS ?values)
WHERE {
  ?obs qb:dataSet data:dataset ;
       dim:year <http://reference.data.gov.uk/id/year/2019> ;
       dim:local-authority-code ?geography_uri ;
       meas:territorial-emissions ?val .

       FILTER(?geography_uri != <http://statistics.data.gov.uk/id/statistical-geography/N92000002>)

    OPTIONAL { ?geography_uri geo:officialname ?label }
}
GROUP BY ?geography_uri ?label
ORDER BY ASC(?geography_uri)
charlesons commented 1 year ago

Comment above has SPARQL that can be used to test maps in standalone Chart builder