initial version histo chart
This commit is contained in:
@@ -88,16 +88,23 @@ from rowers.serializers import *
|
||||
activate(settings.TIME_ZONE)
|
||||
thetimezone = get_current_timezone()
|
||||
|
||||
def get_chart(end_point, chart_data):
|
||||
|
||||
def get_chart(end_point, chart_data, debug=False):
|
||||
if debug:
|
||||
print(chart_data)
|
||||
url = settings.ROWSANDALL_CHARTS_URL+end_point
|
||||
headers = {'authorization':"Bearer {token}".format(token=settings.ROWSANDALL_CHARTS_TOKEN)}
|
||||
try:
|
||||
response = requests.post(url, json=chart_data, headers=headers)
|
||||
except:
|
||||
except ConnectionError as err:
|
||||
if debug:
|
||||
print("Chart Server Error")
|
||||
print(err)
|
||||
script = ''
|
||||
div = 'Chart Server Error'
|
||||
return script, div
|
||||
|
||||
if debug:
|
||||
print("Status Code",response.status_code)
|
||||
|
||||
if response.status_code == 200:
|
||||
script = response.json()['script']
|
||||
@@ -108,6 +115,16 @@ def get_chart(end_point, chart_data):
|
||||
|
||||
return script, div
|
||||
|
||||
# Example for 3D
|
||||
def filmdeaths():
|
||||
data = pd.read_csv("~/Downloads/filmdeathcounts.csv")
|
||||
|
||||
chart_data = data.to_dict("records")
|
||||
chart_data_dict = {"data": chart_data}
|
||||
|
||||
script, div = get_chart("/filmdeaths", chart_data_dict)
|
||||
return script, div
|
||||
|
||||
# Example for BokehJS
|
||||
def sleep():
|
||||
data = {
|
||||
@@ -2090,6 +2107,11 @@ def interactive_histoall(theworkouts, histoparam, includereststrokes,
|
||||
histopwr = histopwr[histopwr > yaxminima[histoparam]]
|
||||
histopwr = histopwr[histopwr < yaxmaxima[histoparam]]
|
||||
|
||||
data_dict = {"data": histopwr.tolist()}
|
||||
script, div = get_chart("/histogram", data_dict, debug=False)
|
||||
|
||||
return script, div
|
||||
|
||||
plot = figure(tools=TOOLS, width=900,
|
||||
toolbar_sticky=False,
|
||||
toolbar_location="above"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
{% block main %}
|
||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||
<script src="https://d3js.org/d3/v6/js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
@@ -86,7 +87,6 @@
|
||||
|
||||
<li class="grid_4">
|
||||
<div id="id_chart">
|
||||
|
||||
{{ the_div|safe }}
|
||||
</div>
|
||||
</li>
|
||||
@@ -123,22 +123,23 @@
|
||||
|
||||
<script>
|
||||
$(function($) {
|
||||
console.log('loading script');
|
||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/histodata/', function(json) {
|
||||
console.log('got script');
|
||||
var counter=0;
|
||||
var script = json.script;
|
||||
var div = json.div;
|
||||
console.log('set vars');
|
||||
$("#id_sitready").remove();
|
||||
console.log('sitready removed');
|
||||
$("#id_chart").append(div);
|
||||
console.log('div appended');
|
||||
$("#id_script").append("<script>"+script+"</s"+"cript>");
|
||||
console.log('script changed');
|
||||
console.log('loading script');
|
||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/histodata/', function(json) {
|
||||
console.log('got script');
|
||||
var counter=0;
|
||||
var script = json.script;
|
||||
var div = json.div;
|
||||
console.log(div)
|
||||
console.log('set vars');
|
||||
$("#id_sitready").remove();
|
||||
console.log('sitready removed');
|
||||
$("#id_chart").append(div);
|
||||
console.log('div appended');
|
||||
$("#id_script").append("<script>"+script+"</s"+"cript>");
|
||||
console.log('script changed');
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
}
|
||||
</script>
|
||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||
<script src="https://d3js.org/d3.v6.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
@@ -411,9 +412,9 @@
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_4">
|
||||
<div id="id_chart">
|
||||
{{ the_div|safe }}
|
||||
</div>
|
||||
<div id="id_chart">
|
||||
{{ the_div|safe }}
|
||||
</div>
|
||||
</li>
|
||||
<li class="grid_4">
|
||||
<p>You can use the date and search forms to search through all
|
||||
|
||||
@@ -273,6 +273,7 @@ urlpatterns = [
|
||||
name='workouts_summaries_email_view'),
|
||||
path('failedjobs/', views.failed_queue_view, name='failed_queue_view'),
|
||||
path('sleep/', views.sleep_view, name='sleep_view'),
|
||||
path('filmdeaths/', views.filmdeaths_view, name='filmdeaths_view'),
|
||||
path('failedjobs/empty/', views.failed_queue_empty, name='failed_queue_empty'),
|
||||
re_path('^failedjobs/(?P<id>\w+.*)/$',
|
||||
views.failed_job_view, name='failed_job_view'),
|
||||
|
||||
@@ -155,12 +155,7 @@ def get_call():
|
||||
call1 = random.choice(coxes_calls)
|
||||
call2 = random.choice(info_calls)
|
||||
|
||||
call = """<div id="id_sitready" class="successmessage">
|
||||
<p>
|
||||
%s (%s)
|
||||
</p>
|
||||
</div>
|
||||
""" % (call1, call2)
|
||||
call = """<div id="id_sitready" class="successmessage"><p>%s (%s)</p></div>""" % (call1, call2)
|
||||
|
||||
return call
|
||||
|
||||
|
||||
@@ -618,6 +618,7 @@ def histodata(workouts, options):
|
||||
extratitle=extratitle,
|
||||
workmin=workmin, workmax=workmax)
|
||||
|
||||
print(div)
|
||||
return(script, div)
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,17 @@ def sleep_view(request):
|
||||
"the_script": script,
|
||||
})
|
||||
|
||||
def filmdeaths_view(request):
|
||||
script, div = filmdeaths()
|
||||
|
||||
return render(request,
|
||||
"filmdeaths.html",
|
||||
{
|
||||
"the_div": div,
|
||||
"the_script": script,
|
||||
}
|
||||
)
|
||||
|
||||
@login_required()
|
||||
def download_fit(request, filename=''):
|
||||
pss = PlannedSession.objects.filter(fitfile=filename)
|
||||
|
||||
Reference in New Issue
Block a user