From bb535a373dd1790b67066165ad92096c33a8da97 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 2 Oct 2015 15:07:09 -0700 Subject: [PATCH] Adding an option for line_interpolation in line chart --- panoramix/forms.py | 7 +++++++ panoramix/static/widgets/viz_nvd3.js | 2 ++ panoramix/viz.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/panoramix/forms.py b/panoramix/forms.py index c41384b78..b38821e8f 100644 --- a/panoramix/forms.py +++ b/panoramix/forms.py @@ -126,6 +126,13 @@ class FormFactory(object): choices=[(s, s) for s in ['random', 'flat', 'square']], default="random", description="Rotation to apply to words in the cloud"), + 'line_interpolation': SelectField( + "Line Interpolation", + choices=[(s, s) for s in [ + 'linear', 'basis', 'cardinal', 'monotone', + 'step-before', 'step-after']], + default='linear', + description="Line interpolation as defined by d3.js"), 'code': TextAreaField("Code", description="Put your code here"), 'size_from': TextField( "Font Size From", diff --git a/panoramix/static/widgets/viz_nvd3.js b/panoramix/static/widgets/viz_nvd3.js index 01cac9ec7..6ece06b74 100644 --- a/panoramix/static/widgets/viz_nvd3.js +++ b/panoramix/static/widgets/viz_nvd3.js @@ -38,9 +38,11 @@ function viz_nvd3(token_name, json_callback) { .tickFormat(function (d) {return tickMultiFormat(UTC(new Date(d))); }) .tickValues([]); chart.y2Axis.tickFormat(d3.format('.3s')); + console.log(viz.form_data.line_interpolation); } else { var chart = nv.models.lineChart() } + chart.interpolate(viz.form_data.line_interpolation); chart.xScale(d3.time.scale()); chart.xAxis .showMaxMin(false) diff --git a/panoramix/viz.py b/panoramix/viz.py index 447a0acd4..e9584a81d 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -387,7 +387,7 @@ class NVD3TimeSeriesViz(NVD3Viz): 'metrics', 'groupby', 'limit', ('rolling_type', 'rolling_periods'), - ('num_period_compare', None), + ('num_period_compare', 'line_interpolation'), ('show_brush', 'show_legend'), ('rich_tooltip', 'y_axis_zero'), ('y_log_scale', 'contribution')