Skip to content

Commit

Permalink
NVD3 form optinos for stacked/expanded/grouped ...
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jan 13, 2016
1 parent 7982dee commit d726bd0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
9 changes: 9 additions & 0 deletions panoramix/forms.py
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions panoramix/static/widgets/viz_nvd3.js
Expand Up @@ -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') {
Expand All @@ -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') {
Expand Down Expand Up @@ -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)
Expand Down
20 changes: 19 additions & 1 deletion panoramix/viz.py
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -805,7 +823,7 @@ class DistributionBarViz(DistributionPieViz):
('since', 'until'),
'metrics', 'groupby',
'limit',
('show_legend', None),
('show_legend', 'bar_stacked'),
)
},)

Expand Down

0 comments on commit d726bd0

Please sign in to comment.