visualize-admin / visualization-tool

The tool for visualizing Swiss Open Government Data. Project ownership: Federal Office for the Environment FOEN
https://visualize.admin.ch
BSD 3-Clause "New" or "Revised" License
30 stars 3 forks source link

Scatter-plot bug in BFE-Cube in Visualize #1114

Closed CDiGallo closed 6 months ago

CDiGallo commented 1 year ago

Describe the bug Creating a Scatter-plot in this Cube creates an error, which persists in other Charttypes.

To Reproduce open: https://int.visualize.admin.ch/en/create/JJ3CzLBe5UaC?dataSource=Int (or https://int.[visualize.admin.ch](https://int.visualize.admin.ch/en/v/BVXg0G9INLQR?dataSource=Int)/en/v/BVXg0G9INLQR?dataSource=Int) then create bar-chart. everything is fine. create scatter plot - see error (it is then also not possible to make a sparql-query)

Expected behavior no error but a plot of different energy-containers

CDiGallo commented 1 year ago

This does not have any priority for anyhting I do. I stumbled upon this by accident. I try to be simple: me see bug, me reports bug

bprusinowski commented 1 year ago

Hi @CDiGallo, thanks for reporting the bug!

It seems that it's somehow connected to how the cube is structured – the http://openenergy-platform.org/ontology/oeo/BFO_0000015 (Rubrik DE) dimension is of a langString type, and the filtering won't work due to that reason (at least that's how we handle such dimensions in Visualize, see https://github.com/visualize-admin/visualization-tool/issues/319).

The exact query that is generated when we want to fetch the observations (the place where the error happens) looks like this:

SELECT DISTINCT ?dimension0 ?dimension1 ?dimension2 ?dimension3 ?dimension4 ?dimension5 ?dimension6 ?dimension7 ?dimension8 ?dimension9 ?dimension10 ?dimension11 ?dimension12 ?dimension13 ?dimension14 WHERE {
  <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/8> <https://cube.link/observationSet> ?observationSet0 .
  ?observationSet0 <https://cube.link/observation> ?source0 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/jahr> ?dimension0 .
  ?source0 <http://openenergy-platform.org/ontology/oeo/BFO_0000015> ?dimension1 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/holzenergie-TJ> ?dimension2 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/kohle-TJ> ?dimension3 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/muell-un-industrieabfaelle-TJ> ?dimension4 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/rohoel-TJ> ?dimension5 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/erdoelprodukte-TJ> ?dimension6 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/gas-TJ> ?dimension7 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/wasserkraft-TJ> ?dimension8 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/kernbrennstoffe-TJ> ?dimension9 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/uebrige-erneuerbare-TJ> ?dimension10 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/elektrizitaet-TJ> ?dimension11 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/fernwaerme-TJ> ?dimension12 .
  ?source0 <https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/total-TJ> ?dimension13 .
  ?source0 <http://purl.org/linked-data/cube#order> ?dimension14 .
  FILTER (
    (?dimension1 = "Bruttoverbrauch"@)
  )
}
GROUP BY ?dimension0 ?dimension1 ?dimension2 ?dimension3 ?dimension4 ?dimension5 ?dimension6 ?dimension7 ?dimension8 ?dimension9 ?dimension10 ?dimension11 ?dimension12 ?dimension13 ?dimension14

(see the filtering clause, where we have @ sign, but we miss the language to filter the results by).

Also, apart from this issue, it seems that generally something is not right with the data, as there is only one dimension (http://openenergy-platform.org/ontology/oeo/BFO_0000015) and 14 measures. I think that at least the https://energy.ld.admin.ch/sfoe/bfe_ogd115_gest_bilanz/jahr dimension should actually be a dimension and not measure (it should be marked as GeneralDateTimeDescription in the Cube creator, and not have custom "yr" unit, but actual Year unit. I think there might be such option selectable in the CC?).

We had similar problems reported before (e.g. here https://github.com/visualize-admin/visualization-tool/issues/1001), and it seems that the column type should be marked as string instead of langString. Also, each observation should have a unique key defined by taking its values for each key dimension together – now we have duplicated values due to having only one key dimension (Rubrik DE).

Let me know if this makes sense and if you need more support :) I think the problem should be solved once above suggestions are implemented, but it also might turn out to be something else 👀

sosiology commented 6 months ago

Closing this issue. Please reopen if more support is needed.