Commit 0fabd752 authored by Lukas Burgey's avatar Lukas Burgey

Fix the position of the scripts

parent 065c1bc8
......@@ -20,6 +20,8 @@
<link rel="mask-icon" href="{% static "safari-pinned-tab.svg" %}" color="#5bbad5">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="{% static 'skat.js' %}"></script>
{% block script %}{% endblock %}
</head>
<body>
<nav class="navbar navbar-default">
......@@ -118,6 +120,4 @@
{% block content %}{% endblock %}
</div>
</body>
{% block script %}{% endblock %}
<script src="{% static 'skat.js' %}"></script>
</html>
......@@ -5,55 +5,57 @@
{% block nav-combinatorics %}class="active"{% endblock %}
{% block script %}
<script>
{% for n, ks in frei_liegen.items %}
new Chart($("#chartfrei{{ n }}")[0].getContext("2d"), {
type: 'scatter',
options: {
events: ["mousemove", "mouseenter"],
animation: {
duration: 1000,
},
legend: {
display: false,
$(window).on("load", function() {
{% for n, ks in frei_liegen.items %}
new Chart($("#chartfrei{{ n }}")[0].getContext("2d"), {
type: 'scatter',
options: {
events: ["mousemove", "mouseenter"],
animation: {
duration: 1000,
},
legend: {
display: false,
},
scales: {
xAxes: [{
scaleLabel: {
labelString: "k",
display: true,
},
ticks: {
max: {{ n }},
beginAtZero: true,
stepSize: 1,
},
}],
yAxes: [{
scaleLabel: {
labelString: "p",
display: true,
},
ticks: {
max: 1,
beginAtZero: true,
},
}]
}
},
scales: {
xAxes: [{
scaleLabel: {
labelString: "k",
display: true,
},
ticks: {
max: {{ n }},
beginAtZero: true,
stepSize: 1,
data: {
datasets: [
{
label: "{{ n }}",
borderWidth: 3,
lineTension: 0.5,
fill: false,
data: [{% for k, p in ks.items %}
{x:{{ k }}, y:{{ p }}},{% endfor %}]
},
}],
yAxes: [{
scaleLabel: {
labelString: "p",
display: true,
},
ticks: {
max: 1,
beginAtZero: true,
},
}]
]
}
},
data: {
datasets: [
{
label: "{{ n }}",
borderWidth: 3,
lineTension: 0.5,
fill: false,
data: [{% for k, p in ks.items %}
{x:{{ k }}, y:{{ p }}},{% endfor %}]
},
]
}
});
{% endfor %}
});
{% endfor %}
</script>
{% endblock %}
......
......@@ -85,6 +85,29 @@
{% block script %}
<script>
// load all images
var schelleImg = new Image();
schelleImg.src = '{% static "skat/schelle.png" %}';
var herzImg = new Image();
herzImg.src = '{% static "skat/herz.png" %}';
var blattImg = new Image();
blattImg.src = '{% static "skat/blatt.png" %}';
var eichelImg = new Image();
eichelImg.src = '{% static "skat/eichel.png" %}';
var nullImg = new Image();
nullImg.src = '{% static "skat/null.png" %}';
var grandImg = new Image();
grandImg.src = '{% static "skat/grand.jpg" %}';
var winImg = new Image();
winImg.src = '{% static "skat/win.jpg" %}';
var loseImg = new Image();
loseImg.src = '{% static "skat/lose.jpg" %}';
var label = {};
label["True"] = "Win";
label["False"] = "Defeat";
// prepare datasets
var dataSetsPointHistory = [
{% for player in player_list|dictsort:"stats.points" %}{
borderWidth: 3,
......@@ -97,9 +120,7 @@ var dataSetsPointHistory = [
data: [{% for point in player.stats.point_history %}{x:{{ forloop.counter0 }},y:{{ point }}},{% endfor %}],
},{% endfor %}
];
scatterChart("#chartpoint_history", dataSetsPointHistory);
</script>
<script>
var dataSetsEloHistory = [
{% for player in player_list|dictsort:"stats.points" %}{
label: "{{ player.name }}",
......@@ -112,26 +133,13 @@ var dataSetsEloHistory = [
data: [{% for elo in player.stats.elo_history %}{x:{{ forloop.counter0 }},y:{{ elo }},},{% endfor %}]
},{% endfor %}
];
scatterChart("#chart_elo_history", dataSetsEloHistory);
</script>
<script>
// former typestats
var ctx = $("#chart0")[0].getContext("2d");
var schelleImg = new Image();
schelleImg.src = '{% static "skat/schelle.png" %}';
var herzImg = new Image();
herzImg.src = '{% static "skat/herz.png" %}';
var blattImg = new Image();
blattImg.src = '{% static "skat/blatt.png" %}';
var eichelImg = new Image();
eichelImg.src = '{% static "skat/eichel.png" %}';
var nullImg = new Image();
nullImg.src = '{% static "skat/null.png" %}';
var grandImg = new Image();
grandImg.src = '{% static "skat/grand.jpg" %}';
var pattern = {}
// draw all charts, when the page is loaded
$(window).on("load", function () {
scatterChart("#chartpoint_history", dataSetsPointHistory);
scatterChart("#chart_elo_history", dataSetsEloHistory);
var pattern = {}
var ctx = $("#chart0")[0].getContext("2d");
pattern['Schelle'] = ctx.createPattern(schelleImg, 'repeat');
pattern['Herz'] = ctx.createPattern(herzImg, 'repeat');
pattern['Blatt'] = ctx.createPattern(blattImg, 'repeat');
......@@ -173,24 +181,10 @@ $(window).on("load", function () {
},
}
});
});
</script>
<script>
// former overall
var ctx1 = $("#chart1")[0].getContext("2d");
var winImg = new Image();
winImg.src = '{% static "skat/win.jpg" %}';
var loseImg = new Image();
loseImg.src = '{% static "skat/lose.jpg" %}';
var label = {};
label["True"] = "Win";
label["False"] = "Defeat";
$(window).on("load", function () {
var pattern = {}
pattern["True"] = ctx1.createPattern(winImg, 'repeat');
pattern["False"] = ctx1.createPattern(loseImg, 'repeat');
var ctx1 = $("#chart1")[0].getContext("2d");
var winPattern = {}
winPattern["True"] = ctx1.createPattern(winImg, 'repeat');
winPattern["False"] = ctx1.createPattern(loseImg, 'repeat');
var typeChart = new Chart(ctx1, {
type: 'doughnut',
......@@ -204,7 +198,7 @@ $(window).on("load", function () {
borderWidth: 1,
hoverBorderWidth: 3,
backgroundColor: [
{% for row in won_list %}pattern['{{ row.won }}'],
{% for row in won_list %}winPattern['{{ row.won }}'],
{% endfor %}],
data: [
{% for row in won_list %}"{{ row.count }}",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment