Skip to content

Commit

Permalink
Adding a basic ifram viz
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jan 19, 2016
1 parent ef612ed commit 5f9f95b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 2 additions & 0 deletions panoramix/forms.py
Expand Up @@ -288,6 +288,8 @@ def __init__(self, viz):
'Bubble Size',
default=default_metric,
choices=datasource.metrics_combo),
'url': TextField(
'URL', default='www.airbnb.com',),
'where': TextField(
'Custom WHERE clause', default='',
description=(
Expand Down
20 changes: 20 additions & 0 deletions panoramix/static/widgets/viz_iframe.js
@@ -0,0 +1,20 @@
px.registerViz('iframe', function(slice) {

function refresh() {
$('#code').attr('rows', '15')
$.getJSON(slice.jsonEndpoint(), function(payload) {
slice.container.html(
'<iframe style="width:100%; height:100%;"></iframe>');
console.log(slice);
slice.container.find('iframe').attr('src', payload.form_data.url);
slice.done();
})
.fail(function(xhr) {
slice.error(xhr.responseText);
});
};
return {
render: refresh,
resize: refresh,
};
});
15 changes: 14 additions & 1 deletion panoramix/viz.py
Expand Up @@ -1146,6 +1146,18 @@ def get_json_data(self):
return dumps(d)


class IFrameViz(BaseViz):
viz_type = "iframe"
verbose_name = "iFrame"
is_timeseries = False
js_files = ['widgets/viz_iframe.js']
fieldsets = (
{
'label': None,
'fields': ('url',)
},)


viz_types_list = [
TableViz,
PivotTableViz,
Expand All @@ -1164,6 +1176,7 @@ def get_json_data(self):
SankeyViz,
WorldMapViz,
FilterBoxViz,
IFrameViz,
]
# This dict is used to

viz_types = OrderedDict([(v.viz_type, v) for v in viz_types_list])

0 comments on commit 5f9f95b

Please sign in to comment.