mirror of https://github.com/apache/superset.git
Temporary hack to see the query for NVD3 vizs
This commit is contained in:
parent
5cf5019ff1
commit
2243623430
|
@ -133,9 +133,9 @@
|
|||
<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;">
|
||||
|
@ -159,7 +159,12 @@
|
|||
<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>
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
{% macro viz_html(viz) %}
|
||||
<div id="{{ viz.token }}" style="height:100%; width: 100%">
|
||||
<img src="{{ url_for("static", filename="loading.gif") }}" class="loading">
|
||||
<div class="chart" style="height:100%; width: 100%"></div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro viz_js(viz) %}
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
Highcharts.setOptions({
|
||||
colors: [
|
||||
"#FF5A5F", "#007A87", "#7B0051", "#00D1C1", "#8CE071", "#FFB400",
|
||||
"#FFAA91", "#B4A76C", "#9CA299", "#565A5C"
|
||||
],
|
||||
global: {
|
||||
useUTC: false
|
||||
},
|
||||
});
|
||||
var token = $("#{{ viz.token }}");
|
||||
var loading = $("#{{ viz.token }}").find("img.loading");
|
||||
var chart = $("#{{ viz.token }}").find("div.chart");
|
||||
var refresh = function(){
|
||||
chart.hide();
|
||||
loading.show();
|
||||
var url = "{{ viz.get_url(json="true")|safe }}";
|
||||
$.getJSON(url, function(data){
|
||||
chart.width(token.width());
|
||||
chart.height(token.height()-40);
|
||||
chart.highcharts('{{ viz.chart_call }}', data);
|
||||
chart.show();
|
||||
token.find("img.loading").hide();
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
var err = '<div class="alert alert-danger">' + xhr.responseText + '</div>';
|
||||
loading.hide();
|
||||
chart.show();
|
||||
chart.html(err);
|
||||
});
|
||||
};
|
||||
refresh();
|
||||
token.parent().find("a.refresh").click(refresh);
|
||||
});
|
||||
</script>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro viz_css(viz) %}
|
||||
{% endmacro %}
|
|
@ -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' %}
|
||||
|
@ -127,7 +128,7 @@
|
|||
|
||||
|
||||
token.select('.chart').append("svg")
|
||||
.datum(data)
|
||||
.datum(data.chart_data)
|
||||
.transition().duration(500)
|
||||
.call(chart);
|
||||
|
||||
|
|
|
@ -397,7 +397,7 @@ class NVD3TimeSeriesViz(NVD3Viz):
|
|||
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":
|
||||
|
@ -418,8 +418,13 @@ class NVD3TimeSeriesViz(NVD3Viz):
|
|||
{'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):
|
||||
|
|
Loading…
Reference in New Issue