From a674fca26df18cf2530f68bcbf89f12616122e71 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 28 Sep 2015 10:32:56 -0700 Subject: [PATCH] Better form handling --- panoramix/bin/panoramix | 2 +- panoramix/forms.py | 2 +- panoramix/templates/panoramix/viz.html | 8 +- panoramix/templates/panoramix/viz_nvd3.html | 26 +++--- .../templates/panoramix/viz_standalone.html | 2 +- panoramix/templates/panoramix/viz_table.html | 4 +- .../templates/panoramix/viz_word_cloud.html | 6 +- panoramix/viz.py | 92 +++++++++---------- 8 files changed, 72 insertions(+), 70 deletions(-) diff --git a/panoramix/bin/panoramix b/panoramix/bin/panoramix index cf1b09a83..943e10b91 100755 --- a/panoramix/bin/panoramix +++ b/panoramix/bin/panoramix @@ -72,7 +72,7 @@ def load_examples(sample): with gzip.open(config.get("BASE_DIR") + '/data/birth_names.csv.gz') as f: bb_csv = csv.reader(f) for i, (state, year, name, gender, num) in enumerate(bb_csv): - if i == 0: + if i == 0 or year < "1965": # jumpy data before 1965 continue if num == "NA": num = 0 diff --git a/panoramix/forms.py b/panoramix/forms.py index 5045eb93d..49c615324 100644 --- a/panoramix/forms.py +++ b/panoramix/forms.py @@ -118,7 +118,7 @@ def form_factory(viz): "Range Selector", default=True, description="Whether to display the time range interactive selector"), 'show_legend': BooleanField( - "Legend", default=True, + "Legend", default=True, false_values=["f"], description="Whether to display the legend (toggles)"), 'rich_tooltip': BooleanField( "Rich Tooltip", default=True, diff --git a/panoramix/templates/panoramix/viz.html b/panoramix/templates/panoramix/viz.html index c7d0a92b3..9fb32b2ad 100644 --- a/panoramix/templates/panoramix/viz.html +++ b/panoramix/templates/panoramix/viz.html @@ -1,9 +1,9 @@ {% import viz.template as viz_macros %} -{% if viz.args.get("json") == "true" %} +{% if viz.form_data.get("json") == "true" %} {{ viz.get_json() }} {% else %} - {% if viz.args.get("standalone") == "true" %} + {% if viz.form_data.get("standalone") == "true" %} {% extends 'panoramix/viz_standalone.html' %} {% else %} {% extends 'panoramix/datasource.html' %} @@ -16,7 +16,7 @@ {% block head_css %} {{super()}} - {% if viz.args.get("skip_libs") != "true" %} + {% if viz.form_data.get("skip_libs") != "true" %} {% for css in viz.css_files %} {% endfor %} @@ -27,7 +27,7 @@ {% block tail %} {{super()}} - {% if viz.args.get("skip_libs") != "true" %} + {% if viz.form_data.get("skip_libs") != "true" %} {% endblock %} diff --git a/panoramix/templates/panoramix/viz_table.html b/panoramix/templates/panoramix/viz_table.html index d787b331f..90c45870d 100644 --- a/panoramix/templates/panoramix/viz_table.html +++ b/panoramix/templates/panoramix/viz_table.html @@ -1,5 +1,5 @@ {% macro viz_html(viz) %} - {% if viz.args.get("async") == "true" %} + {% if viz.form_data.get("async") == "true" %} {% set df = viz.get_df() %} @@ -32,7 +32,7 @@ {% endmacro %} {% macro viz_js(viz) %} - {% if viz.args.get("async") != "true" %} + {% if viz.form_data.get("async") != "true" %}