Skip to content

Commit

Permalink
Merge pull request #37 from mistercrunch/viz_type
Browse files Browse the repository at this point in the history
Viz type
  • Loading branch information
mistercrunch committed Oct 2, 2015
2 parents f3e3415 + ee6cc15 commit f3c6414
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion panoramix/bin/panoramix
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion panoramix/static/widgets/viz_nvd3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 28 additions & 21 deletions panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


class BaseViz(object):
viz_type = None
verbose_name = "Base Viz"
template = None
form_fields = [
Expand Down Expand Up @@ -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']
Expand All @@ -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']
Expand All @@ -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 = [
Expand Down Expand Up @@ -248,9 +252,9 @@ def get_json_data(self):


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',
Expand All @@ -260,8 +264,8 @@ class NVD3Viz(BaseViz):


class BubbleViz(NVD3Viz):
viz_type = "bubble"
verbose_name = "Bubble Chart"
chart_type = 'bubble'
form_fields = [
'viz_type',
('since', 'until'),
Expand Down Expand Up @@ -323,6 +327,7 @@ def get_json_data(self):
})

class BigNumberViz(BaseViz):
viz_type = "big_number"
verbose_name = "Big Number"
template = 'panoramix/viz_bignumber.html'
js_files = [
Expand Down Expand Up @@ -373,8 +378,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',
Expand Down Expand Up @@ -460,8 +465,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'),
Expand All @@ -473,8 +478,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'),
Expand All @@ -486,8 +491,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',
Expand All @@ -500,8 +505,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'),
Expand Down Expand Up @@ -536,8 +541,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()
Expand Down Expand Up @@ -576,16 +581,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])

0 comments on commit f3c6414

Please sign in to comment.