Skip to content

Commit

Permalink
Temporary hack to see the query for NVD3 vizs
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 30, 2015
1 parent 5cf5019 commit 2243623
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 54 deletions.
9 changes: 7 additions & 2 deletions panoramix/templates/panoramix/datasource.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ <h3>{{ viz.verbose_name }}
<span class="label label-success">
{{ "{0:0.4f}".format(results.duration.total_seconds()) }} s
</span>
{% endif %}
<span class="label label-info btn"
data-toggle="modal" data-target="#query_modal">query</span>
{% endif %}
</h3>
<hr/>
<div class="viz" style="height: 700px;">
Expand All @@ -159,7 +159,12 @@ <h3>{{ viz.verbose_name }}
<h4 class="modal-title" id="myModalLabel">Query</h4>
</div>
<div class="modal-body">
<pre>{{ '' }}</pre>
<pre id="query_container">
{% if viz.query %}
{% else %}
<img width="250" src="{{ url_for('static', filename="penguins.png") }}">
{% endif %}
</pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
Expand Down
48 changes: 0 additions & 48 deletions panoramix/templates/panoramix/viz_highcharts.html

This file was deleted.

3 changes: 2 additions & 1 deletion panoramix/templates/panoramix/viz_nvd3.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
loading.show();
var url = "{{ viz.get_url(json="true")|safe }}";
$.getJSON(url, function(data){
$("#query_container").html(data.query);
nv.addGraph(function() {
// chart_type is {{ viz.chart_type }}
{% if viz.chart_type == 'line' %}
Expand Down Expand Up @@ -127,7 +128,7 @@


token.select('.chart').append("svg")
.datum(data)
.datum(data.chart_data)
.transition().duration(500)
.call(chart);

Expand Down
11 changes: 8 additions & 3 deletions panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def get_df(self):
def get_json(self):
df = self.get_df()
series = df.to_dict('series')
datas = []
chart_data = []
for name in df.T.index.tolist():
ys = series[name]
if df[name].dtype.kind not in "biufc":
Expand All @@ -418,8 +418,13 @@ def get_json(self):
{'x': ds, 'y': ys[i]}
for i, ds in enumerate(df.timestamp)]
}
datas.append(d)
return dumps(datas)
chart_data.append(d)
data = {
'chart_data': chart_data,
'query': self.results.query,
'duration': self.results.duration,
}
return dumps(data)


class NVD3TimeSeriesBarViz(NVD3TimeSeriesViz):
Expand Down

0 comments on commit 2243623

Please sign in to comment.