diff --git a/panoramix/templates/panoramix/viz_nvd3.html b/panoramix/templates/panoramix/viz_nvd3.html index e196493dc87d..d36f36373304 100644 --- a/panoramix/templates/panoramix/viz_nvd3.html +++ b/panoramix/templates/panoramix/viz_nvd3.html @@ -77,6 +77,15 @@ var chart = nv.models.multiBarChart(); chart.yAxis.tickFormat(d3.format('.3s')); + {% elif viz.chart_type == 'compare' %} + var chart = nv.models.cumulativeLineChart(); + chart.xScale(d3.time.scale()); + chart.xAxis + .showMaxMin(false) + .tickFormat(function (d) {return tickMultiFormat(new Date(d)); }); + chart.showLegend({{ "{}".format(viz.args.show_legend=='y')|lower }}); + chart.yAxis.tickFormat(d3.format('.3p')); + {% elif viz.chart_type == 'bubble' %} var chart = nv.models.scatterChart(); chart.xAxis.tickFormat(d3.format('.3s')); diff --git a/panoramix/viz.py b/panoramix/viz.py index 4503fc8689c1..117c3d9cca4a 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -313,7 +313,7 @@ def get_json(self): class NVD3TimeSeriesViz(NVD3Viz): - verbose_name = "NVD3 - Time Series - Line Chart" + verbose_name = "Time Series - Line Chart" chart_type = "nvd3_line" form_fields = [ 'viz_type', @@ -373,7 +373,7 @@ def get_json(self): class NVD3TimeSeriesBarViz(NVD3TimeSeriesViz): - verbose_name = "NVD3 - Time Series - Bar Chart" + verbose_name = "Time Series - Bar Chart" chart_type = "nvd3_bar" form_fields = [ 'viz_type', @@ -385,8 +385,21 @@ class NVD3TimeSeriesBarViz(NVD3TimeSeriesViz): ] +class NVD3CompareTimeSeriesViz(NVD3TimeSeriesViz): + verbose_name = "Time Series - Percent Change" + chart_type = "compare" + form_fields = [ + 'viz_type', + 'granularity', ('since', 'until'), + 'metrics', + 'groupby', 'limit', + ('rolling_type', 'rolling_periods'), + 'show_legend', + ] + + class NVD3TimeSeriesStackedViz(NVD3TimeSeriesViz): - verbose_name = "NVD3 - Time Series - Stacked" + verbose_name = "Time Series - Stacked" chart_type = "stacked" form_fields = [ 'viz_type', @@ -469,10 +482,9 @@ def get_json(self): viz_types = OrderedDict([ ['table', TableViz], ['line', NVD3TimeSeriesViz], - ['stacked', NVD3TimeSeriesStackedViz], ['big_number', BigNumberViz], - #['compare', TimeSeriesCompareViz], # TODO replace - #['area', TimeSeriesAreaViz], # TODO replace + ['compare', NVD3CompareTimeSeriesViz], + ['area', NVD3TimeSeriesStackedViz], ['bar', NVD3TimeSeriesBarViz], ['dist_bar', DistributionBarViz], ['pie', DistributionPieViz],