diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 45e731f2..7a6ce8f5 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -1994,7 +1994,7 @@ def forcecurve_multi_interactive_chart(selected): # pragma: no cover columns = ['catch', 'slip', 'wash', 'finish', 'averageforce', 'peakforceangle', 'peakforce', 'spm', 'distance', - 'workoutstate', 'driveenergy', 'cumdist'] + 'workoutstate', 'workoutid', 'driveenergy', 'cumdist'] rowdata = dataprep.getsmallrowdata_db(columns, ids=workoutids, workstrokesonly=False) @@ -2024,70 +2024,6 @@ def forcecurve_multi_interactive_chart(selected): # pragma: no cover script, div = get_chart("/forcecurve_compare", chart_data) return script, div - source = ColumnDataSource( - df_plot - ) - - TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,crosshair' - plot = figure(width=920,tools=TOOLS, - toolbar_location='above', - toolbar_sticky=False) - - #plot.sizing_mode = 'stretch_both' - - # add watermark - watermarkurl = "/static/img/logo7.png" - - watermarkrange = Range1d(start=0, end=1) - watermarkalpha = 0.6 - watermarkx = 0.99 - watermarky = 0.01 - watermarkw = 184 - watermarkh = 35 - watermarkanchor = 'bottom_right' - plot.extra_y_ranges = {"watermark": watermarkrange} - plot.extra_x_ranges = {"watermark": watermarkrange} - - plot.image_url([watermarkurl], watermarkx, watermarky, - watermarkw, watermarkh, - global_alpha=watermarkalpha, - w_units='screen', - h_units='screen', - anchor=watermarkanchor, - dilate=True, - x_range_name="watermark", - y_range_name="watermark", - ) - - colors = itertools.cycle(palette) - - try: - items = itertools.izip(ids, colors) - except AttributeError: - items = zip(ids, colors) - - for id, color in items: - xname = 'x_'+str(id) - yname = 'y_'+str(id) - analysis = ForceCurveAnalysis.objects.get(id=id) - legendlabel = '{name}'.format( - name = analysis.name, - ) - if analysis.notes: - legendlabel = '{name} - {notes}'.format( - name = analysis.name, - notes = analysis.notes - ) - plot.line(xname,yname,source=source,legend_label=legendlabel, - line_width=2, color=color) - - plot.legend.location = "top_left" - plot.xaxis.axis_label = "Angle" - plot.yaxis.axis_label = "Force (N)" - - script, div = components(plot) - - return (script, div) def instroke_multi_interactive_chart(selected, *args, **kwargs): # pragma: no cover df2 = [] @@ -2880,6 +2816,7 @@ def thumbnails_set(r, id, favorites): except (KeyError, TypeError): # pragma: no cover pass + plotnr = 1 for f in favorites: script, div = thumbnail_flex_chart( rowdata, @@ -2888,7 +2825,9 @@ def thumbnails_set(r, id, favorites): yparam1=f.yparam1, yparam2=f.yparam2, plottype=f.plottype, + plotnr=plotnr ) + plotnr = plotnr+1 charts.append({ 'script': script, @@ -2903,6 +2842,7 @@ def thumbnail_flex_chart(rowdata, id=0, promember=0, yparam1='pace', yparam2='hr', plottype='line', + plotnr=1, workstrokesonly=False): try: @@ -2938,6 +2878,25 @@ def thumbnail_flex_chart(rowdata, id=0, promember=0, else: rowdata['y2'] = rowdata['y1'] + data_dict = rowdata.to_dict("records") + metrics_list = [{'name': name, 'rowingmetrics':d } for name, d in metrics.rowingmetrics] + + chart_data = { + 'title': '', + 'x': xparam, + 'y1': yparam1, + 'y2': yparam2, + 'data': data_dict, + 'metrics': metrics_list, + 'plottype': plottype, + 'plotnr': plotnr, + } + + script, div = get_chart("/miniflex", chart_data) + + return script, div + + if xparam == 'time': xaxmax = tseconds.max() xaxmin = tseconds.min() diff --git a/rowers/templates/forcecurve_analysis.html b/rowers/templates/forcecurve_analysis.html index cbd51e2a..2216bd01 100644 --- a/rowers/templates/forcecurve_analysis.html +++ b/rowers/templates/forcecurve_analysis.html @@ -14,6 +14,7 @@