interactive_chart op twee plaatsen
This commit is contained in:
@@ -3558,7 +3558,22 @@ def interactive_chart(id=0, promember=0, intervaldata={}):
|
|||||||
|
|
||||||
metrics_list = [{'name': name, 'rowingmetrics':d } for name, d in metrics.rowingmetrics]
|
metrics_list = [{'name': name, 'rowingmetrics':d } for name, d in metrics.rowingmetrics]
|
||||||
|
|
||||||
print(intervaldata)
|
|
||||||
|
intervals = []
|
||||||
|
# add shaded bar chart areas
|
||||||
|
if intervaldata != {}:
|
||||||
|
intervaldf = pd.DataFrame(intervaldata)
|
||||||
|
intervaldf['itime'] = intervaldf['itime']*1.e3
|
||||||
|
intervaldf['time'] = intervaldf['itime'].cumsum()
|
||||||
|
intervaldf['time'] = intervaldf['time'].shift(1)
|
||||||
|
intervaldf.loc[0, 'time'] = 0
|
||||||
|
intervaldf['time_r'] = intervaldf['time'] + intervaldf['itime']
|
||||||
|
intervaldf['value'] = 100
|
||||||
|
mask = intervaldf['itype'] == 3
|
||||||
|
intervaldf.loc[mask, 'value'] = 0
|
||||||
|
intervaldf['bottom'] = 0
|
||||||
|
|
||||||
|
intervals = intervaldf.to_dict("records")
|
||||||
|
|
||||||
chart_data = {
|
chart_data = {
|
||||||
'title': row.name,
|
'title': row.name,
|
||||||
@@ -3567,7 +3582,7 @@ def interactive_chart(id=0, promember=0, intervaldata={}):
|
|||||||
'y2': "spm",
|
'y2': "spm",
|
||||||
'data': data_dict,
|
'data': data_dict,
|
||||||
'metrics': metrics_list,
|
'metrics': metrics_list,
|
||||||
'intervals': intervaldata,
|
'intervals': intervals,
|
||||||
}
|
}
|
||||||
|
|
||||||
script, div = get_chart("/interactive", chart_data)
|
script, div = get_chart("/interactive", chart_data)
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>jQuery UI Slider - Range slider</title>
|
<title>jQuery UI Slider - Range slider</title>
|
||||||
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
|
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
|
||||||
<link rel="stylesheet" href="/resources/demos/style.css">
|
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
|
||||||
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
|
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
|
||||||
|
|
||||||
@@ -30,11 +29,14 @@
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
console.log(data);
|
|
||||||
$("#id_script").replaceWith('<div id="id_script">'+data.script+'</d'+'iv>');
|
$("#id_script").replaceWith('<div id="id_script">'+data.script+'</d'+'iv>');
|
||||||
$("#id_chart").replaceWith('<div id="id_chart">'+data.div+'</d'+'iv>');
|
$("#id_chart").replaceWith('<div id="id_chart">'+data.div+'</d'+'iv>');
|
||||||
$("#ds").replaceWith('<div id="ds">'+data.ds+'</d'+'iv>');
|
|
||||||
$("#dd").replaceWith('<div id="dd">'+data.dd+'</d'+'iv>');
|
|
||||||
|
$("#dd").empty();
|
||||||
|
$("#dd").html(data.dd);
|
||||||
|
$("#ds").empty();
|
||||||
|
$('#ds').html(data.ds)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -169,11 +171,10 @@ $( function() {
|
|||||||
{{ the_div|safe }}
|
{{ the_div|safe }}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="grid_2">
|
|
||||||
<div id="dd" class="flexplot">
|
|
||||||
<script src="https://d3js.org/d3.v6.js"></script>
|
<script src="https://d3js.org/d3.v6.js"></script>
|
||||||
|
<li class="grid_2" id="interactive">
|
||||||
|
<div id="dd" class="flexplot">
|
||||||
{{ dd|safe }}
|
{{ dd|safe }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="ds">
|
<div id="ds">
|
||||||
{{ ds |safe }}
|
{{ ds |safe }}
|
||||||
|
|||||||
Reference in New Issue
Block a user