From 04f914fb5c6bcaa2a3388e835069aeaa2db5cbd3 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Wed, 30 Sep 2015 13:58:32 -0700 Subject: [PATCH 1/3] Viz type clarifications --- panoramix/bin/panoramix | 2 +- panoramix/viz.py | 48 ++++++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/panoramix/bin/panoramix b/panoramix/bin/panoramix index 1a9dfb1ff12e..477a35846e16 100755 --- a/panoramix/bin/panoramix +++ b/panoramix/bin/panoramix @@ -88,7 +88,7 @@ def load_examples(sample): sum_boys=num if gender == 'boy' else 0, sum_girls=num if gender == 'girl' else 0, ) - if i % 5000 == 0: + if i % 1000 == 0: print("{} loaded out of 82527 rows".format(i)) session.commit() session.commit() diff --git a/panoramix/viz.py b/panoramix/viz.py index 51009fa7b1d0..a5f81b266e8f 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -18,6 +18,7 @@ class BaseViz(object): + viz_type = None verbose_name = "Base Viz" template = None form_fields = [ @@ -174,6 +175,7 @@ def get_json_data(self): return json.dumps([]) class TableViz(BaseViz): + viz_type = "table" verbose_name = "Table View" template = 'panoramix/viz_table.html' form_fields = BaseViz.form_fields + ['row_limit'] @@ -198,6 +200,7 @@ def get_df(self): class MarkupViz(BaseViz): + viz_type = "markup" verbose_name = "Markup Widget" template = 'panoramix/viz_markup.html' form_fields = ['viz_type', 'markup_type', 'code'] @@ -216,6 +219,7 @@ class WordCloudViz(BaseViz): Integration with the nice library at: https://github.com/jasondavies/d3-cloud """ + viz_type = "word_cloud" verbose_name = "Word Cloud" template = 'panoramix/viz_word_cloud.html' form_fields = [ @@ -248,6 +252,7 @@ def get_json_data(self): class NVD3Viz(BaseViz): + viz_type = None verbose_name = "Base NVD3 Viz" template = 'panoramix/viz_nvd3.html' chart_kind = 'line' @@ -260,8 +265,8 @@ class NVD3Viz(BaseViz): class BubbleViz(NVD3Viz): + viz_type = "bubble" verbose_name = "Bubble Chart" - chart_type = 'bubble' form_fields = [ 'viz_type', ('since', 'until'), @@ -323,6 +328,7 @@ def get_json_data(self): }) class BigNumberViz(BaseViz): + viz_type = "big_number" verbose_name = "Big Number" template = 'panoramix/viz_bignumber.html' js_files = [ @@ -373,8 +379,8 @@ def get_json_data(self): class NVD3TimeSeriesViz(NVD3Viz): + viz_type = "line" verbose_name = "Time Series - Line Chart" - chart_type = "line" sort_series = False form_fields = [ 'viz_type', @@ -460,8 +466,8 @@ def get_json_data(self): class NVD3TimeSeriesBarViz(NVD3TimeSeriesViz): + viz_type = "bar" verbose_name = "Time Series - Bar Chart" - chart_type = "nvd3_bar" form_fields = [ 'viz_type', 'granularity', ('since', 'until'), @@ -473,8 +479,8 @@ class NVD3TimeSeriesBarViz(NVD3TimeSeriesViz): class NVD3CompareTimeSeriesViz(NVD3TimeSeriesViz): + viz_type = 'compare' verbose_name = "Time Series - Percent Change" - chart_type = "compare" form_fields = [ 'viz_type', 'granularity', ('since', 'until'), @@ -486,8 +492,8 @@ class NVD3CompareTimeSeriesViz(NVD3TimeSeriesViz): class NVD3TimeSeriesStackedViz(NVD3TimeSeriesViz): + viz_type = "area" verbose_name = "Time Series - Stacked" - chart_type = "stacked" sort_series = True form_fields = [ 'viz_type', @@ -500,8 +506,8 @@ class NVD3TimeSeriesStackedViz(NVD3TimeSeriesViz): class DistributionPieViz(NVD3Viz): + viz_type = "pie" verbose_name = "Distribution - NVD3 - Pie Chart" - chart_type = "pie" form_fields = [ 'viz_type', 'metrics', 'groupby', ('since', 'until'), @@ -536,8 +542,8 @@ def get_json_data(self): class DistributionBarViz(DistributionPieViz): + viz_type = "dist_bar" verbose_name = "Distribution - Bar Chart" - chart_type = "column" def get_df(self): df = super(DistributionPieViz, self).get_df() @@ -576,16 +582,18 @@ def get_json_data(self): }) -viz_types = OrderedDict([ - ['table', TableViz], - ['line', NVD3TimeSeriesViz], - ['compare', NVD3CompareTimeSeriesViz], - ['area', NVD3TimeSeriesStackedViz], - ['bar', NVD3TimeSeriesBarViz], - ['dist_bar', DistributionBarViz], - ['pie', DistributionPieViz], - ['bubble', BubbleViz], - ['markup', MarkupViz], - ['word_cloud', WordCloudViz], - ['big_number', BigNumberViz], -]) +viz_types_list = [ + TableViz, + NVD3TimeSeriesViz, + NVD3CompareTimeSeriesViz, + NVD3TimeSeriesStackedViz, + NVD3TimeSeriesBarViz, + DistributionBarViz, + DistributionPieViz, + BubbleViz, + MarkupViz, + WordCloudViz, + BigNumberViz, +] +# This dict is used to +viz_types = OrderedDict([(v.viz_type, v) for v in viz_types_list]) From f36ea7aa50049be502d2e8e12f221351fbffbf27 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Wed, 30 Sep 2015 18:00:06 -0700 Subject: [PATCH 2/3] Aligingin stackedAreaChart with area --- panoramix/static/widgets/viz_nvd3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panoramix/static/widgets/viz_nvd3.js b/panoramix/static/widgets/viz_nvd3.js index 0cdb89941b4f..6d16edc9ee5d 100644 --- a/panoramix/static/widgets/viz_nvd3.js +++ b/panoramix/static/widgets/viz_nvd3.js @@ -95,7 +95,7 @@ function viz_nvd3(token_name, json_callback) { chart.showLegend(viz.form_data.show_legend); chart.pointRange([5, 5000]); - } else if (viz_type === 'stacked') { + } else if (viz_type === 'area') { var chart = nv.models.stackedAreaChart(); chart.xScale(d3.time.scale()); chart.xAxis From ee6cc157f692d1707ba5447fbdd130a59fbe945b Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Thu, 1 Oct 2015 17:47:52 -0700 Subject: [PATCH 3/3] Removing chart_kind artefact --- panoramix/viz.py | 1 - 1 file changed, 1 deletion(-) diff --git a/panoramix/viz.py b/panoramix/viz.py index a5f81b266e8f..447a0acd4298 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -255,7 +255,6 @@ class NVD3Viz(BaseViz): viz_type = None verbose_name = "Base NVD3 Viz" template = 'panoramix/viz_nvd3.html' - chart_kind = 'line' js_files = [ 'd3.min.js', 'nv.d3.min.js',