Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render WDQG-visualisations in page, instead of using iframes. #1411

Open
rasmuserik opened this issue Apr 2, 2021 · 4 comments
Open

Render WDQG-visualisations in page, instead of using iframes. #1411

rasmuserik opened this issue Apr 2, 2021 · 4 comments
Labels
JavaScript some Scholia code is in JavaScript visualization the way query results are rendered
Milestone

Comments

@rasmuserik
Copy link
Collaborator

It might be possible to use the code from wikidata-query-gui to render the visualisations directly in the page instead of including them as iframes. This could help with several existing issues, such as #1367, #1026, #1374, #394, #301, #5, #1246 etc.

The first step will be a proof-of-concept to determine whether it is feasible to use WDQG in this way. Then we probably need to make changes to WDQG, as well as changing the {{ sparql_to_iframe(...) }} within Scholia. Hopefully our changes to WDQG can also go upstream.

@rasmuserik
Copy link
Collaborator Author

I am working on this.

(I tried to assign the issue to myself, – but do not have the permissions on the repo to do this yet).

@rasmuserik
Copy link
Collaborator Author

Status update:

This is more complex than I hoped: the code in ResultView.js of wikidata-query-gui assumes that there is only one ResultView in the page, – so we cannot just replace the iframe, with code similar to embed.html/embedInit.js from WDQG, but in addition, we also need to reimplement the functionality of ResultView.

While I see if this is feasible, – I also streamline the way it is going to be embedded, – the plan is that sparql queries can be embedded in html like:

<script type="sparql/wikidata-query-gui">
#defaultView:Graph
SELECT
  ?citing_work ?citing_workLabel ?rgb
  ?cited_work ?cited_workLabel
WITH {
  SELECT (COUNT(*) AS ?count) ?citing_work WHERE {
 [...]
</script>

And then the script-tag will be replaced with the actual element when the document is loaded.

The sparql-file wil just be included with a template like:

{{ sparql_wikidata_query_gui('citation-graph') }} 

(none of this is ready yet)

Work on the issue happens in this branch: https://github.com/rasmuserik/scholia/tree/1411-wdqg-in-page-not-iframe (currently the branch also includes some temporary development-code that will be removed before pull-requesting)

rasmuserik added a commit to rasmuserik/scholia that referenced this issue Apr 9, 2021
@rasmuserik
Copy link
Collaborator Author

Status update:
I've made an early proof-of-concept that can render several visualisations within the same page, without iframes.
It currently only works with "Graph" visualisation type, but I will look into getting the others to work too.

We only get the raw visualisations, and not the entire wikidata-query-gui UI. If this is a problem, we need to find another way.

I have also greped through the code, and it seems like we are using the following visualisation types, which needs to be tested:

     22 :BarChart
     19 :Table
     19 :BubbleChart
     17 :Graph
      8 :Map
      8 :LineChart
      7 :Timeline
      5 :ImageGrid
      3 :ScatterChart
      2 :Map{"markercluster":true}.
      1 :TreeMap
      1 :Tree
      1 :Timeline{"hide": ["?end_time", "?start_time"]}
      1 :Map{"layer": "?counts"}

The next step is to change the code from proof-of-concept to be actually usable/mergeable into production, and support/test with above types.

@Daniel-Mietchen Daniel-Mietchen added the JavaScript some Scholia code is in JavaScript label Apr 12, 2021
@Daniel-Mietchen Daniel-Mietchen added this to the 30 April 2021 milestone Apr 12, 2021
@Daniel-Mietchen Daniel-Mietchen added the visualization the way query results are rendered label Apr 12, 2021
@fnielsen
Copy link
Collaborator

"{"hide": ["?end_time", "?start_time"]}" are parameters that are available for some of the visualizations.

I have checked http://127.0.0.1:8100/dev/Q21090025 and it looks fine. I hope that the final version would be able to display some for feedback while it is querying and an indication of empty if there is no graph.

I am wondering whether the window size can be controled, e.g., to be made smaller if there is no results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JavaScript some Scholia code is in JavaScript visualization the way query results are rendered
Projects
Development

No branches or pull requests

4 participants