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"
|
||||
|
||||
Reference in New Issue
Block a user