question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jinja template + dataframe access from Separator'esque Viz

See original GitHub issue

Make sure these boxes are checked before submitting your issue - thank you!

I have checked the superset logs for python stacktraces and included it here as text if any

  • I have checked the superset logs for python stacktraces and included it here as text if any
  • I have reproduced the issue with at least the latest released version of superset
  • I have checked the issue tracker for the same issue and I haven’t found one similar

Superset version

0.26

Expected results

A Separator’esque widget that can render not just html or text, but can interpolate variables and even include branching logic. I’d imagine that being able to insert Jinja templating with access to the pandas dataframe would suffice.

The reason for it, is that I want to create more descriptive text that might help to explain the data being visualised. For example, the final rendered text may look something like:

“USA’s population is growing slower (by 5%) than Australia’s”

And the Jinja template may look something like (It’s been years since I’ve done Jinja, so forgive any errors):

  <text>
     {% if df[df.country == 'USA'].growth <  if df[df.country == 'Australia'].growth %}
     USA's population is growing slower by ( {{ df[df.country == 'USA'].growth }} )
     than Australia's.
     {% else %}
     USA's population is growing faster than Australia's.
     {% endif %}
   </text>

I have spent only 5 minutes looking at this, but I suspect we would need a viz object that builds a dataframe based on the form data (i.e columns, metrics, group by etc) as other Viz objects do, but also have a textarea like MarkupViz to save our template.

Anyway, the implementation details would need to be worked out, but for me this would be a great addition as well as for others potentially.

Thoughts ?

Actual results

This feature does not exist AFAIK.

Steps to reproduce

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
kalium99commented, Sep 5, 2018

Here’s a screen-shot of the first iteration of it.

jinja_viz

2reactions
kalium99commented, Oct 1, 2018

Sorry, just seeing this comment now. I have been using it on our local Superset instance. Will push a patch up this evening but from memory it doesn’t look totally different to yours @ankoh

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jinja template + dataframe access from Separator'esque Viz
A Separator'esque widget that can render not just html or text, but can interpolate variables and even include branching logic. I'd imagine that ......
Read more >
Iterate over pandas dataframe in jinja2 - python - Stack Overflow
Now I want to make a select dropdown in jinja2. But I cannot find a way to loop over the dataframe in jinja2....
Read more >
Template Designer Documentation - Jinja
A template contains variables and/or expressions, which get replaced with values when a template is rendered; and tags, which control the logic of...
Read more >
DataFrame — Panel v0.14.2
The DataFrame widget allows displaying and editing a pandas DataFrame. ... This results in no horizontal scrollbar showing up, but data can get...
Read more >
Primer on Jinja Templating - Real Python
Get Started With Jinja. Install Jinja; Render Your First Jinja Template; Use an External File as a Template. Control the Flow in Jinja....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found