From 38a4157ac670a1bf291f49bd7732ce9ffaceca79 Mon Sep 17 00:00:00 2001 From: Patrick Leo Tardif Date: Mon, 9 Nov 2015 18:30:55 -0800 Subject: [PATCH 1/4] Adding y-axis format option --- panoramix/forms.py | 2 ++ panoramix/static/widgets/viz_nvd3.js | 3 +++ panoramix/viz.py | 1 + 3 files changed, 6 insertions(+) diff --git a/panoramix/forms.py b/panoramix/forms.py index 2f204a1a5..352759802 100644 --- a/panoramix/forms.py +++ b/panoramix/forms.py @@ -130,6 +130,8 @@ class FormFactory(object): description="Based on granularity, number of time periods to compare against"), 'compare_suffix': TextField('Comparison suffix', description="Suffix to apply after the percentage display"), + 'y_axis_format': TextField('Y axis format', + description="D3 format syntax for y axis"), 'markup_type': SelectField( "Markup Type", choices=self.choicify(['markdown', 'html']), diff --git a/panoramix/static/widgets/viz_nvd3.js b/panoramix/static/widgets/viz_nvd3.js index 29ec245ad..4a3b00d42 100644 --- a/panoramix/static/widgets/viz_nvd3.js +++ b/panoramix/static/widgets/viz_nvd3.js @@ -137,6 +137,9 @@ function viz_nvd3(data_attribute) { if (viz.form_data.x_log_scale) { chart.xScale(d3.scale.log()); } + if (viz.form_data.y_axis_format) { + chart.yAxis.tickFormat(d3.format(viz.form_data.y_axis_format)); + } chart.duration(0); diff --git a/panoramix/viz.py b/panoramix/viz.py index 80e575ef2..4295a4a35 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -420,6 +420,7 @@ class NVD3TimeSeriesViz(NVD3Viz): ('show_brush', 'show_legend'), ('rich_tooltip', 'y_axis_zero'), ('y_log_scale', 'contribution'), + 'y_axis_format' ] def get_df(self, query_obj=None): From 6b13d78f699ebd4433a63e3f5b1d64c452e55e79 Mon Sep 17 00:00:00 2001 From: Patrick Leo Tardif Date: Tue, 10 Nov 2015 11:32:42 -0800 Subject: [PATCH 2/4] verbose explanation and link for d3 format" --- panoramix/forms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/panoramix/forms.py b/panoramix/forms.py index 352759802..c59f9cb0f 100644 --- a/panoramix/forms.py +++ b/panoramix/forms.py @@ -131,7 +131,9 @@ class FormFactory(object): 'compare_suffix': TextField('Comparison suffix', description="Suffix to apply after the percentage display"), 'y_axis_format': TextField('Y axis format', - description="D3 format syntax for y axis"), + description="D3 format syntax for y axis " + "https://github.com/mbostock/\n" + "d3/wiki/Formatting"), 'markup_type': SelectField( "Markup Type", choices=self.choicify(['markdown', 'html']), From 4233d3467865c1b7ee35442d210d511cb81623f4 Mon Sep 17 00:00:00 2001 From: Patrick Leo Tardif Date: Tue, 10 Nov 2015 11:33:05 -0800 Subject: [PATCH 3/4] handle y2axis for y axis format --- panoramix/static/widgets/viz_nvd3.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/panoramix/static/widgets/viz_nvd3.js b/panoramix/static/widgets/viz_nvd3.js index 4a3b00d42..f2a7b7786 100644 --- a/panoramix/static/widgets/viz_nvd3.js +++ b/panoramix/static/widgets/viz_nvd3.js @@ -139,6 +139,10 @@ function viz_nvd3(data_attribute) { } if (viz.form_data.y_axis_format) { chart.yAxis.tickFormat(d3.format(viz.form_data.y_axis_format)); + + if (chart.y2Axis != undefined) { + chart.y2Axis.tickFormat(d3.format(viz.form_data.y_axis_format)); + } } chart.duration(0); From 93c660f2c7d241bc231157ac5e073128eb5eb965 Mon Sep 17 00:00:00 2001 From: Patrick Leo Tardif Date: Tue, 10 Nov 2015 11:33:35 -0800 Subject: [PATCH 4/4] make y axis format one col width only --- panoramix/viz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panoramix/viz.py b/panoramix/viz.py index 4295a4a35..4b918d8ff 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -420,7 +420,7 @@ class NVD3TimeSeriesViz(NVD3Viz): ('show_brush', 'show_legend'), ('rich_tooltip', 'y_axis_zero'), ('y_log_scale', 'contribution'), - 'y_axis_format' + ('y_axis_format', None) ] def get_df(self, query_obj=None):