NVD3 form optinos for stacked/expanded/grouped ...

This commit is contained in:
Maxime Beauchemin
2016-01-13 13:43:39 -08:00
parent 7982dee834
commit d726bd0e05
3 changed files with 31 additions and 1 deletions

View File

@@ -105,6 +105,15 @@ class FormFactory(object):
'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,

View File

@@ -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)

View File

@@ -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'),
)
},)