-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add heatmap for non-IV encounter to mon stats (#1026)
* Update DbStatsReader.py * Update statistics.py * Update mon_statistics.html * Update DbStatsReader.py * Update statistics.py * Travis is sometimes fun :D E226 missing whitespace around arithmetic operator * Update mon_statistics.html
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block header %} | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" crossorigin="" /> | ||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" crossorigin="anonymous"> | ||
{% endblock %} | ||
|
||
{% block scripts %} | ||
|
@@ -15,8 +17,17 @@ | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.68/pdfmake.min.js"></script> | ||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.68/vfs_fonts.js"></script> | ||
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.html5.min.js"></script> | ||
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> | ||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.heat/0.2.0/leaflet-heat.js"></script> | ||
<script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> | ||
<script> | ||
$(function () { | ||
|
||
const storedCenter = getStoredCenter(); | ||
var map = L.map("heatmap").setView(storedCenter.split(","), 12); | ||
var tiles = L.tileLayer("https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png").addTo(map); | ||
var heat = L.heatLayer([], {radius: 10, blur: 5}).addTo(map); | ||
var unfiltered_points = []; | ||
|
||
var options_dots = { | ||
xaxis: { | ||
|
@@ -150,8 +161,20 @@ | |
} | ||
|
||
}); | ||
|
||
$.ajax({ | ||
"url": "get_noniv_encounters_count", | ||
"type": "GET", | ||
"cache": false, | ||
"dataType": "json", | ||
success: function (result) { | ||
console.log(result); | ||
unfiltered_points = result.data.map(function (p) { return {"count": p[0], "lat": p[1], "lon": p[2]}; }) | ||
setupSlider(); | ||
} | ||
}); | ||
|
||
var previousPoint = null, previousLabel = null; | ||
var previousPoint = null, previousLabel = null; | ||
|
||
$.fn.UseTooltip = function () { | ||
$(this).bind("plothover", function (event, pos, item) { | ||
|
@@ -245,6 +268,40 @@ | |
opacity: 0.9 | ||
}).appendTo("body").fadeIn(200); | ||
} | ||
|
||
function setupSlider() { | ||
$("#slider-range-max").slider({ | ||
range: "max", | ||
min: 1, | ||
max: Math.max.apply(Math, unfiltered_points.map(function(p) { return p.count; })), | ||
value: 2, | ||
slide: function(event, ui) { | ||
$("#slider-amount").val(ui.value); | ||
slider_redrawHeatmap(); | ||
} | ||
}); | ||
$("#slider-amount").val($("#slider-range-max").slider("value")); | ||
slider_redrawHeatmap(); | ||
} | ||
|
||
function slider_redrawHeatmap() { | ||
min_val = $("#slider-amount").val() | ||
heatmap_points = unfiltered_points.filter(p => p.count >= min_val) | ||
.map(p => [p.lat, p.lon]); | ||
heat.setLatLngs(heatmap_points); | ||
} | ||
|
||
function getStoredCenter() { | ||
var val = localStorage.getItem("settings"); | ||
if (val == null) { | ||
return "52.521374,13.411201"; | ||
} | ||
var settings = JSON.parse(val); | ||
if (settings["center"] === undefined) { | ||
return "52.521374,13.411201"; | ||
} | ||
return settings["center"]; | ||
} | ||
|
||
function setGrid(tableGridHtmlId, gridData, columns, defs) { | ||
$(tableGridHtmlId).DataTable({ | ||
|
@@ -344,4 +401,11 @@ <h2>Spawn Statistics</h2> | |
<br> | ||
<h2>Recent IV 100 mon</h2> | ||
<table id="show-data-good-pokemon" class="table" style="width:100%;"></table> | ||
<h2>Heatmap of non-iv encounters in last 4 hours</h2> | ||
<div id="slider-range-max"></div> | ||
<p> | ||
<label for="slider-amount">Minimum number of non-IV encounters per spawn:</label> | ||
<input type="text" id="slider-amount" readonly style="border:0; color:#f6931f; font-weight:bold;"> | ||
</p> | ||
<div id="heatmap" style="width:100%; height:600px;"></div> | ||
{% endblock %} |