Skip to content

Commit

Permalink
Introducing compare
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 28, 2015
1 parent 495c2df commit 4cd7c3d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
9 changes: 9 additions & 0 deletions panoramix/templates/panoramix/viz_nvd3.html
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
24 changes: 18 additions & 6 deletions panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit 4cd7c3d

Please sign in to comment.