Self hosted FLOSS fitness/workout, nutrition and weight tracker
Make width of weight diagram relative to browser width
Roland Geider400300e3956d
diff --git a/wger/manager/static/css/workout-manager-common.css b/wger/manager/static/css/workout-manager-common.cssnew file mode 100644index 000000000..4121b8f8f--- /dev/null+++ b/wger/manager/static/css/workout-manager-common.css@@ -0,0 +1,130 @@+/*+ This file is part of Workout Manager++ Workout Manager is free software: you can redistribute it and/or modify+ it under the terms of the GNU Affero General Public License as published by+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ Workout Manager is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU Affero General Public License for more details.++ You should have received a copy of the GNU Affero General Public License+ along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.+*/++/**************************************************************+ *+ * This file contains custom classes and styles for both mobile and desktop version+ *+ **************************************************************/+++/* Use Open Sans for the body text */+.ui-body-c,+.ui-body-c input,+.ui-body-c select,+.ui-body-c textarea,+.ui-body-c button {+ font-family: "Open Sans Light", Arial, Helvetica, sans-serif;+ font-weight: 300;+}+.ui-body-c .ui-link{+ font-weight: normal;+}++++/**************************************************************+ * Styling for the SVG elements on the weight chart+ **************************************************************/++.axis path, .axis line {+ fill: none;+ stroke: #000;+ shape-rendering: crispEdges;+}++.area {+ fill: lightsteelblue;+}++.line {+ fill: none;+ stroke: steelblue;+ stroke-width: 1.5px;+}++.dot {+ fill: white;+ stroke: steelblue;+ stroke-width: 1.5px;+}++circle:hover{+ fill: #204a87;+ stroke: #204a87;+}++circle{+ cursor: pointer;+}++.brush .extent {+ stroke: #fff;+ fill-opacity: .125;+ shape-rendering: crispEdges;+}++/* Color series from d3.scale.category10() */+circle.color-1f77b4:hover+{+ fill: #1f77b4;+}++circle.color-ff7f0e:hover+{+ fill: #ff7f0e;+}++circle.color-2ca02c:hover+{+ fill: #2ca02c;+}++circle.color-d62728:hover+{+ fill: #d62728;+}++circle.color-9467bd:hover+{+ fill: #9467bd;+}++circle.color-8c564b:hover+{+ fill: #8c564b;+}++circle.color-e377c2:hover+{+ fill: #e377c2;+}++circle.color-7f7f7f:hover+{+ fill: #7f7f7f;+}++circle.color-bcbd22:hover+{+ fill: #bcbd22;+}++circle.color-17becf:hover+{+ fill: #17becf;+}\ No newline at end of filediff --git a/wger/manager/static/css/workout-manager.css b/wger/manager/static/css/workout-manager.cssindex 645c50d2f..4bda996c2 100644--- a/wger/manager/static/css/workout-manager.css+++ b/wger/manager/static/css/workout-manager.css@@ -124,100 +124,6 @@ div.muscle-background-/**************************************************************- * Styling for the SVG elements on the weight chart- **************************************************************/--.axis path, .axis line {- fill: none;- stroke: #000;- shape-rendering: crispEdges;-}--.area {- fill: lightsteelblue;-}--.line {- fill: none;- stroke: steelblue;- stroke-width: 1.5px;-}--.dot {- fill: white;- stroke: steelblue;- stroke-width: 1.5px;-}--circle:hover{- fill: #204a87;- stroke: #204a87;-}--circle{- cursor: pointer;-}--.brush .extent {- stroke: #fff;- fill-opacity: .125;- shape-rendering: crispEdges;-}--/* Color series from d3.scale.category10() */-circle.color-1f77b4:hover-{- fill: #1f77b4;-}--circle.color-ff7f0e:hover-{- fill: #ff7f0e;-}--circle.color-2ca02c:hover-{- fill: #2ca02c;-}--circle.color-d62728:hover-{- fill: #d62728;-}--circle.color-9467bd:hover-{- fill: #9467bd;-}--circle.color-8c564b:hover-{- fill: #8c564b;-}--circle.color-e377c2:hover-{- fill: #e377c2;-}--circle.color-7f7f7f:hover-{- fill: #7f7f7f;-}--circle.color-bcbd22:hover-{- fill: #bcbd22;-}--circle.color-17becf:hover-{- fill: #17becf;-}---/*************************************************************** Classes Error form**************************************************************/diff --git a/wger/manager/static/js/workout-manager.js b/wger/manager/static/js/workout-manager.jsindex 7e70ae281..d511469fa 100644--- a/wger/manager/static/js/workout-manager.js+++ b/wger/manager/static/js/workout-manager.js@@ -475,7 +475,7 @@ function getDate(d) {return new Date(d);}-function weight_chart(data)+function weight_chart(data, width_factor){// Return if there is no data to processif(data == '')@@ -483,14 +483,23 @@ function weight_chart(data)return;}+++ // Calculate the size+ var width_factor = typeof width_factor !== 'undefined' ? width_factor: 600;+ var height_factor = width_factor / 600 * 400;+ var height2_factor = width_factor / 600 * 390;+ var bottom_factor = width_factor / 600 * 150;+ var top_factor = width_factor / 600 * 290;+var minDate = getDate(data[0].x),maxDate = getDate(data[data.length-1].x);- var margin = {top: 10, right: 10, bottom: 150, left: 40},- margin2 = {top: 290, right: 10, bottom: 50, left: 40},- width = 600 - margin.left - margin.right,- height = 400 - margin.top - margin.bottom,- height2 = 390 - margin2.top - margin2.bottom;+ var margin = {top: 10, right: 10, bottom: bottom_factor, left: 40},+ margin2 = {top: top_factor, right: 10, bottom: 50, left: 40},+ width = width_factor - margin.left - margin.right,+ height = height_factor - margin.top - margin.bottom,+ height2 = height2_factor - margin2.top - margin2.bottom;var x = d3.time.scale().domain([minDate, maxDate])diff --git a/wger/manager/templates/mobile/base.html b/wger/manager/templates/mobile/base.htmlindex f1df6fdea..b179d2a0f 100644--- a/wger/manager/templates/mobile/base.html+++ b/wger/manager/templates/mobile/base.html@@ -13,7 +13,7 @@{% endif %}</div>{% endif %}- <div data-role="content">+ <div data-role="content" id="content"><h2>{% block title %}{% endblock %}</h2>{% block content %}{% endblock %}{% block sidebar %}{% endblock %}diff --git a/wger/manager/templates/mobile/template.html b/wger/manager/templates/mobile/template.htmlindex a27cacf43..a4b4a6d10 100644--- a/wger/manager/templates/mobile/template.html+++ b/wger/manager/templates/mobile/template.html@@ -7,28 +7,26 @@<meta name="author" content="Roland Geider"><!--- This file is part of Workout Manager+ This file is part of wger Workout Manager- Workout Manager is free software: you can redistribute it and/or modify+ wger Workout Manager is free software: you can redistribute it and/or modifyit under the terms of the GNU Affero General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.- Workout Manager is distributed in the hope that it will be useful,+ wger Workout Manager is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU Affero General Public License for more details.You should have received a copy of the GNU Affero General Public License- along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.+ along with wger Workout Manager. If not, see <http://www.gnu.org/licenses/>.--><title>{% block title %}{% endblock %}</title><meta name="viewport" content="width=device-width, initial-scale=1">- <!--<link rel="stylesheet" type="text/css" href="{% static 'css/yaml/demos/css/flexible-grids.css' %} ">--> <!-- CSS framework for the layout -->- <!--<link rel="stylesheet" type="text/css" href="{% static 'css/yaml/custom-yaml.css' %}">--> <!-- Customisations for yaml --><link rel="stylesheet" type="text/css" href="{% static 'css/jquery-mobile.css' %}"><link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager-common.css' %}">@@ -38,8 +36,8 @@<script src="{% static 'js/jquery.js' %}" type="text/javascript"></script><script src="{% static 'js/jquery-ui.js' %}" type="text/javascript"></script>- <script src="{% static 'js/jquery-mobile.js' %}" type="text/javascript"></script>- <!--<script src="{% static 'js/workout-manager.js' %}" type="text/javascript"></script>-->+ <script src="{% static 'js/jquery-mobile.js' %}" type="text/javascript"></script>+ <script src="{% static 'js/workout-manager.js' %}" type="text/javascript"></script>{% block header %}{% endblock %}</head>diff --git a/wger/weight/templates/mobile/weight_overview.html b/wger/weight/templates/mobile/weight_overview.htmlindex 1d0cfcf6e..a6f696bd0 100644--- a/wger/weight/templates/mobile/weight_overview.html+++ b/wger/weight/templates/mobile/weight_overview.html@@ -39,32 +39,7 @@ $(document).ready(function () {}$.getJSON("/weight/api/get_weight_data/", filter_data, function(json) {- weight_chart(json);- });-- // Add datepickers to the filter elements-- $("#weight_filter_from").datepicker({ dateFormat: "yy-mm-dd",- {% if min_date %}minDate: {{ min_date }}{% endif %}- });- $("#weight_filter_to").datepicker({ dateFormat: "yy-mm-dd",- {% if max_date %}maxDate: {{max_date}}{% endif %}- });-- // Process the filter- $("#weight_diagram_refresh").click(function(e) {-- e.preventDefault();-- var date_min = $("#weight_filter_from").val();- var date_max = $("#weight_filter_to").val();-- $.getJSON("/weight/api/get_weight_data/",- {'date_min': date_min,- 'date_max': date_max},- function(json) {- weight_chart(json);- });+ weight_chart(json, $('#content').width() * 0.95);});});</script>