mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
feat: routes overview - fix distanceScale value
This commit is contained in:
parent
28bc6ccde6
commit
834d6f6cc7
17 changed files with 328 additions and 130 deletions
|
|
@ -29,12 +29,11 @@ function overviewRoutes() {
|
|||
function routesOverviewAddLines() {
|
||||
body.innerHTML = "";
|
||||
let lines = "";
|
||||
const unit = distanceUnitInput.value;
|
||||
|
||||
for (const route of pack.routes) {
|
||||
route.name = route.name || Routes.generateName(route);
|
||||
route.length = route.length || getRouteLength(route.i);
|
||||
const length = rn(route.length * distanceScale) + " " + unit;
|
||||
route.length = route.length || Routes.getLength(route.i);
|
||||
const length = rn(route.length * distanceScale) + " " + distanceUnitInput.value;
|
||||
|
||||
lines += /* html */ `<div
|
||||
class="states"
|
||||
|
|
@ -56,7 +55,7 @@ function overviewRoutes() {
|
|||
// update footer
|
||||
routesFooterNumber.innerHTML = pack.routes.length;
|
||||
const averageLength = rn(d3.mean(pack.routes.map(r => r.length)));
|
||||
routesFooterLength.innerHTML = averageLength * distanceScale + " " + unit;
|
||||
routesFooterLength.innerHTML = averageLength * distanceScale + " " + distanceUnitInput.value;
|
||||
|
||||
// add listeners
|
||||
body.querySelectorAll("div.states").forEach(el => el.on("mouseenter", routeHighlightOn));
|
||||
|
|
@ -68,11 +67,6 @@ function overviewRoutes() {
|
|||
applySorting(routesHeader);
|
||||
}
|
||||
|
||||
function getRouteLength(routeId) {
|
||||
const path = routes.select("#route" + routeId).node();
|
||||
return rn(path.getTotalLength() / 2, 2);
|
||||
}
|
||||
|
||||
function routeHighlightOn(event) {
|
||||
if (!layerIsOn("toggleRoutes")) toggleRoutes();
|
||||
const routeId = +event.target.dataset.id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue