diff --git a/panoramix/forms.py b/panoramix/forms.py index f07f3e2374bd3..e0f2a42ad21e0 100644 --- a/panoramix/forms.py +++ b/panoramix/forms.py @@ -105,6 +105,15 @@ def __init__(self, viz): 'Metric', choices=datasource.metrics_combo, default=default_metric, description="Chose the metric"), + 'stacked_style': SelectField( + 'Chart Style', choices=self.choicify( + ['stack', 'stream', 'expand']), + default='stack', + description=""), + 'bar_stacked': BetterBooleanField( + 'Stacked Bars', + default=False, + description=""), 'secondary_metric': SelectField( 'Color Metric', choices=datasource.metrics_combo, default=default_metric, diff --git a/panoramix/static/widgets/viz_nvd3.js b/panoramix/static/widgets/viz_nvd3.js index 1556ca31e7385..b2025760dcf1e 100644 --- a/panoramix/static/widgets/viz_nvd3.js +++ b/panoramix/static/widgets/viz_nvd3.js @@ -69,6 +69,7 @@ function viz_nvd3(slice) { .tickFormat(formatDate) .staggerLabels(true); chart.showLegend(fd.show_legend); + chart.stacked(fd.bar_stacked); chart.yAxis.tickFormat(d3.format('.3s')); } else if (viz_type === 'dist_bar') { @@ -79,6 +80,7 @@ function viz_nvd3(slice) { .groupSpacing(0.1); //Distance between each group of bars. chart.xAxis .showMaxMin(false); + chart.stacked(fd.bar_stacked); chart.yAxis.tickFormat(d3.format('.3s')); } else if (viz_type === 'pie') { @@ -131,6 +133,7 @@ function viz_nvd3(slice) { } else if (viz_type === 'area') { chart = nv.models.stackedAreaChart(); + chart.style(fd.stacked_style); chart.xScale(d3.time.scale.utc()); chart.xAxis .showMaxMin(false) diff --git a/panoramix/viz.py b/panoramix/viz.py index b107a6fa82f7e..458245babb6c8 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -743,6 +743,15 @@ class NVD3TimeSeriesBarViz(NVD3TimeSeriesViz): viz_type = "bar" sort_series = True verbose_name = "Time Series - Bar Chart" + fieldsets = [NVD3TimeSeriesViz.fieldsets[0]] + [{ + 'label': 'Chart Options', + 'fields': ( + ('show_brush', 'show_legend'), + ('rich_tooltip', 'y_axis_zero'), + ('y_log_scale', 'contribution'), + ('y_axis_format', 'x_axis_showminmax'), + ('line_interpolation', 'bar_stacked'), + ), }] + [NVD3TimeSeriesViz.fieldsets[2]] class NVD3CompareTimeSeriesViz(NVD3TimeSeriesViz): @@ -754,6 +763,15 @@ class NVD3TimeSeriesStackedViz(NVD3TimeSeriesViz): viz_type = "area" verbose_name = "Time Series - Stacked" sort_series = True + fieldsets = [NVD3TimeSeriesViz.fieldsets[0]] + [{ + 'label': 'Chart Options', + 'fields': ( + ('show_brush', 'show_legend'), + ('rich_tooltip', 'y_axis_zero'), + ('y_log_scale', 'contribution'), + ('y_axis_format', 'x_axis_showminmax'), + ('line_interpolation', 'stacked_style'), + ), }] + [NVD3TimeSeriesViz.fieldsets[2]] class DistributionPieViz(NVD3Viz): @@ -805,7 +823,7 @@ class DistributionBarViz(DistributionPieViz): ('since', 'until'), 'metrics', 'groupby', 'limit', - ('show_legend', None), + ('show_legend', 'bar_stacked'), ) },)