diff --git a/panoramix/templates/panoramix/base.html b/panoramix/templates/panoramix/base.html index 4dfbdb33ac89b..6ebb3bdc2bf0c 100644 --- a/panoramix/templates/panoramix/base.html +++ b/panoramix/templates/panoramix/base.html @@ -9,8 +9,8 @@ {% endblock %} {% block tail_js %} -{{ super() }} +{{ super() }} {% endblock %} diff --git a/panoramix/templates/panoramix/explore.html b/panoramix/templates/panoramix/explore.html index 9ed8ea592c096..379038c6b279b 100644 --- a/panoramix/templates/panoramix/explore.html +++ b/panoramix/templates/panoramix/explore.html @@ -36,10 +36,10 @@

{% set field = form.get_field(fieldname)%}
- {{ field.label }} + {{ viz.get_form_override(fieldname, 'label') or field.label }} {% if field.description %} + title="{{ viz.get_form_override(fieldname, 'description') or field.description }}"> {% endif %} {{ field(class_=form.field_css_classes(field.name)) }}
@@ -51,10 +51,10 @@

{% if name %} {% set field = form.get_field(name)%} - {{ field.label }} + {{ viz.form_overrides.label or field.label }} {% if field.description %} + title="{{ viz.get_form_override(fieldname, 'description') or field.description }}"> {% endif %} {{ field(class_=form.field_css_classes(field.name)) }} {% endif %} diff --git a/panoramix/viz.py b/panoramix/viz.py index 76a3897d56b3b..0ac7b9311bb35 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -3,7 +3,7 @@ import json import uuid -from flask import flash, request +from flask import flash, request, Markup from markdown import markdown from pandas.io.json import dumps from werkzeug.datastructures import ImmutableMultiDict @@ -36,6 +36,7 @@ class BaseViz(object): },) js_files = [] css_files = [] + form_overrides = {} def __init__(self, datasource, form_data): self.orig_form_data = form_data @@ -74,6 +75,16 @@ def __init__(self, datasource, form_data): self.groupby = self.form_data.get('groupby') or [] self.reassignments() + def get_form_override(self, fieldname, attr): + if ( + fieldname in self.form_overrides and + attr in self.form_overrides[fieldname]): + s = self.form_overrides[fieldname][attr] + if attr == 'label': + s = ''.format(**locals()) + s = Markup(s) + return s + def fieldsetizer(self): """ Makes form_fields support either a list approach or a fieldsets @@ -804,6 +815,24 @@ class SunburstViz(BaseViz): 'limit', ) },) + form_overrides = { + 'metric': { + 'label': 'Primary Metric', + 'description': ( + "The primary metric is used to " + "define the arc segment sizes"), + }, + 'secondary_metric': { + 'label': 'Secondary Metric', + 'description': ( + "This secondary metric is used to " + "define the color as a ratio against the primary metric"), + }, + 'groupby': { + 'label': 'Hierarchy', + 'description': "This defines the level of the hierarchy", + }, + } def get_df(self): df = super(SunburstViz, self).get_df()