You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We often (ab)use Redash's ability to display arbitrary HTML in table visualizations. However, writing HTML within SQL queries is a huge pain. It would be nice to define + save custom visualizations that leverage Jinja2 templates. These would then be displayed similarly to the current table visualization.
For example, lets say you want to use HTML to color usernames red if they start with the letter 'A'. The current way you would do this is by writing this query:
SELECT
CASE WHEN user like 'A%' THEN '<span style="color:red">' || user || '</span>'
ELSE user
END AS "Formatted Username"
FROM users
As the HTML gets longer, this kind of query gets harder to work with. Instead, I'd like to write this query:
SELECT
user
FROM users
And then define a custom visualization with these fields (you can add more than one template per visualization):
Output name: Formatted Username
Jinja2 Template:
{% if user.startswith('A') %}
<span style="color:red"> {{ user }} </span>`
{% else %}
{{ user }}
{% endif %}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We often (ab)use Redash's ability to display arbitrary HTML in table visualizations. However, writing HTML within SQL queries is a huge pain. It would be nice to define + save custom visualizations that leverage Jinja2 templates. These would then be displayed similarly to the current table visualization.
For example, lets say you want to use HTML to color usernames red if they start with the letter 'A'. The current way you would do this is by writing this query:
As the HTML gets longer, this kind of query gets harder to work with. Instead, I'd like to write this query:
And then define a custom visualization with these fields (you can add more than one template per visualization):
Beta Was this translation helpful? Give feedback.
All reactions