{% extends "base.html" %}
{% load staticfiles %}
{% load rowerfilters %}

{% block title %} Flexible Plot {% endblock %}

{% block content %}

	<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
	<script async="true" type="text/javascript">
    Bokeh.set_log_level("info");
	</script>

	{{ interactiveplot |safe }}

    <script>
    // Set things up to resize the plot on a window resize. You can play with
    // the arguments of resize_width_height() to change the plot's behavior.
    var plot_resize_setup = function () {
        var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
        var plot = Bokeh.index[plotid];
        var plotresizer = function() {
            // arguments: use width, use height, maintain aspect ratio
            plot.resize_width_height(true, true, false);
        };
        window.addEventListener('resize', plotresizer);
        plotresizer();
    };
    window.addEventListener('load', plot_resize_setup);
    </script>
    <style>
    /* Need this to get the page in "desktop mode"; not having an infinite height.*/
    html, body {height: 100%; margin:5px;}
    </style>

<div id="navigation" class="grid_12 alpha">
	{% if user.is_authenticated and mayedit %}
	<div class="grid_2 alpha">
	<p>
	<a class="button gray small" href="/rowers/workout/{{ id }}/edit">Edit Workout</a>
</p>
	</div>
	<div class="grid_2 suffix_8 omega">
	<p>
	<a class="button gray small" href="/rowers/workout/{{ id }}/advanced">Advanced Edit</a>
</p>

	</div>
	{% endif %}
</div>


<p>&nbsp;</p>

<div id="plotbuttons" class="grid_12 alpha">


	<div id="x-axis" class="grid_6 alpha">
		<div class="grid_2 alpha">
		<a class="button blue small" href="/rowers/workout/{{ id }}/flexchart2/time/{{ yparam1 }}/{{ yparam2 }}">Time</a>
		</div>
		<div class="grid_2">
		<a class="button blue small" href="/rowers/workout/{{ id }}/flexchart2/distance/{{ yparam1 }}/{{ yparam2 }}">Distance</a>
		</div>
		<div class="grid_2 omega">
		<a class="button blue small" 
		href="/rowers/workout/{{ id }}/flexchart2/{{ xparam }}/{{ yparam2 }}/{{ yparam1 }}">Swap Y axes</a>
		</div>
	</div>

	<div id="y-axis" class="grid_6 omega">
		<div class="grid_1 prefix_2 alpha">
		<a class="button blue small" href="/rowers/workout/{{ id }}/flexchart2/{{ xparam }}/{{ yparam1 }}/pace">Pace</a>
		</div>
		<div class="grid_1">
		<a class="button blue small" href="/rowers/workout/{{ id }}/flexchart2/{{ xparam }}/{{ yparam1 }}/hr">HR</a>
		</div>
		<div class="grid_1">
		<a class="button blue small" href="/rowers/workout/{{ id }}/flexchart2/{{ xparam }}/{{ yparam1 }}/spm">SPM</a>
		</div>
		<div class="grid_1 omega">
		<a class="button blue small" href="/rowers/workout/{{ id }}/flexchart2/{{ xparam }}/{{ yparam1 }}/power">Power</a>
		</div>
	</div>

</div>

<div id="theplot" class="grid_12 alpha">


    {{ the_div|safe }}

</div>

{% endblock %}