@raruto/leaflet-elevation 1.7.5 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -2
- package/dist/leaflet-elevation.css +0 -1
- package/dist/leaflet-elevation.js +721 -885
- package/dist/leaflet-elevation.js.map +1 -1
- package/dist/leaflet-elevation.min.css +1 -1
- package/dist/leaflet-elevation.min.js +3 -1
- package/dist/leaflet-elevation.min.js.map +1 -1
- package/package.json +1 -1
- package/src/acceleration.js +11 -21
- package/src/altitude.js +21 -22
- package/src/chart.js +91 -178
- package/src/components.js +163 -115
- package/src/control.js +116 -209
- package/src/distance.js +15 -13
- package/src/index.css +0 -1
- package/src/index.js +12 -1
- package/src/marker.js +38 -98
- package/src/options.js +1 -8
- package/src/slope.js +9 -18
- package/src/speed.js +11 -21
- package/src/time.js +15 -10
- package/src/utils.js +77 -99
|
@@ -101,31 +101,6 @@
|
|
|
101
101
|
|
|
102
102
|
return deepMerge.apply(void 0, [target].concat(sources));
|
|
103
103
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Wait for document load before execute function.
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
|
-
function deferFunc(f) {
|
|
109
|
-
if (document.readyState !== 'complete') window.addEventListener("load", f, {
|
|
110
|
-
once: true
|
|
111
|
-
});else f();
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Debounce function to limit events are being fired.
|
|
115
|
-
*/
|
|
116
|
-
|
|
117
|
-
function debounce(func, wait, context, immediate) {
|
|
118
|
-
var timeout;
|
|
119
|
-
return function () {
|
|
120
|
-
var args = arguments;
|
|
121
|
-
clearTimeout(timeout);
|
|
122
|
-
timeout = setTimeout(function () {
|
|
123
|
-
timeout = null;
|
|
124
|
-
if (!immediate) func.apply(context, args);
|
|
125
|
-
}, wait);
|
|
126
|
-
if (immediate && !timeout) func.apply(context, args);
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
104
|
var SEC = 1000;
|
|
130
105
|
var MIN = SEC * 60;
|
|
131
106
|
var HOUR = MIN * 60;
|
|
@@ -283,13 +258,6 @@
|
|
|
283
258
|
|
|
284
259
|
return layer;
|
|
285
260
|
}
|
|
286
|
-
/**
|
|
287
|
-
* Check DOM element visibility.
|
|
288
|
-
*/
|
|
289
|
-
|
|
290
|
-
function isDomVisible(elem) {
|
|
291
|
-
return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
|
|
292
|
-
}
|
|
293
261
|
/**
|
|
294
262
|
* Check object type.
|
|
295
263
|
*/
|
|
@@ -297,40 +265,6 @@
|
|
|
297
265
|
function isObject(item) {
|
|
298
266
|
return item && _typeof(item) === 'object' && !Array.isArray(item);
|
|
299
267
|
}
|
|
300
|
-
/**
|
|
301
|
-
* Check DOM element viewport visibility.
|
|
302
|
-
*/
|
|
303
|
-
|
|
304
|
-
function isVisible(elem) {
|
|
305
|
-
if (!elem) return false;
|
|
306
|
-
var styles = window.getComputedStyle(elem);
|
|
307
|
-
|
|
308
|
-
function isVisibleByStyles(elem, styles) {
|
|
309
|
-
return styles.visibility !== 'hidden' && styles.display !== 'none';
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function isAboveOtherElements(elem, styles) {
|
|
313
|
-
var boundingRect = elem.getBoundingClientRect();
|
|
314
|
-
var left = boundingRect.left + 1;
|
|
315
|
-
var right = boundingRect.right - 1;
|
|
316
|
-
var top = boundingRect.top + 1;
|
|
317
|
-
var bottom = boundingRect.bottom - 1;
|
|
318
|
-
var above = true;
|
|
319
|
-
var pointerEvents = elem.style.pointerEvents;
|
|
320
|
-
if (styles['pointer-events'] == 'none') elem.style.pointerEvents = 'auto';
|
|
321
|
-
if (document.elementFromPoint(left, top) !== elem) above = false;
|
|
322
|
-
if (document.elementFromPoint(right, top) !== elem) above = false; // Only for completely visible elements
|
|
323
|
-
// if (document.elementFromPoint(left, bottom) !== elem) above = false;
|
|
324
|
-
// if (document.elementFromPoint(right, bottom) !== elem) above = false;
|
|
325
|
-
|
|
326
|
-
elem.style.pointerEvents = pointerEvents;
|
|
327
|
-
return above;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (!isVisibleByStyles(elem, styles)) return false;
|
|
331
|
-
if (!isAboveOtherElements(elem, styles)) return false;
|
|
332
|
-
return true;
|
|
333
|
-
}
|
|
334
268
|
/**
|
|
335
269
|
* Check JSON object type.
|
|
336
270
|
*/
|
|
@@ -368,6 +302,22 @@
|
|
|
368
302
|
return documentElement ? documentElement.nodeName !== "HTML" : false;
|
|
369
303
|
}
|
|
370
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Generate download data event.
|
|
307
|
+
*/
|
|
308
|
+
|
|
309
|
+
function saveFile(dataURI, fileName) {
|
|
310
|
+
var a = create('a', '', {
|
|
311
|
+
href: dataURI,
|
|
312
|
+
target: '_new',
|
|
313
|
+
download: fileName || "",
|
|
314
|
+
style: "display:none;"
|
|
315
|
+
});
|
|
316
|
+
var b = document.body;
|
|
317
|
+
b.appendChild(a);
|
|
318
|
+
a.click();
|
|
319
|
+
b.removeChild(a);
|
|
320
|
+
}
|
|
371
321
|
/**
|
|
372
322
|
* Async JS script download.
|
|
373
323
|
*/
|
|
@@ -390,50 +340,69 @@
|
|
|
390
340
|
document.head.appendChild(tag);
|
|
391
341
|
});
|
|
392
342
|
}
|
|
343
|
+
function lazyLoad(src, control) {
|
|
344
|
+
if (!control.options.lazyLoadJS) return Promise.resolve();
|
|
345
|
+
var Elevation = L.Control.Elevation;
|
|
346
|
+
var loader = '';
|
|
347
|
+
var condition = false;
|
|
348
|
+
|
|
349
|
+
switch (src) {
|
|
350
|
+
case control.__D3:
|
|
351
|
+
loader = '_d3LazyLoader';
|
|
352
|
+
condition = (typeof d3 === "undefined" ? "undefined" : _typeof(d3)) !== 'object';
|
|
353
|
+
break;
|
|
354
|
+
|
|
355
|
+
case control.__TOGEOJSON:
|
|
356
|
+
loader = '_togeojsonLazyLoader';
|
|
357
|
+
condition = (typeof toGeoJSON === "undefined" ? "undefined" : _typeof(toGeoJSON)) !== 'object';
|
|
358
|
+
break;
|
|
359
|
+
|
|
360
|
+
case control.__LGEOMUTIL:
|
|
361
|
+
loader = '_geomutilLazyLoader';
|
|
362
|
+
condition = _typeof(L.GeometryUtil) !== 'object';
|
|
363
|
+
|
|
364
|
+
case control.__LALMOSTOVER:
|
|
365
|
+
loader = '_almostoverLazyLoader';
|
|
366
|
+
condition = typeof L.Handler.AlmostOver !== 'function ';
|
|
367
|
+
break;
|
|
368
|
+
|
|
369
|
+
case control.__LDISTANCEM:
|
|
370
|
+
loader = '_distanceMarkersLazyLoader';
|
|
371
|
+
condition = typeof L.DistanceMarkers !== 'function';
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return Elevation[loader] = lazyLoader(src, condition, Elevation[loader]);
|
|
376
|
+
}
|
|
393
377
|
/**
|
|
394
|
-
*
|
|
378
|
+
* Convert SVG Path into Path2D and then update canvas
|
|
395
379
|
*/
|
|
396
380
|
|
|
397
|
-
function
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
381
|
+
function drawCanvas(ctx, path) {
|
|
382
|
+
path.classed('canvas-path', true);
|
|
383
|
+
ctx.beginPath();
|
|
384
|
+
ctx.moveTo(0, 0);
|
|
385
|
+
var p = new Path2D(path.attr('d'));
|
|
386
|
+
ctx.strokeStyle = path.attr('stroke');
|
|
387
|
+
ctx.fillStyle = path.attr('fill');
|
|
388
|
+
ctx.lineWidth = 1.25;
|
|
389
|
+
ctx.globalCompositeOperation = 'source-over'; // stroke opacity
|
|
390
|
+
|
|
391
|
+
ctx.globalAlpha = path.attr('stroke-opacity') || 0.3;
|
|
392
|
+
ctx.stroke(p); // fill opacity
|
|
393
|
+
|
|
394
|
+
ctx.globalAlpha = path.attr('fill-opacity') || 0.45;
|
|
395
|
+
ctx.fill(p);
|
|
396
|
+
ctx.globalAlpha = 1;
|
|
397
|
+
ctx.closePath();
|
|
408
398
|
}
|
|
409
399
|
/**
|
|
410
|
-
*
|
|
400
|
+
* Limit a number between min / max values
|
|
411
401
|
*/
|
|
412
402
|
|
|
413
|
-
function
|
|
414
|
-
return
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
var scrollFn = function scrollFn() {
|
|
418
|
-
if (!ticking) {
|
|
419
|
-
L.Util.requestAnimFrame(function () {
|
|
420
|
-
if (isVisible(elem)) {
|
|
421
|
-
window.removeEventListener('scroll', scrollFn);
|
|
422
|
-
resolve();
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
ticking = false;
|
|
426
|
-
});
|
|
427
|
-
ticking = true;
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
window.addEventListener('scroll', scrollFn);
|
|
432
|
-
if (elem) elem.addEventListener('mouseenter', scrollFn, {
|
|
433
|
-
once: true
|
|
434
|
-
});
|
|
435
|
-
scrollFn();
|
|
436
|
-
});
|
|
403
|
+
function clamp(val, range) {
|
|
404
|
+
if (range) return val < range[0] ? range[0] : val > range[1] ? range[1] : val;
|
|
405
|
+
return val;
|
|
437
406
|
}
|
|
438
407
|
/**
|
|
439
408
|
* A little bit safier than L.DomUtil.addClass
|
|
@@ -524,9 +493,17 @@
|
|
|
524
493
|
*/
|
|
525
494
|
|
|
526
495
|
var hasClass = L.DomUtil.hasClass;
|
|
496
|
+
/**
|
|
497
|
+
* Generate a random string
|
|
498
|
+
*/
|
|
499
|
+
|
|
527
500
|
function randomId() {
|
|
528
501
|
return Math.random().toString(36).substr(2, 9);
|
|
529
502
|
}
|
|
503
|
+
/**
|
|
504
|
+
* Execute a function foreach element in object
|
|
505
|
+
*/
|
|
506
|
+
|
|
530
507
|
function each(obj, fn) {
|
|
531
508
|
for (var i in obj) {
|
|
532
509
|
fn(obj[i], i);
|
|
@@ -536,18 +513,16 @@
|
|
|
536
513
|
var _ = /*#__PURE__*/Object.freeze({
|
|
537
514
|
__proto__: null,
|
|
538
515
|
deepMerge: deepMerge,
|
|
539
|
-
deferFunc: deferFunc,
|
|
540
|
-
debounce: debounce,
|
|
541
516
|
formatTime: formatTime,
|
|
542
517
|
GeoJSONLoader: GeoJSONLoader,
|
|
543
|
-
isDomVisible: isDomVisible,
|
|
544
518
|
isObject: isObject,
|
|
545
|
-
isVisible: isVisible,
|
|
546
519
|
isJSONDoc: isJSONDoc,
|
|
547
520
|
isXMLDoc: isXMLDoc,
|
|
548
|
-
lazyLoader: lazyLoader,
|
|
549
521
|
saveFile: saveFile,
|
|
550
|
-
|
|
522
|
+
lazyLoader: lazyLoader,
|
|
523
|
+
lazyLoad: lazyLoad,
|
|
524
|
+
drawCanvas: drawCanvas,
|
|
525
|
+
clamp: clamp,
|
|
551
526
|
addClass: addClass,
|
|
552
527
|
removeClass: removeClass,
|
|
553
528
|
toggleClass: toggleClass,
|
|
@@ -672,58 +647,59 @@
|
|
|
672
647
|
props.type = "grid";
|
|
673
648
|
return Axis(props);
|
|
674
649
|
};
|
|
675
|
-
var
|
|
650
|
+
var PositionMarker = function PositionMarker(_ref4) {
|
|
676
651
|
var theme = _ref4.theme,
|
|
677
652
|
_ref4$xCoord = _ref4.xCoord,
|
|
678
653
|
xCoord = _ref4$xCoord === void 0 ? 0 : _ref4$xCoord,
|
|
679
654
|
_ref4$yCoord = _ref4.yCoord,
|
|
680
655
|
yCoord = _ref4$yCoord === void 0 ? 0 : _ref4$yCoord,
|
|
656
|
+
_ref4$labels = _ref4.labels,
|
|
657
|
+
labels = _ref4$labels === void 0 ? {} : _ref4$labels,
|
|
658
|
+
_ref4$item = _ref4.item,
|
|
659
|
+
item = _ref4$item === void 0 ? {} : _ref4$item,
|
|
681
660
|
_ref4$length = _ref4.length,
|
|
682
661
|
length = _ref4$length === void 0 ? 0 : _ref4$length;
|
|
683
|
-
return function (
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
var
|
|
697
|
-
|
|
698
|
-
|
|
662
|
+
return function (g) {
|
|
663
|
+
var line = g.select('.height-focus.line');
|
|
664
|
+
var circle = g.select('.height-focus.circle-lower');
|
|
665
|
+
var text = g.select('.height-focus-label');
|
|
666
|
+
if (!line.node()) line = g.append('svg:line');
|
|
667
|
+
if (!circle.node()) circle = g.append('svg:circle');
|
|
668
|
+
if (!text.node()) text = g.append('svg:text');
|
|
669
|
+
if (isNaN(xCoord) || isNaN(yCoord)) return g;
|
|
670
|
+
circle.attr("class", theme + " height-focus circle-lower").attr("transform", "translate(" + xCoord + "," + yCoord + ")").attr("r", 6).attr("cx", 0).attr("cy", 0);
|
|
671
|
+
line.attr("class", theme + " height-focus line").attr("x1", xCoord).attr("x2", xCoord).attr("y1", yCoord).attr("y2", length);
|
|
672
|
+
text.attr("class", theme + " height-focus-label").style("pointer-events", "none").attr("x", xCoord + 5).attr("y", length);
|
|
673
|
+
var label;
|
|
674
|
+
|
|
675
|
+
for (var i in labels) {
|
|
676
|
+
label = text.select(".height-focus-" + labels[i].name);
|
|
677
|
+
|
|
678
|
+
if (!label.size()) {
|
|
679
|
+
label = text.append("svg:tspan").attr("class", "height-focus-" + labels[i].name).attr("dy", "1.5em");
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
label.text(typeof labels[i].value !== "function" ? labels[i].value : labels[i].value(item));
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
text.select('tspan').attr("dy", text.selectAll('tspan').size() > 1 ? "-1.5em" : "0em");
|
|
699
686
|
text.selectAll('tspan').attr("x", xCoord + 5);
|
|
700
|
-
return
|
|
701
|
-
};
|
|
702
|
-
};
|
|
703
|
-
var HeightFocusMarker = function HeightFocusMarker(_ref6) {
|
|
704
|
-
var theme = _ref6.theme,
|
|
705
|
-
_ref6$xCoord = _ref6.xCoord,
|
|
706
|
-
xCoord = _ref6$xCoord === void 0 ? 0 : _ref6$xCoord,
|
|
707
|
-
_ref6$yCoord = _ref6.yCoord,
|
|
708
|
-
yCoord = _ref6$yCoord === void 0 ? 0 : _ref6$yCoord;
|
|
709
|
-
return function (circle) {
|
|
710
|
-
return circle.attr("class", theme + " height-focus circle-lower").attr("transform", "translate(" + xCoord + "," + yCoord + ")").attr("r", 6).attr("cx", 0).attr("cy", 0);
|
|
687
|
+
return g;
|
|
711
688
|
};
|
|
712
689
|
};
|
|
713
|
-
var LegendItem = function LegendItem(
|
|
714
|
-
var name =
|
|
715
|
-
label =
|
|
716
|
-
width =
|
|
717
|
-
height =
|
|
718
|
-
|
|
719
|
-
margins =
|
|
720
|
-
color =
|
|
721
|
-
path =
|
|
690
|
+
var LegendItem = function LegendItem(_ref5) {
|
|
691
|
+
var name = _ref5.name,
|
|
692
|
+
label = _ref5.label,
|
|
693
|
+
width = _ref5.width,
|
|
694
|
+
height = _ref5.height,
|
|
695
|
+
_ref5$margins = _ref5.margins,
|
|
696
|
+
margins = _ref5$margins === void 0 ? {} : _ref5$margins,
|
|
697
|
+
color = _ref5.color,
|
|
698
|
+
path = _ref5.path;
|
|
722
699
|
return function (g) {
|
|
723
700
|
g.attr("class", "legend-item legend-" + name.toLowerCase()).attr("data-name", name);
|
|
724
|
-
var svg = d3.select(g.node().ownerSVGElement || g);
|
|
725
701
|
g.on('click.legend', function () {
|
|
726
|
-
return
|
|
702
|
+
return d3.select(g.node().ownerSVGElement || g).dispatch("legend_clicked", {
|
|
727
703
|
detail: {
|
|
728
704
|
path: path.node(),
|
|
729
705
|
name: name,
|
|
@@ -737,34 +713,24 @@
|
|
|
737
713
|
return g;
|
|
738
714
|
};
|
|
739
715
|
};
|
|
740
|
-
var
|
|
741
|
-
var
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
var xCoord = _ref9.xCoord,
|
|
750
|
-
yCoord = _ref9.yCoord,
|
|
751
|
-
_ref9$labelX = _ref9.labelX,
|
|
752
|
-
labelX = _ref9$labelX === void 0 ? "" : _ref9$labelX,
|
|
753
|
-
_ref9$labelY = _ref9.labelY,
|
|
754
|
-
labelY = _ref9$labelY === void 0 ? "" : _ref9$labelY,
|
|
755
|
-
width = _ref9.width;
|
|
716
|
+
var Tooltip = function Tooltip(_ref6) {
|
|
717
|
+
var xCoord = _ref6.xCoord,
|
|
718
|
+
yCoord = _ref6.yCoord,
|
|
719
|
+
width = _ref6.width,
|
|
720
|
+
height = _ref6.height,
|
|
721
|
+
_ref6$labels = _ref6.labels,
|
|
722
|
+
labels = _ref6$labels === void 0 ? {} : _ref6$labels,
|
|
723
|
+
_ref6$item = _ref6.item,
|
|
724
|
+
item = _ref6$item === void 0 ? {} : _ref6$item;
|
|
756
725
|
return function (g) {
|
|
757
|
-
g.
|
|
758
|
-
var
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
var
|
|
762
|
-
|
|
763
|
-
if (!
|
|
764
|
-
if (!
|
|
765
|
-
if (!x.node()) x = text.append("svg:tspan");
|
|
766
|
-
y.text(labelY);
|
|
767
|
-
x.text(labelX); // Sets focus-label-text position to the left / right of the mouse-focus-line
|
|
726
|
+
var line = g.select('.mouse-focus-line');
|
|
727
|
+
var box = g.select('.mouse-focus-label');
|
|
728
|
+
if (!line.node()) line = g.append('svg:line');
|
|
729
|
+
if (!box.node()) box = g.append("g");
|
|
730
|
+
var rect = box.select(".mouse-focus-label-rect");
|
|
731
|
+
var text = box.select(".mouse-focus-label-text");
|
|
732
|
+
if (!rect.node()) rect = box.append("svg:rect");
|
|
733
|
+
if (!text.node()) text = box.append("svg:text"); // Sets focus-label-text position to the left / right of the mouse-focus-line
|
|
768
734
|
|
|
769
735
|
var xAlign = 0;
|
|
770
736
|
var yAlign = 0;
|
|
@@ -781,17 +747,30 @@
|
|
|
781
747
|
|
|
782
748
|
if (xCoord) xAlign = xCoord + (xCoord < width / 2 ? 10 : -bbox.width - 10);
|
|
783
749
|
if (yCoord) yAlign = Math.max(yCoord - bbox.height, L.Browser.webkit ? 0 : -Infinity);
|
|
750
|
+
line.attr('class', 'mouse-focus-line').attr('x2', xCoord).attr('y2', 0).attr('x1', xCoord).attr('y1', height);
|
|
751
|
+
box.attr('class', 'mouse-focus-label');
|
|
784
752
|
rect.attr("class", "mouse-focus-label-rect").attr("x", xAlign - 5).attr("y", yAlign - 5).attr("width", bbox.width + 10).attr("height", bbox.height + 10).attr("rx", 3).attr("ry", 3);
|
|
785
753
|
text.attr("class", "mouse-focus-label-text").style("font-weight", "700").attr("y", yAlign);
|
|
786
|
-
|
|
787
|
-
|
|
754
|
+
var label;
|
|
755
|
+
|
|
756
|
+
for (var i in labels) {
|
|
757
|
+
label = text.select(".mouse-focus-label-" + labels[i].name);
|
|
758
|
+
|
|
759
|
+
if (!label.size()) {
|
|
760
|
+
label = text.append("svg:tspan", ".mouse-focus-label-x").attr("class", "mouse-focus-label-" + labels[i].name).attr("dy", "1.5em");
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
label.text(typeof labels[i].value !== "function" ? labels[i].value : labels[i].value(item));
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
text.select('tspan').attr("dy", "1em");
|
|
788
767
|
text.selectAll('tspan').attr("x", xAlign);
|
|
789
768
|
return g;
|
|
790
769
|
};
|
|
791
770
|
};
|
|
792
|
-
var Ruler = function Ruler(
|
|
793
|
-
var height =
|
|
794
|
-
width =
|
|
771
|
+
var Ruler = function Ruler(_ref7) {
|
|
772
|
+
var height = _ref7.height,
|
|
773
|
+
width = _ref7.width;
|
|
795
774
|
return function (g) {
|
|
796
775
|
g.data([{
|
|
797
776
|
"x": 0,
|
|
@@ -838,13 +817,64 @@
|
|
|
838
817
|
return g;
|
|
839
818
|
};
|
|
840
819
|
};
|
|
841
|
-
var
|
|
842
|
-
var
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
820
|
+
var CheckPoint = function CheckPoint(_ref8) {
|
|
821
|
+
var point = _ref8.point,
|
|
822
|
+
height = _ref8.height,
|
|
823
|
+
width = _ref8.width,
|
|
824
|
+
x = _ref8.x,
|
|
825
|
+
y = _ref8.y;
|
|
826
|
+
return function (g) {
|
|
827
|
+
if (isNaN(x) || isNaN(y)) return g;
|
|
828
|
+
|
|
829
|
+
if (!point.item || !point.item.property('isConnected')) {
|
|
830
|
+
point.position = point.position || "bottom";
|
|
831
|
+
point.item = g.append('g');
|
|
832
|
+
point.item.append("svg:line").attr("y1", 0).attr("x1", 0).attr("style", "stroke: rgb(51, 51, 51); stroke-width: 0.5; stroke-dasharray: 2, 2;");
|
|
833
|
+
point.item.append("svg:circle").attr("class", " height-focus circle-lower").attr("r", 3);
|
|
834
|
+
|
|
835
|
+
if (point.label) {
|
|
836
|
+
point.item.append("svg:text").attr("dx", "4px").attr("dy", "-4px");
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
point.item.datum({
|
|
841
|
+
pos: point.position,
|
|
842
|
+
x: x,
|
|
843
|
+
y: y
|
|
844
|
+
}).attr("class", function (d) {
|
|
845
|
+
return "point " + d.pos;
|
|
846
|
+
}).attr("transform", function (d) {
|
|
847
|
+
return "translate(" + d.x + "," + d.y + ")";
|
|
848
|
+
});
|
|
849
|
+
point.item.select('line').datum({
|
|
850
|
+
y2: {
|
|
851
|
+
'top': -y,
|
|
852
|
+
'bottom': height - y
|
|
853
|
+
}[point.position],
|
|
854
|
+
x2: {
|
|
855
|
+
'left': -x,
|
|
856
|
+
'right': width - x
|
|
857
|
+
}[point.position] || 0
|
|
858
|
+
}).attr("y2", function (d) {
|
|
859
|
+
return d.y2;
|
|
860
|
+
}).attr("x2", function (d) {
|
|
861
|
+
return d.x2;
|
|
862
|
+
});
|
|
863
|
+
|
|
864
|
+
if (point.label) {
|
|
865
|
+
point.item.select('text').text(point.label);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
return g;
|
|
869
|
+
};
|
|
870
|
+
};
|
|
871
|
+
var Domain = function Domain(_ref9) {
|
|
872
|
+
var min = _ref9.min,
|
|
873
|
+
max = _ref9.max,
|
|
874
|
+
attr = _ref9.attr,
|
|
875
|
+
name = _ref9.name,
|
|
876
|
+
forceBounds = _ref9.forceBounds,
|
|
877
|
+
scale = _ref9.scale;
|
|
848
878
|
return function (data) {
|
|
849
879
|
attr = attr || name;
|
|
850
880
|
if (scale && scale.attr) attr = scale.attr;
|
|
@@ -863,19 +893,19 @@
|
|
|
863
893
|
return domain;
|
|
864
894
|
};
|
|
865
895
|
};
|
|
866
|
-
var Range = function Range(
|
|
867
|
-
var axis =
|
|
896
|
+
var Range = function Range(_ref10) {
|
|
897
|
+
var axis = _ref10.axis;
|
|
868
898
|
return function (width, height) {
|
|
869
899
|
if (axis == 'x') return [0, width];else if (axis == 'y') return [height, 0];
|
|
870
900
|
};
|
|
871
901
|
};
|
|
872
|
-
var Scale = function Scale(
|
|
873
|
-
var data =
|
|
874
|
-
attr =
|
|
875
|
-
min =
|
|
876
|
-
max =
|
|
877
|
-
forceBounds =
|
|
878
|
-
range =
|
|
902
|
+
var Scale = function Scale(_ref11) {
|
|
903
|
+
var data = _ref11.data,
|
|
904
|
+
attr = _ref11.attr,
|
|
905
|
+
min = _ref11.min,
|
|
906
|
+
max = _ref11.max,
|
|
907
|
+
forceBounds = _ref11.forceBounds,
|
|
908
|
+
range = _ref11.range;
|
|
879
909
|
return d3.scaleLinear().range(range).domain(Domain({
|
|
880
910
|
min: min,
|
|
881
911
|
max: max,
|
|
@@ -883,22 +913,22 @@
|
|
|
883
913
|
forceBounds: forceBounds
|
|
884
914
|
})(data));
|
|
885
915
|
};
|
|
886
|
-
var Bisect = function Bisect(
|
|
887
|
-
var
|
|
888
|
-
data =
|
|
889
|
-
scale =
|
|
890
|
-
x =
|
|
891
|
-
attr =
|
|
916
|
+
var Bisect = function Bisect(_ref12) {
|
|
917
|
+
var _ref12$data = _ref12.data,
|
|
918
|
+
data = _ref12$data === void 0 ? [0, 1] : _ref12$data,
|
|
919
|
+
scale = _ref12.scale,
|
|
920
|
+
x = _ref12.x,
|
|
921
|
+
attr = _ref12.attr;
|
|
892
922
|
return d3.bisector(function (d) {
|
|
893
923
|
return d[attr];
|
|
894
924
|
}).left(data, scale.invert(x));
|
|
895
925
|
};
|
|
896
|
-
var Chart = function Chart(
|
|
897
|
-
var width =
|
|
898
|
-
height =
|
|
899
|
-
|
|
900
|
-
margins =
|
|
901
|
-
ruler =
|
|
926
|
+
var Chart = function Chart(_ref13) {
|
|
927
|
+
var width = _ref13.width,
|
|
928
|
+
height = _ref13.height,
|
|
929
|
+
_ref13$margins = _ref13.margins,
|
|
930
|
+
margins = _ref13$margins === void 0 ? {} : _ref13$margins,
|
|
931
|
+
ruler = _ref13.ruler;
|
|
902
932
|
|
|
903
933
|
var _width = width - margins.left - margins.right;
|
|
904
934
|
|
|
@@ -919,31 +949,24 @@
|
|
|
919
949
|
legend: g.append('g').attr("class", "legend")
|
|
920
950
|
}; // SVG Paths
|
|
921
951
|
|
|
922
|
-
var
|
|
923
|
-
var
|
|
952
|
+
var mask = panes.area.append("svg:mask").attr("id", 'elevation-clipper').attr('fill-opacity', 1);
|
|
953
|
+
var maskRect = mask.append("svg:rect").attr('class', 'zoom').attr('fill', 'white'); // white = transparent
|
|
954
|
+
// Canvas Paths
|
|
924
955
|
|
|
925
|
-
var foreignObject = panes.area.append('svg:foreignObject');
|
|
956
|
+
var foreignObject = panes.area.append('svg:foreignObject').attr('mask', 'url(#' + mask.attr('id') + ')');
|
|
926
957
|
var canvas = foreignObject.append('xhtml:canvas').attr('class', 'canvas-plot');
|
|
927
|
-
var context = canvas.node().getContext('2d'); //
|
|
958
|
+
var context = canvas.node().getContext('2d'); // Add tooltip
|
|
928
959
|
|
|
929
|
-
|
|
930
|
-
var focusG = panes.tooltip;
|
|
931
|
-
var brushG = panes.brush;
|
|
932
|
-
focusG.append('svg:line').call(MouseFocusLine({
|
|
933
|
-
xCoord: 0,
|
|
934
|
-
height: _height
|
|
935
|
-
}));
|
|
936
|
-
focusG.append("g").call(MouseFocusLabel({
|
|
960
|
+
panes.tooltip.call(Tooltip({
|
|
937
961
|
xCoord: 0,
|
|
938
962
|
yCoord: 0,
|
|
939
963
|
height: _height,
|
|
940
964
|
width: _width,
|
|
941
|
-
|
|
942
|
-
labelY: ""
|
|
965
|
+
labels: {}
|
|
943
966
|
})); // Add the brushing
|
|
944
967
|
|
|
945
968
|
var brush = d3.brushX().on('start.cursor end.cursor brush.cursor', function () {
|
|
946
|
-
return
|
|
969
|
+
return panes.brush.select(".overlay").attr('cursor', null);
|
|
947
970
|
}); // Scales
|
|
948
971
|
|
|
949
972
|
var scale = function scale(opts) {
|
|
@@ -954,11 +977,9 @@
|
|
|
954
977
|
};
|
|
955
978
|
|
|
956
979
|
var utils = {
|
|
957
|
-
|
|
980
|
+
mask: mask,
|
|
958
981
|
canvas: canvas,
|
|
959
982
|
context: context,
|
|
960
|
-
dragG: dragG,
|
|
961
|
-
focusG: focusG,
|
|
962
983
|
brush: brush
|
|
963
984
|
};
|
|
964
985
|
var chart = {
|
|
@@ -969,12 +990,12 @@
|
|
|
969
990
|
scale: scale
|
|
970
991
|
}; // Resize
|
|
971
992
|
|
|
972
|
-
chart._resize = function (
|
|
973
|
-
var width =
|
|
974
|
-
height =
|
|
975
|
-
|
|
976
|
-
margins =
|
|
977
|
-
ruler =
|
|
993
|
+
chart._resize = function (_ref14) {
|
|
994
|
+
var width = _ref14.width,
|
|
995
|
+
height = _ref14.height,
|
|
996
|
+
_ref14$margins = _ref14.margins,
|
|
997
|
+
margins = _ref14$margins === void 0 ? {} : _ref14$margins,
|
|
998
|
+
ruler = _ref14.ruler;
|
|
978
999
|
|
|
979
1000
|
var _width = width - margins.left - margins.right;
|
|
980
1001
|
|
|
@@ -987,19 +1008,19 @@
|
|
|
987
1008
|
canvas.style("transform", "translate(" + margins.left + "px," + margins.top + "px)");
|
|
988
1009
|
}
|
|
989
1010
|
|
|
990
|
-
|
|
1011
|
+
maskRect.attr("x", 0).attr("y", 0).attr("width", _width).attr("height", _height);
|
|
991
1012
|
foreignObject.attr('width', _width).attr('height', _height);
|
|
992
1013
|
canvas.attr('width', _width).attr('height', _height);
|
|
993
1014
|
|
|
994
1015
|
if (ruler) {
|
|
995
|
-
|
|
1016
|
+
panes.ruler.call(Ruler({
|
|
996
1017
|
height: _height,
|
|
997
1018
|
width: _width
|
|
998
1019
|
}));
|
|
999
1020
|
}
|
|
1000
1021
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1022
|
+
panes.brush.call(brush.extent([[0, 0], [_width, _height]]));
|
|
1023
|
+
panes.brush.select(".overlay").attr('cursor', null);
|
|
1003
1024
|
chart._width = _width;
|
|
1004
1025
|
chart._height = _height;
|
|
1005
1026
|
chart.svg.dispatch('resize', {
|
|
@@ -1038,13 +1059,11 @@
|
|
|
1038
1059
|
Path: Path,
|
|
1039
1060
|
Axis: Axis,
|
|
1040
1061
|
Grid: Grid,
|
|
1041
|
-
|
|
1042
|
-
HeightFocusLabel: HeightFocusLabel,
|
|
1043
|
-
HeightFocusMarker: HeightFocusMarker,
|
|
1062
|
+
PositionMarker: PositionMarker,
|
|
1044
1063
|
LegendItem: LegendItem,
|
|
1045
|
-
|
|
1046
|
-
MouseFocusLabel: MouseFocusLabel,
|
|
1064
|
+
Tooltip: Tooltip,
|
|
1047
1065
|
Ruler: Ruler,
|
|
1066
|
+
CheckPoint: CheckPoint,
|
|
1048
1067
|
Domain: Domain,
|
|
1049
1068
|
Range: Range,
|
|
1050
1069
|
Scale: Scale,
|
|
@@ -1055,6 +1074,8 @@
|
|
|
1055
1074
|
var Chart$1 = L.Class.extend({
|
|
1056
1075
|
includes: L.Evented ? L.Evented.prototype : L.Mixin.Events,
|
|
1057
1076
|
initialize: function initialize(opts, control) {
|
|
1077
|
+
var _this = this;
|
|
1078
|
+
|
|
1058
1079
|
this.options = opts;
|
|
1059
1080
|
this.control = control;
|
|
1060
1081
|
this._data = []; // cache registered components
|
|
@@ -1066,7 +1087,7 @@
|
|
|
1066
1087
|
grids: {},
|
|
1067
1088
|
axes: {},
|
|
1068
1089
|
legendItems: {},
|
|
1069
|
-
|
|
1090
|
+
tooltipItems: {}
|
|
1070
1091
|
};
|
|
1071
1092
|
this._scales = {};
|
|
1072
1093
|
this._domains = {};
|
|
@@ -1074,15 +1095,6 @@
|
|
|
1074
1095
|
this._paths = {};
|
|
1075
1096
|
this._brushEnabled = opts.dragging;
|
|
1076
1097
|
this._zoomEnabled = opts.zooming;
|
|
1077
|
-
|
|
1078
|
-
if (opts.imperial) {
|
|
1079
|
-
this._xLabel = "mi";
|
|
1080
|
-
this._yLabel = "ft";
|
|
1081
|
-
} else {
|
|
1082
|
-
this._xLabel = opts.xLabel;
|
|
1083
|
-
this._yLabel = opts.yLabel;
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
1098
|
var chart = this._chart = Chart(opts); // SVG Container
|
|
1087
1099
|
|
|
1088
1100
|
var svg = this._container = chart.svg; // Panes
|
|
@@ -1091,25 +1103,31 @@
|
|
|
1091
1103
|
this._area = chart.pane('area');
|
|
1092
1104
|
this._point = chart.pane('point');
|
|
1093
1105
|
this._axis = chart.pane('axis');
|
|
1094
|
-
this._legend = chart.pane('legend');
|
|
1106
|
+
this._legend = chart.pane('legend');
|
|
1107
|
+
this._tooltip = chart.pane('tooltip');
|
|
1108
|
+
this._ruler = chart.pane('ruler'); // Scales
|
|
1095
1109
|
|
|
1096
1110
|
this._initScale(); // Helpers
|
|
1097
1111
|
|
|
1098
1112
|
|
|
1099
|
-
this.
|
|
1100
|
-
this._canvas = chart.get('canvas');
|
|
1113
|
+
this._mask = chart.get('mask');
|
|
1101
1114
|
this._context = chart.get('context');
|
|
1102
|
-
this.
|
|
1103
|
-
this._focusG = chart.get('focusG');
|
|
1104
|
-
this._brush = chart.get('brush'); // Tooltip
|
|
1105
|
-
|
|
1106
|
-
this._focusline = this._focusG.select('.mouse-focus-line');
|
|
1107
|
-
this._focuslabel = this._focusG.select('.mouse-focus-label');
|
|
1115
|
+
this._brush = chart.get('brush');
|
|
1108
1116
|
this._zoom = d3.zoom();
|
|
1109
1117
|
this._drag = d3.drag(); // Interactions
|
|
1110
1118
|
|
|
1111
1119
|
this._initInteractions(); // svg.on('resize', (e)=>console.log(e.detail));
|
|
1120
|
+
// Handle multi-track segments (BETA)
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
this._maskGaps = [];
|
|
1124
|
+
control.on('eletrack_added', function (e) {
|
|
1125
|
+
_this._maskGaps.push(e.index);
|
|
1112
1126
|
|
|
1127
|
+
control.once('eledata_updated', function (e) {
|
|
1128
|
+
return _this._maskGaps.push(e.index);
|
|
1129
|
+
});
|
|
1130
|
+
});
|
|
1113
1131
|
},
|
|
1114
1132
|
update: function update(props) {
|
|
1115
1133
|
if (props) {
|
|
@@ -1130,11 +1148,11 @@
|
|
|
1130
1148
|
return this;
|
|
1131
1149
|
},
|
|
1132
1150
|
render: function render() {
|
|
1133
|
-
var
|
|
1151
|
+
var _this2 = this;
|
|
1134
1152
|
|
|
1135
1153
|
return function (container) {
|
|
1136
1154
|
return container.append(function () {
|
|
1137
|
-
return
|
|
1155
|
+
return _this2._container.node();
|
|
1138
1156
|
});
|
|
1139
1157
|
};
|
|
1140
1158
|
},
|
|
@@ -1145,52 +1163,28 @@
|
|
|
1145
1163
|
|
|
1146
1164
|
this._area.selectAll('path').attr("d", "M0 0");
|
|
1147
1165
|
|
|
1148
|
-
this._context.clearRect(0, 0, this._width(), this._height());
|
|
1166
|
+
this._context.clearRect(0, 0, this._width(), this._height()); // if (this._path) {
|
|
1167
|
+
// this._x.domain([0, 1]);
|
|
1168
|
+
// this._y.domain([0, 1]);
|
|
1169
|
+
// }
|
|
1149
1170
|
|
|
1150
|
-
if (this._path) ;
|
|
1151
1171
|
},
|
|
1152
1172
|
_drawPath: function _drawPath(name) {
|
|
1153
|
-
var opts = this.options;
|
|
1154
|
-
var ctx = this._context;
|
|
1155
1173
|
var path = this._paths[name];
|
|
1156
1174
|
var area = this._props.areas[name];
|
|
1157
|
-
|
|
1158
|
-
var scaleX = this._scales[area.scaleX];
|
|
1159
|
-
var scaleY = this._scales[area.scaleY];
|
|
1160
|
-
area = L.extend({}, area, {
|
|
1175
|
+
path.datum(this._data).attr("d", Area(L.extend({}, area, {
|
|
1161
1176
|
width: this._width(),
|
|
1162
1177
|
height: this._height(),
|
|
1163
|
-
scaleX: scaleX,
|
|
1164
|
-
scaleY: scaleY
|
|
1165
|
-
});
|
|
1166
|
-
|
|
1167
|
-
if (!scaleY || !scaleY) {
|
|
1168
|
-
return console.warn('Unable to render path:' + name);
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
path.datum(this._data).attr("d", Area(area));
|
|
1178
|
+
scaleX: this._scales[area.scaleX],
|
|
1179
|
+
scaleY: this._scales[area.scaleY]
|
|
1180
|
+
})));
|
|
1172
1181
|
if (path.classed('leaflet-hidden')) return;
|
|
1173
1182
|
|
|
1174
|
-
if (
|
|
1175
|
-
|
|
1176
|
-
ctx.beginPath();
|
|
1177
|
-
ctx.moveTo(0, 0);
|
|
1178
|
-
var p = new Path2D(path.attr('d'));
|
|
1179
|
-
ctx.strokeStyle = path.attr('stroke');
|
|
1180
|
-
ctx.fillStyle = path.attr('fill');
|
|
1181
|
-
ctx.lineWidth = 1.25;
|
|
1182
|
-
ctx.globalCompositeOperation = 'source-over'; // stroke opacity
|
|
1183
|
-
|
|
1184
|
-
ctx.globalAlpha = path.attr('stroke-opacity') || 0.3;
|
|
1185
|
-
ctx.stroke(p); // fill opacity
|
|
1186
|
-
|
|
1187
|
-
ctx.globalAlpha = path.attr('fill-opacity') || 0.45;
|
|
1188
|
-
ctx.fill(p);
|
|
1189
|
-
ctx.globalAlpha = 1;
|
|
1190
|
-
ctx.closePath();
|
|
1183
|
+
if (this.options.preferCanvas) {
|
|
1184
|
+
drawCanvas(this._context, path);
|
|
1191
1185
|
} else {
|
|
1192
1186
|
this._area.append(function () {
|
|
1193
|
-
return node;
|
|
1187
|
+
return path.node();
|
|
1194
1188
|
});
|
|
1195
1189
|
}
|
|
1196
1190
|
},
|
|
@@ -1210,43 +1204,43 @@
|
|
|
1210
1204
|
* Initialize "d3-brush".
|
|
1211
1205
|
*/
|
|
1212
1206
|
_initBrush: function _initBrush(e) {
|
|
1213
|
-
var
|
|
1207
|
+
var _this3 = this;
|
|
1214
1208
|
|
|
1215
1209
|
var brush = function brush(e) {
|
|
1216
|
-
if (!
|
|
1210
|
+
if (!_this3._data.length) return;
|
|
1217
1211
|
var extent = e.selection;
|
|
1218
1212
|
|
|
1219
1213
|
if (extent) {
|
|
1220
|
-
var start =
|
|
1214
|
+
var start = _this3._findIndexForXCoord(extent[0]);
|
|
1221
1215
|
|
|
1222
|
-
var end =
|
|
1216
|
+
var end = _this3._findIndexForXCoord(extent[1]);
|
|
1223
1217
|
|
|
1224
|
-
|
|
1225
|
-
dragstart:
|
|
1226
|
-
dragend:
|
|
1218
|
+
_this3.fire('dragged', {
|
|
1219
|
+
dragstart: _this3._data[start],
|
|
1220
|
+
dragend: _this3._data[end]
|
|
1227
1221
|
});
|
|
1228
1222
|
}
|
|
1229
1223
|
};
|
|
1230
1224
|
|
|
1231
1225
|
var focus = function focus(e) {
|
|
1232
|
-
if (!
|
|
1226
|
+
if (!_this3._data.length) return;
|
|
1233
1227
|
if (e.type == 'brush' && !e.sourceEvent) return;
|
|
1234
1228
|
|
|
1235
|
-
var rect =
|
|
1229
|
+
var rect = _this3._chart.panes.brush.select('.overlay').node();
|
|
1236
1230
|
|
|
1237
1231
|
var coords = d3.pointers(e, rect)[0];
|
|
1238
1232
|
var xCoord = coords[0];
|
|
1239
1233
|
|
|
1240
|
-
var item =
|
|
1234
|
+
var item = _this3._data[_this3._findIndexForXCoord(xCoord)];
|
|
1241
1235
|
|
|
1242
|
-
|
|
1236
|
+
_this3.fire("mouse_move", {
|
|
1243
1237
|
item: item,
|
|
1244
1238
|
xCoord: xCoord
|
|
1245
1239
|
});
|
|
1246
1240
|
};
|
|
1247
1241
|
|
|
1248
1242
|
this._brush.filter(function (e) {
|
|
1249
|
-
return
|
|
1243
|
+
return _this3._brushEnabled && !e.shiftKey && !e.button;
|
|
1250
1244
|
}).on("end.update", brush).on("brush.update", focus);
|
|
1251
1245
|
|
|
1252
1246
|
this._chart.panes.brush.on("mouseenter.focus touchstart.focus", this.fire.bind(this, "mouse_enter")).on("mouseout.focus touchend.focus", this.fire.bind(this, "mouse_out")).on("mousemove.focus touchmove.focus", focus);
|
|
@@ -1256,7 +1250,7 @@
|
|
|
1256
1250
|
* Initialize "d3-zoom"
|
|
1257
1251
|
*/
|
|
1258
1252
|
_initClipper: function _initClipper() {
|
|
1259
|
-
var
|
|
1253
|
+
var _this4 = this;
|
|
1260
1254
|
|
|
1261
1255
|
var svg = this._container;
|
|
1262
1256
|
var margin = this.options.margins;
|
|
@@ -1266,42 +1260,52 @@
|
|
|
1266
1260
|
if (e.sourceEvent && e.sourceEvent.type == "mousedown") svg.style('cursor', 'grabbing');
|
|
1267
1261
|
|
|
1268
1262
|
if (e.transform.k == 1 && e.transform.x == 0) {
|
|
1269
|
-
|
|
1263
|
+
_this4._container.classed('zoomed', true); // Apply d3-zoom (bind <clipPath> mask)
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
if (_this4._mask) {
|
|
1267
|
+
_this4._point.attr('mask', 'url(#' + _this4._mask.attr('id') + ')');
|
|
1268
|
+
}
|
|
1270
1269
|
}
|
|
1271
1270
|
|
|
1272
|
-
|
|
1271
|
+
_this4.zooming = true;
|
|
1273
1272
|
};
|
|
1274
1273
|
|
|
1275
1274
|
var onEnd = function onEnd(e) {
|
|
1276
1275
|
if (e.transform.k == 1 && e.transform.x == 0) {
|
|
1277
|
-
|
|
1276
|
+
_this4._container.classed('zoomed', false); // Apply d3-zoom (bind <clipPath> mask)
|
|
1277
|
+
|
|
1278
|
+
|
|
1279
|
+
if (_this4._mask) {
|
|
1280
|
+
_this4._point.attr('mask', null);
|
|
1281
|
+
}
|
|
1278
1282
|
}
|
|
1279
1283
|
|
|
1280
|
-
|
|
1284
|
+
_this4.zooming = false;
|
|
1281
1285
|
svg.style('cursor', '');
|
|
1282
1286
|
};
|
|
1283
1287
|
|
|
1284
1288
|
var onZoom = function onZoom(e) {
|
|
1285
1289
|
// TODO: find a faster way to redraw the chart.
|
|
1286
|
-
|
|
1290
|
+
_this4.zooming = false;
|
|
1287
1291
|
|
|
1288
|
-
|
|
1292
|
+
_this4._updateScale(); // hacky way for restoring x scale when zooming out
|
|
1289
1293
|
|
|
1290
1294
|
|
|
1291
|
-
|
|
1292
|
-
|
|
1295
|
+
_this4.zooming = true;
|
|
1296
|
+
_this4._scales.distance = _this4._x = e.transform.rescaleX(_this4._x); // calculate x scale at zoom level
|
|
1293
1297
|
|
|
1294
|
-
|
|
1298
|
+
_this4._resetDrag();
|
|
1295
1299
|
|
|
1296
1300
|
if (e.sourceEvent && e.sourceEvent.type == "mousemove") {
|
|
1297
|
-
|
|
1301
|
+
_this4._hideDiagramIndicator();
|
|
1298
1302
|
}
|
|
1299
1303
|
|
|
1300
|
-
|
|
1304
|
+
_this4.fire('zoom');
|
|
1301
1305
|
};
|
|
1302
1306
|
|
|
1303
1307
|
zoom.scaleExtent([1, 10]).extent([[margin.left, 0], [this._width() - margin.right, this._height()]]).translateExtent([[margin.left, -Infinity], [this._width() - margin.right, Infinity]]).filter(function (e) {
|
|
1304
|
-
return
|
|
1308
|
+
return _this4._zoomEnabled && (e.shiftKey || e.buttons == 4);
|
|
1305
1309
|
}).on("start", onStart).on("end", onEnd).on("zoom", onZoom);
|
|
1306
1310
|
svg.call(zoom); // add zoom functionality to "svg" group
|
|
1307
1311
|
// d3.select("body").on("keydown.grabzoom keyup.grabzoom", (e) => svg.style('cursor', e.shiftKey ? 'move' : ''));
|
|
@@ -1320,7 +1324,7 @@
|
|
|
1320
1324
|
* Toggle chart data on legend click
|
|
1321
1325
|
*/
|
|
1322
1326
|
_initLegend: function _initLegend() {
|
|
1323
|
-
var
|
|
1327
|
+
var _this5 = this;
|
|
1324
1328
|
|
|
1325
1329
|
this._container.on('legend_clicked', function (e) {
|
|
1326
1330
|
var _e$detail = e.detail,
|
|
@@ -1340,9 +1344,9 @@
|
|
|
1340
1344
|
|
|
1341
1345
|
toggleClass(path, 'leaflet-hidden', enabled);
|
|
1342
1346
|
|
|
1343
|
-
|
|
1347
|
+
_this5._updateArea();
|
|
1344
1348
|
|
|
1345
|
-
|
|
1349
|
+
_this5.fire("elepath_toggle", {
|
|
1346
1350
|
path: path,
|
|
1347
1351
|
name: name,
|
|
1348
1352
|
legend: legend,
|
|
@@ -1355,7 +1359,7 @@
|
|
|
1355
1359
|
* Initialize "ruler".
|
|
1356
1360
|
*/
|
|
1357
1361
|
_initRuler: function _initRuler() {
|
|
1358
|
-
var
|
|
1362
|
+
var _this6 = this;
|
|
1359
1363
|
|
|
1360
1364
|
if (!this.options.ruler) return; // const yMax = this._height();
|
|
1361
1365
|
|
|
@@ -1363,41 +1367,41 @@
|
|
|
1363
1367
|
var drag = this._drag;
|
|
1364
1368
|
|
|
1365
1369
|
var label = function label(e, d) {
|
|
1366
|
-
var yMax =
|
|
1370
|
+
var yMax = _this6._height();
|
|
1367
1371
|
|
|
1368
|
-
var y =
|
|
1372
|
+
var y = _this6._ruler.data()[0].y;
|
|
1369
1373
|
|
|
1370
|
-
if (y >= yMax || y <= 0)
|
|
1374
|
+
if (y >= yMax || y <= 0) _this6._ruler.select(".horizontal-drag-label").text('');
|
|
1371
1375
|
|
|
1372
|
-
|
|
1376
|
+
_this6._hideDiagramIndicator();
|
|
1373
1377
|
};
|
|
1374
1378
|
|
|
1375
1379
|
var position = function position(e, d) {
|
|
1376
|
-
var yMax =
|
|
1380
|
+
var yMax = _this6._height();
|
|
1377
1381
|
|
|
1378
|
-
var yCoord = d3.pointers(e,
|
|
1382
|
+
var yCoord = d3.pointers(e, _this6._area.node())[0][1];
|
|
1379
1383
|
var y = yCoord > 0 ? yCoord < yMax ? yCoord : yMax : 0;
|
|
1380
1384
|
|
|
1381
|
-
var z =
|
|
1385
|
+
var z = _this6._y.invert(y);
|
|
1382
1386
|
|
|
1383
|
-
var data = L.extend(
|
|
1387
|
+
var data = L.extend(_this6._ruler.data()[0], {
|
|
1384
1388
|
y: y
|
|
1385
1389
|
});
|
|
1386
1390
|
|
|
1387
|
-
|
|
1391
|
+
_this6._ruler.data([data]).attr("transform", function (d) {
|
|
1388
1392
|
return "translate(" + d.x + "," + d.y + ")";
|
|
1389
1393
|
}).classed('active', y < yMax);
|
|
1390
1394
|
|
|
1391
|
-
|
|
1395
|
+
_this6._container.select(".horizontal-drag-label").text(formatNum(z) + " " + (_this6.options.imperial ? 'ft' : 'm'));
|
|
1392
1396
|
|
|
1393
|
-
|
|
1394
|
-
coords: yCoord < yMax && yCoord > 0 ?
|
|
1397
|
+
_this6.fire('ruler_filter', {
|
|
1398
|
+
coords: yCoord < yMax && yCoord > 0 ? _this6._findCoordsForY(yCoord) : []
|
|
1395
1399
|
});
|
|
1396
1400
|
};
|
|
1397
1401
|
|
|
1398
1402
|
drag.on("start end", label).on("drag", position);
|
|
1399
1403
|
|
|
1400
|
-
this.
|
|
1404
|
+
this._ruler.call(drag);
|
|
1401
1405
|
},
|
|
1402
1406
|
|
|
1403
1407
|
/**
|
|
@@ -1476,7 +1480,7 @@
|
|
|
1476
1480
|
},
|
|
1477
1481
|
|
|
1478
1482
|
/**
|
|
1479
|
-
* Add a
|
|
1483
|
+
* Add a point of interest over the chart
|
|
1480
1484
|
*/
|
|
1481
1485
|
_registerCheckPoint: function _registerCheckPoint(point) {
|
|
1482
1486
|
if (!this._data.length) return;
|
|
@@ -1490,49 +1494,18 @@
|
|
|
1490
1494
|
x = this._x(point.dist);
|
|
1491
1495
|
item = this._data[this._findIndexForXCoord(x)];
|
|
1492
1496
|
y = this._y(item.z);
|
|
1493
|
-
} else if (isNaN(x) || isNaN(y)) return;
|
|
1494
|
-
|
|
1495
|
-
if (!point.item || !point.item.property('isConnected')) {
|
|
1496
|
-
point.position = point.position || "bottom";
|
|
1497
|
-
point.item = this._point.append('g');
|
|
1498
|
-
point.item.append("svg:line").attr("y1", 0).attr("x1", 0).attr("style", "stroke: rgb(51, 51, 51); stroke-width: 0.5; stroke-dasharray: 2, 2;");
|
|
1499
|
-
point.item.append("svg:circle").attr("class", " height-focus circle-lower").attr("r", 3);
|
|
1500
|
-
|
|
1501
|
-
if (point.label) {
|
|
1502
|
-
point.item.append("svg:text").attr("dx", "4px").attr("dy", "-4px");
|
|
1503
|
-
}
|
|
1504
1497
|
}
|
|
1505
1498
|
|
|
1506
|
-
|
|
1507
|
-
|
|
1499
|
+
this._point.call(CheckPoint({
|
|
1500
|
+
point: point,
|
|
1501
|
+
width: this._width(),
|
|
1502
|
+
height: this._height(),
|
|
1508
1503
|
x: x,
|
|
1509
1504
|
y: y
|
|
1510
|
-
})
|
|
1511
|
-
return "point " + d.pos;
|
|
1512
|
-
}).attr("transform", function (d) {
|
|
1513
|
-
return "translate(" + d.x + "," + d.y + ")";
|
|
1514
|
-
});
|
|
1515
|
-
point.item.select('line').datum({
|
|
1516
|
-
y2: {
|
|
1517
|
-
'top': -y,
|
|
1518
|
-
'bottom': this._height() - y
|
|
1519
|
-
}[point.position],
|
|
1520
|
-
x2: {
|
|
1521
|
-
'left': -x,
|
|
1522
|
-
'right': this._width() - x
|
|
1523
|
-
}[point.position] || 0
|
|
1524
|
-
}).attr("y2", function (d) {
|
|
1525
|
-
return d.y2;
|
|
1526
|
-
}).attr("x2", function (d) {
|
|
1527
|
-
return d.x2;
|
|
1528
|
-
});
|
|
1529
|
-
|
|
1530
|
-
if (point.label) {
|
|
1531
|
-
point.item.select('text').text(point.label);
|
|
1532
|
-
}
|
|
1505
|
+
}));
|
|
1533
1506
|
},
|
|
1534
|
-
|
|
1535
|
-
this._props.
|
|
1507
|
+
_registerTooltip: function _registerTooltip(props) {
|
|
1508
|
+
this._props.tooltipItems[props.name] = props;
|
|
1536
1509
|
},
|
|
1537
1510
|
_updateArea: function _updateArea() {
|
|
1538
1511
|
var paths = this._paths; // Reset and update chart profiles
|
|
@@ -1595,14 +1568,32 @@
|
|
|
1595
1568
|
});
|
|
1596
1569
|
},
|
|
1597
1570
|
_updateClipper: function _updateClipper() {
|
|
1571
|
+
var _this7 = this;
|
|
1572
|
+
|
|
1598
1573
|
var margin = this.options.margins;
|
|
1599
1574
|
|
|
1600
|
-
this._zoom.scaleExtent([1, 10]).extent([[margin.left, 0], [this._width() - margin.right, this._height()]]).translateExtent([[margin.left, -Infinity], [this._width() - margin.right, Infinity]]);
|
|
1575
|
+
this._zoom.scaleExtent([1, 10]).extent([[margin.left, 0], [this._width() - margin.right, this._height()]]).translateExtent([[margin.left, -Infinity], [this._width() - margin.right, Infinity]]); // Apply svg mask on multi-track segments (BETA)
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
this._mask.selectAll(".gap").remove();
|
|
1579
|
+
|
|
1580
|
+
this._maskGaps.forEach(function (d, i) {
|
|
1581
|
+
if (i >= _this7._maskGaps.length - 2) return;
|
|
1582
|
+
var d1 = _this7._data[_this7._maskGaps[i]];
|
|
1583
|
+
var d2 = _this7._data[_this7._maskGaps[i + 1]];
|
|
1584
|
+
|
|
1585
|
+
var x1 = _this7._x(_this7._data[_this7._findIndexForLatLng(d1.latlng)].dist);
|
|
1586
|
+
|
|
1587
|
+
var x2 = _this7._x(_this7._data[_this7._findIndexForLatLng(d2.latlng)].dist);
|
|
1588
|
+
|
|
1589
|
+
_this7._mask.append("rect").attr("x", x1).attr("y", 0).attr("width", x2 - x1).attr("height", _this7._height()).attr('class', 'gap').attr('fill-opacity', '0.8').attr("fill", 'black'); // black = hide
|
|
1590
|
+
|
|
1591
|
+
});
|
|
1601
1592
|
},
|
|
1602
1593
|
_updateLegend: function _updateLegend() {
|
|
1603
|
-
var
|
|
1594
|
+
var _this8 = this;
|
|
1604
1595
|
|
|
1605
|
-
if (this.options.legend
|
|
1596
|
+
if (this.options.legend === false) return;
|
|
1606
1597
|
var legends = this._props.legendItems;
|
|
1607
1598
|
var legend; // Reset legend items
|
|
1608
1599
|
|
|
@@ -1656,21 +1647,21 @@
|
|
|
1656
1647
|
var legend = d3.select(n[i]);
|
|
1657
1648
|
var rect = legend.select('rect');
|
|
1658
1649
|
var name = legend.attr('data-name');
|
|
1659
|
-
var path =
|
|
1650
|
+
var path = _this8._paths[name];
|
|
1660
1651
|
var tx = v[i] * 55;
|
|
1661
1652
|
var ty = xAxesB * 2;
|
|
1662
1653
|
legend // Adjust legend item positions
|
|
1663
1654
|
.attr("transform", "translate(" + tx + ", " + ty + ")"); // Set initial state (disabled controls)
|
|
1664
1655
|
|
|
1665
|
-
if (name in
|
|
1656
|
+
if (name in _this8.options && _this8.options[name] == 'disabled') {
|
|
1666
1657
|
path.classed('leaflet-hidden', true);
|
|
1667
1658
|
legend.select('text').style('text-decoration-line', 'line-through');
|
|
1668
1659
|
legend.select('rect').style('fill-opacity', '0');
|
|
1669
1660
|
} // Apply d3-zoom (bind <clipPath> mask)
|
|
1670
1661
|
|
|
1671
1662
|
|
|
1672
|
-
if (
|
|
1673
|
-
path.attr('
|
|
1663
|
+
if (_this8._mask) {
|
|
1664
|
+
path.attr('mask', 'url(#' + _this8._mask.attr('id') + ')');
|
|
1674
1665
|
}
|
|
1675
1666
|
});
|
|
1676
1667
|
},
|
|
@@ -1679,13 +1670,9 @@
|
|
|
1679
1670
|
x: this._x,
|
|
1680
1671
|
y: this._y
|
|
1681
1672
|
};
|
|
1682
|
-
var opts = this.options;
|
|
1683
|
-
var scales = this._scales;
|
|
1684
|
-
var d = this._domains;
|
|
1685
|
-
var r = this._ranges;
|
|
1686
1673
|
|
|
1687
|
-
for (var i in
|
|
1688
|
-
|
|
1674
|
+
for (var i in this._scales) {
|
|
1675
|
+
this._scales[i].domain(this._domains[i](this._data)).range(this._ranges[i](this._width(), this._height()));
|
|
1689
1676
|
}
|
|
1690
1677
|
|
|
1691
1678
|
return {
|
|
@@ -1743,10 +1730,10 @@
|
|
|
1743
1730
|
* Finds a data entry for a given x-coordinate of the diagram
|
|
1744
1731
|
*/
|
|
1745
1732
|
_findIndexForXCoord: function _findIndexForXCoord(x) {
|
|
1746
|
-
var
|
|
1733
|
+
var _this9 = this;
|
|
1747
1734
|
|
|
1748
1735
|
return d3.bisector(function (d) {
|
|
1749
|
-
return d[
|
|
1736
|
+
return d[_this9.options.xAttr];
|
|
1750
1737
|
}).left(this._data || [0, 1], this._x.invert(x));
|
|
1751
1738
|
},
|
|
1752
1739
|
|
|
@@ -1791,47 +1778,17 @@
|
|
|
1791
1778
|
* Display distance and altitude level ("focus-rect").
|
|
1792
1779
|
*/
|
|
1793
1780
|
_showDiagramIndicator: function _showDiagramIndicator(item, xCoordinate) {
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
var yCoordinate = this._y(item[opts.yAttr]);
|
|
1797
|
-
|
|
1798
|
-
this._focusG.attr("display", null);
|
|
1799
|
-
|
|
1800
|
-
this._focusline.call(MouseFocusLine({
|
|
1801
|
-
xCoord: xCoordinate,
|
|
1802
|
-
height: this._height()
|
|
1803
|
-
}));
|
|
1804
|
-
|
|
1805
|
-
this._focuslabel.call(MouseFocusLabel({
|
|
1781
|
+
this._tooltip.attr("display", null).call(Tooltip({
|
|
1806
1782
|
xCoord: xCoordinate,
|
|
1807
|
-
yCoord:
|
|
1783
|
+
yCoord: this._y(item[this.options.yAttr]),
|
|
1808
1784
|
height: this._height(),
|
|
1809
1785
|
width: this._width(),
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
}));
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
var labels = this._props.focusLabels;
|
|
1816
|
-
|
|
1817
|
-
var tooltip = this._focuslabel.select('text');
|
|
1818
|
-
|
|
1819
|
-
var label;
|
|
1820
|
-
|
|
1821
|
-
for (var i in labels) {
|
|
1822
|
-
label = tooltip.select(".mouse-focus-label-" + labels[i].name);
|
|
1823
|
-
|
|
1824
|
-
if (!label.size()) {
|
|
1825
|
-
label = tooltip.append("svg:tspan", ".mouse-focus-label-x").attr("class", "mouse-focus-label-" + labels[i].name).attr("dy", "1.5em");
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
label.text(typeof labels[i].value !== "function" ? labels[i].value : labels[i].value(item));
|
|
1829
|
-
|
|
1830
|
-
this._focuslabel.select('.mouse-focus-label-x').attr("dy", "1.5em");
|
|
1831
|
-
}
|
|
1786
|
+
labels: this._props.tooltipItems,
|
|
1787
|
+
item: item
|
|
1788
|
+
}));
|
|
1832
1789
|
},
|
|
1833
1790
|
_hideDiagramIndicator: function _hideDiagramIndicator() {
|
|
1834
|
-
this.
|
|
1791
|
+
this._tooltip.attr("display", 'none');
|
|
1835
1792
|
}
|
|
1836
1793
|
});
|
|
1837
1794
|
|
|
@@ -1839,51 +1796,40 @@
|
|
|
1839
1796
|
initialize: function initialize(options) {
|
|
1840
1797
|
this.options = options;
|
|
1841
1798
|
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
// this._marker = L.circleMarker([0, 0], { pane: 'overlayPane', radius: 6, fillColor: '#fff', fillOpacity:1, color: '#000', weight:1, interactive: false });
|
|
1857
|
-
this._marker = L.marker([0, 0], {
|
|
1858
|
-
icon: this.options.markerIcon,
|
|
1859
|
-
zIndexOffset: 1000000,
|
|
1860
|
-
interactive: false
|
|
1861
|
-
});
|
|
1799
|
+
switch (this.options.marker) {
|
|
1800
|
+
case 'elevation-line':
|
|
1801
|
+
// this._container = d3.create("g").attr("class", "height-focus-group");
|
|
1802
|
+
this._container = d3.select(map.getPane('elevationPane')).select("svg > g").attr("class", "height-focus-group");
|
|
1803
|
+
break;
|
|
1804
|
+
|
|
1805
|
+
case 'position-marker':
|
|
1806
|
+
// this._marker = L.circleMarker([0, 0], { pane: 'overlayPane', radius: 6, fillColor: '#fff', fillOpacity:1, color: '#000', weight:1, interactive: false });
|
|
1807
|
+
this._marker = L.marker([0, 0], {
|
|
1808
|
+
icon: this.options.markerIcon,
|
|
1809
|
+
zIndexOffset: 1000000,
|
|
1810
|
+
interactive: false
|
|
1811
|
+
});
|
|
1812
|
+
break;
|
|
1862
1813
|
}
|
|
1863
1814
|
|
|
1864
|
-
this.
|
|
1815
|
+
this._labels = {};
|
|
1865
1816
|
return this;
|
|
1866
1817
|
},
|
|
1867
1818
|
addTo: function addTo(map) {
|
|
1868
|
-
var _this = this;
|
|
1869
|
-
|
|
1870
1819
|
this._map = map;
|
|
1871
1820
|
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
this._marker.addTo(map, {
|
|
1885
|
-
pane: 'overlayPane'
|
|
1886
|
-
});
|
|
1821
|
+
switch (this.options.marker) {
|
|
1822
|
+
case 'elevation-line':
|
|
1823
|
+
this._container.call(PositionMarker({}));
|
|
1824
|
+
|
|
1825
|
+
break;
|
|
1826
|
+
|
|
1827
|
+
case 'position-marker':
|
|
1828
|
+
this._marker.addTo(map, {
|
|
1829
|
+
pane: 'overlayPane'
|
|
1830
|
+
});
|
|
1831
|
+
|
|
1832
|
+
break;
|
|
1887
1833
|
}
|
|
1888
1834
|
|
|
1889
1835
|
return this;
|
|
@@ -1897,62 +1843,34 @@
|
|
|
1897
1843
|
if (!props) return;
|
|
1898
1844
|
if (props.options) this.options = props.options;
|
|
1899
1845
|
if (!this._map) this.addTo(props.map);
|
|
1900
|
-
var opts = this.options;
|
|
1901
|
-
var map = this._map;
|
|
1902
1846
|
this._latlng = props.item.latlng;
|
|
1903
|
-
var pos = map.latLngToLayerPoint(this._latlng);
|
|
1904
|
-
|
|
1905
|
-
if (map._rotate) {
|
|
1906
|
-
pos = map.rotatedPointToMapPanePoint(pos);
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
var point = L.extend({}, props.item, pos);
|
|
1910
|
-
|
|
1911
|
-
if (this.options.marker == 'elevation-line') {
|
|
1912
|
-
var normalizedAlt = this._height() / props.maxElevation * point.z;
|
|
1913
|
-
var normalizedY = point.y - normalizedAlt;
|
|
1914
|
-
|
|
1915
|
-
this._container.classed("leaflet-hidden", false);
|
|
1916
1847
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
yCoord: point.y
|
|
1921
|
-
}));
|
|
1922
|
-
|
|
1923
|
-
this._focusline.call(HeightFocusLine({
|
|
1924
|
-
theme: opts.theme,
|
|
1925
|
-
xCoord: point.x,
|
|
1926
|
-
yCoord: point.y,
|
|
1927
|
-
length: normalizedY
|
|
1928
|
-
}));
|
|
1848
|
+
switch (this.options.marker) {
|
|
1849
|
+
case 'elevation-line':
|
|
1850
|
+
var point = this._map.latLngToLayerPoint(this._latlng);
|
|
1929
1851
|
|
|
1930
|
-
|
|
1931
|
-
theme: opts.theme,
|
|
1932
|
-
xCoord: point.x,
|
|
1933
|
-
yCoord: normalizedY,
|
|
1934
|
-
label: d3.format("." + opts.decimalsY + "f")(point[opts.yAttr]) + " " + this._yLabel
|
|
1935
|
-
}));
|
|
1852
|
+
point = L.extend({}, props.item, this._map._rotate ? this._map.rotatedPointToMapPanePoint(point) : point);
|
|
1936
1853
|
|
|
1937
|
-
|
|
1938
|
-
var tooltip = this._focuslabel;
|
|
1939
|
-
var label;
|
|
1854
|
+
this._container.classed("leaflet-hidden", false);
|
|
1940
1855
|
|
|
1941
|
-
|
|
1942
|
-
|
|
1856
|
+
this._container.call(PositionMarker({
|
|
1857
|
+
theme: this.options.theme,
|
|
1858
|
+
xCoord: point.x,
|
|
1859
|
+
yCoord: point.y,
|
|
1860
|
+
length: point.y - this._height() / props.maxElevation * point.z,
|
|
1861
|
+
// normalized Y
|
|
1862
|
+
labels: this._labels,
|
|
1863
|
+
item: point
|
|
1864
|
+
}));
|
|
1943
1865
|
|
|
1944
|
-
|
|
1945
|
-
label = tooltip.append("svg:tspan").attr("class", "height-focus-" + labels[i].name).attr("dy", "1.5em");
|
|
1946
|
-
}
|
|
1866
|
+
break;
|
|
1947
1867
|
|
|
1948
|
-
|
|
1868
|
+
case 'position-marker':
|
|
1869
|
+
removeClass(this._marker.getElement(), 'leaflet-hidden');
|
|
1949
1870
|
|
|
1950
|
-
this.
|
|
1951
|
-
}
|
|
1952
|
-
} else if (this.options.marker == 'position-marker') {
|
|
1953
|
-
removeClass(this._marker.getElement(), 'leaflet-hidden');
|
|
1871
|
+
this._marker.setLatLng(this._latlng);
|
|
1954
1872
|
|
|
1955
|
-
|
|
1873
|
+
break;
|
|
1956
1874
|
}
|
|
1957
1875
|
},
|
|
1958
1876
|
|
|
@@ -1962,10 +1880,15 @@
|
|
|
1962
1880
|
remove: function remove() {
|
|
1963
1881
|
this._props = null;
|
|
1964
1882
|
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1883
|
+
switch (this.options.marker) {
|
|
1884
|
+
case 'elevation-line':
|
|
1885
|
+
this._container && this._container.classed("leaflet-hidden", true);
|
|
1886
|
+
break;
|
|
1887
|
+
|
|
1888
|
+
case 'position-marker':
|
|
1889
|
+
addClass(this._marker.getElement(), 'leaflet-hidden');
|
|
1890
|
+
|
|
1891
|
+
break;
|
|
1969
1892
|
}
|
|
1970
1893
|
},
|
|
1971
1894
|
getLatLng: function getLatLng() {
|
|
@@ -1979,8 +1902,8 @@
|
|
|
1979
1902
|
var opts = this.options;
|
|
1980
1903
|
return opts.height - opts.margins.top - opts.margins.bottom;
|
|
1981
1904
|
},
|
|
1982
|
-
|
|
1983
|
-
this.
|
|
1905
|
+
_registerTooltip: function _registerTooltip(props) {
|
|
1906
|
+
this._labels[props.name] = props;
|
|
1984
1907
|
}
|
|
1985
1908
|
});
|
|
1986
1909
|
|
|
@@ -2025,7 +1948,6 @@
|
|
|
2025
1948
|
collapsed: false,
|
|
2026
1949
|
detached: true,
|
|
2027
1950
|
distance: true,
|
|
2028
|
-
distanceFactor: 1,
|
|
2029
1951
|
distanceMarkers: false,
|
|
2030
1952
|
decimalsX: 2,
|
|
2031
1953
|
decimalsY: 0,
|
|
@@ -2035,15 +1957,10 @@
|
|
|
2035
1957
|
followMarker: true,
|
|
2036
1958
|
forceAxisBounds: false,
|
|
2037
1959
|
height: 200,
|
|
2038
|
-
heightFactor: 1,
|
|
2039
1960
|
imperial: false,
|
|
2040
1961
|
interpolation: "curveLinear",
|
|
2041
1962
|
lazyLoadJS: true,
|
|
2042
1963
|
legend: true,
|
|
2043
|
-
loadData: {
|
|
2044
|
-
defer: false,
|
|
2045
|
-
lazy: false
|
|
2046
|
-
},
|
|
2047
1964
|
margins: {
|
|
2048
1965
|
top: 30,
|
|
2049
1966
|
right: 30,
|
|
@@ -2057,7 +1974,6 @@
|
|
|
2057
1974
|
iconSize: [32, 32],
|
|
2058
1975
|
iconAnchor: [16, 16]
|
|
2059
1976
|
}),
|
|
2060
|
-
placeholder: false,
|
|
2061
1977
|
position: "topright",
|
|
2062
1978
|
polyline: {
|
|
2063
1979
|
className: 'elevation-polyline',
|
|
@@ -2076,7 +1992,6 @@
|
|
|
2076
1992
|
ruler: true,
|
|
2077
1993
|
skipNullZCoords: false,
|
|
2078
1994
|
theme: "lightblue-theme",
|
|
2079
|
-
responsive: true,
|
|
2080
1995
|
summary: 'inline',
|
|
2081
1996
|
slope: false,
|
|
2082
1997
|
speed: false,
|
|
@@ -2084,6 +1999,7 @@
|
|
|
2084
1999
|
time: false,
|
|
2085
2000
|
timeFactor: 3600,
|
|
2086
2001
|
timeFormat: false,
|
|
2002
|
+
timestamps: false,
|
|
2087
2003
|
sDeltaMax: undefined,
|
|
2088
2004
|
sInterpolation: "curveStepAfter",
|
|
2089
2005
|
sRange: undefined,
|
|
@@ -2127,11 +2043,11 @@
|
|
|
2127
2043
|
addData: function addData(d, layer) {
|
|
2128
2044
|
var _this = this;
|
|
2129
2045
|
|
|
2130
|
-
|
|
2131
|
-
layer
|
|
2132
|
-
|
|
2046
|
+
this.lazyLoad(this.__D3).then(function () {
|
|
2047
|
+
if (typeof layer === "undefined" && d.on) {
|
|
2048
|
+
layer = d;
|
|
2049
|
+
}
|
|
2133
2050
|
|
|
2134
|
-
Elevation._d3LazyLoader = lazyLoader(this.__D3, (typeof d3 === "undefined" ? "undefined" : _typeof(d3)) !== 'object' || !this.options.lazyLoadJS, Elevation._d3LazyLoader).then(function () {
|
|
2135
2051
|
_this._addData(d);
|
|
2136
2052
|
|
|
2137
2053
|
_this._addLayer(layer);
|
|
@@ -2226,20 +2142,6 @@
|
|
|
2226
2142
|
this._chart._brushEnabled = true;
|
|
2227
2143
|
},
|
|
2228
2144
|
|
|
2229
|
-
/**
|
|
2230
|
-
* Alias for enableBrush
|
|
2231
|
-
*/
|
|
2232
|
-
enableDragging: function enableDragging() {
|
|
2233
|
-
this.enableBrushing();
|
|
2234
|
-
},
|
|
2235
|
-
|
|
2236
|
-
/**
|
|
2237
|
-
* Alias for disableBrush
|
|
2238
|
-
*/
|
|
2239
|
-
disableDragging: function disableDragging() {
|
|
2240
|
-
this.disableBrushing();
|
|
2241
|
-
},
|
|
2242
|
-
|
|
2243
2145
|
/**
|
|
2244
2146
|
* Disable chart zooming.
|
|
2245
2147
|
*/
|
|
@@ -2274,7 +2176,7 @@
|
|
|
2274
2176
|
* Get default zoom level when "followMarker" is true.
|
|
2275
2177
|
*/
|
|
2276
2178
|
getZFollow: function getZFollow() {
|
|
2277
|
-
return this.
|
|
2179
|
+
return this.options.zFollow;
|
|
2278
2180
|
},
|
|
2279
2181
|
|
|
2280
2182
|
/**
|
|
@@ -2294,50 +2196,29 @@
|
|
|
2294
2196
|
this._markedSegments = L.polyline([]);
|
|
2295
2197
|
this._chartEnabled = true, this.track_info = {};
|
|
2296
2198
|
this.options = deepMerge({}, this.options, options);
|
|
2297
|
-
this._zFollow = this.options.zFollow;
|
|
2298
2199
|
if (this.options.followMarker) this._setMapView = L.Util.throttle(this._setMapView, 300, this);
|
|
2299
|
-
if (this.options.placeholder) this.options.loadData.lazy = this.options.loadData.defer = true;
|
|
2300
2200
|
if (this.options.legend) this.options.margins.bottom += 30;
|
|
2301
2201
|
if (this.options.theme) this.options.polylineSegments.className += ' ' + this.options.theme;
|
|
2202
|
+
if (this.options.wptIcons === true) this.options.wptIcons = Options.wptIcons;
|
|
2302
2203
|
|
|
2303
|
-
this._markedSegments.setStyle(this.options.polylineSegments); //
|
|
2304
|
-
// this._resizeChart = L.Util.throttle(this._resizeChart, 300, this);
|
|
2305
|
-
// if (L.Browser.mobile) {
|
|
2306
|
-
// this._updateChart = _.debounce(this._updateChart, 300, this);
|
|
2307
|
-
// this._updateSummary = _.debounce(this._updateSummary, 300, this);
|
|
2308
|
-
// }
|
|
2309
|
-
|
|
2204
|
+
this._markedSegments.setStyle(this.options.polylineSegments); // Leaflet canvas renderer colors
|
|
2310
2205
|
|
|
2311
|
-
if (this.options.wptIcons === true) this.options.wptIcons = Options.wptIcons; // Leaflet canvas renderer colors
|
|
2312
2206
|
|
|
2313
2207
|
L.extend(Colors, this.options.colors || {});
|
|
2314
2208
|
},
|
|
2315
2209
|
|
|
2316
2210
|
/**
|
|
2317
|
-
*
|
|
2318
|
-
*/
|
|
2319
|
-
load: function load(data, opts) {
|
|
2320
|
-
this.loadData(data, opts);
|
|
2321
|
-
},
|
|
2322
|
-
|
|
2323
|
-
/**
|
|
2324
|
-
* Alias for addTo
|
|
2211
|
+
* Javascript scripts downloader (lazy loader)
|
|
2325
2212
|
*/
|
|
2326
|
-
|
|
2327
|
-
this
|
|
2213
|
+
lazyLoad: function lazyLoad$1(src) {
|
|
2214
|
+
return lazyLoad(src, this);
|
|
2328
2215
|
},
|
|
2329
2216
|
|
|
2330
2217
|
/**
|
|
2331
2218
|
* Load elevation data (GPX, GeoJSON or KML).
|
|
2332
2219
|
*/
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
if (opts.defer) {
|
|
2337
|
-
this.loadDefer(data, opts);
|
|
2338
|
-
} else if (opts.lazy) {
|
|
2339
|
-
this.loadLazy(data, opts);
|
|
2340
|
-
} else if (isXMLDoc(data)) {
|
|
2220
|
+
load: function load(data) {
|
|
2221
|
+
if (isXMLDoc(data)) {
|
|
2341
2222
|
this.loadXML(data);
|
|
2342
2223
|
} else if (isJSONDoc(data)) {
|
|
2343
2224
|
this.loadGeoJSON(data);
|
|
@@ -2346,16 +2227,6 @@
|
|
|
2346
2227
|
}
|
|
2347
2228
|
},
|
|
2348
2229
|
|
|
2349
|
-
/**
|
|
2350
|
-
* Wait for document load before download data.
|
|
2351
|
-
*/
|
|
2352
|
-
loadDefer: function loadDefer(data, opts) {
|
|
2353
|
-
opts = L.extend({}, this.options.loadData, opts);
|
|
2354
|
-
opts.defer = false;
|
|
2355
|
-
|
|
2356
|
-
deferFunc(L.bind(this.loadData, this, data, opts));
|
|
2357
|
-
},
|
|
2358
|
-
|
|
2359
2230
|
/**
|
|
2360
2231
|
* Load data from a remote url.
|
|
2361
2232
|
*/
|
|
@@ -2367,10 +2238,7 @@
|
|
|
2367
2238
|
}).then(function (data) {
|
|
2368
2239
|
_this3._downloadURL = url; // TODO: handle multiple urls?
|
|
2369
2240
|
|
|
2370
|
-
_this3.
|
|
2371
|
-
lazy: false,
|
|
2372
|
-
defer: false
|
|
2373
|
-
});
|
|
2241
|
+
_this3.load(data);
|
|
2374
2242
|
}).catch(function (err) {
|
|
2375
2243
|
return console.warn(err);
|
|
2376
2244
|
});
|
|
@@ -2383,20 +2251,13 @@
|
|
|
2383
2251
|
GeoJSONLoader(data, this);
|
|
2384
2252
|
},
|
|
2385
2253
|
|
|
2386
|
-
/**
|
|
2387
|
-
* Alias for loadXML
|
|
2388
|
-
*/
|
|
2389
|
-
loadGPX: function loadGPX(data) {
|
|
2390
|
-
this.loadXML(data);
|
|
2391
|
-
},
|
|
2392
|
-
|
|
2393
2254
|
/**
|
|
2394
2255
|
* Load raw XML data.
|
|
2395
2256
|
*/
|
|
2396
2257
|
loadXML: function loadXML(data) {
|
|
2397
2258
|
var _this4 = this;
|
|
2398
2259
|
|
|
2399
|
-
|
|
2260
|
+
this.lazyLoad(this.__TOGEOJSON).then(function () {
|
|
2400
2261
|
var xml = new DOMParser().parseFromString(data, "text/xml");
|
|
2401
2262
|
var type = xml.documentElement.tagName.toLowerCase(); // "kml" or "gpx"
|
|
2402
2263
|
|
|
@@ -2417,32 +2278,12 @@
|
|
|
2417
2278
|
});
|
|
2418
2279
|
},
|
|
2419
2280
|
|
|
2420
|
-
/**
|
|
2421
|
-
* Wait for chart container visible before download data.
|
|
2422
|
-
*/
|
|
2423
|
-
loadLazy: function loadLazy(data, opts) {
|
|
2424
|
-
var _this5 = this;
|
|
2425
|
-
|
|
2426
|
-
opts = L.extend({}, this.options.loadData, opts);
|
|
2427
|
-
var elem = opts.lazy.parentNode ? opts.lazy : this.placeholder;
|
|
2428
|
-
|
|
2429
|
-
waitHolder(elem).then(function () {
|
|
2430
|
-
opts.lazy = false;
|
|
2431
|
-
|
|
2432
|
-
_this5.loadData(data, opts);
|
|
2433
|
-
|
|
2434
|
-
_this5.once('eledata_loaded', function () {
|
|
2435
|
-
return _this5.placeholder.parentNode.removeChild(elem);
|
|
2436
|
-
});
|
|
2437
|
-
});
|
|
2438
|
-
},
|
|
2439
|
-
|
|
2440
2281
|
/**
|
|
2441
2282
|
* Create container DOM element and related event listeners.
|
|
2442
2283
|
* Called on control.addTo(map).
|
|
2443
2284
|
*/
|
|
2444
2285
|
onAdd: function onAdd(map) {
|
|
2445
|
-
var
|
|
2286
|
+
var _this5 = this;
|
|
2446
2287
|
|
|
2447
2288
|
this._map = map;
|
|
2448
2289
|
|
|
@@ -2452,37 +2293,28 @@
|
|
|
2452
2293
|
addClass(container, 'leaflet-control');
|
|
2453
2294
|
}
|
|
2454
2295
|
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
src: this.options.placeholder,
|
|
2458
|
-
alt: ''
|
|
2459
|
-
} : this.options.placeholder);
|
|
2460
|
-
|
|
2461
|
-
insert(container, this.placeholder, 'afterbegin');
|
|
2462
|
-
}
|
|
2463
|
-
|
|
2464
|
-
Elevation._d3LazyLoader = lazyLoader(this.__D3, (typeof d3 === "undefined" ? "undefined" : _typeof(d3)) !== 'object' || !this.options.lazyLoadJS, Elevation._d3LazyLoader).then(function () {
|
|
2465
|
-
_this6._initButton(container);
|
|
2296
|
+
this.lazyLoad(this.__D3).then(function () {
|
|
2297
|
+
_this5._initButton(container);
|
|
2466
2298
|
|
|
2467
|
-
|
|
2299
|
+
_this5._initChart(container);
|
|
2468
2300
|
|
|
2469
|
-
|
|
2301
|
+
_this5._initSummary(container);
|
|
2470
2302
|
|
|
2471
|
-
|
|
2303
|
+
_this5._initMarker(map);
|
|
2472
2304
|
|
|
2473
|
-
|
|
2305
|
+
_this5._initLayer(map);
|
|
2474
2306
|
|
|
2475
|
-
map.on('zoom viewreset zoomanim',
|
|
2307
|
+
map.on('zoom viewreset zoomanim', _this5._hideMarker, _this5).on('resize', _this5._resetView, _this5).on('resize', _this5._resizeChart, _this5).on('rotate', _this5._rotateMarker, _this5).on('mousedown', _this5._resetDrag, _this5);
|
|
2476
2308
|
|
|
2477
|
-
on(map.getContainer(), 'mousewheel',
|
|
2309
|
+
on(map.getContainer(), 'mousewheel', _this5._resetDrag, _this5);
|
|
2478
2310
|
|
|
2479
|
-
on(map.getContainer(), 'touchstart',
|
|
2311
|
+
on(map.getContainer(), 'touchstart', _this5._resetDrag, _this5);
|
|
2480
2312
|
|
|
2481
|
-
|
|
2313
|
+
_this5.on('eledata_added eledata_loaded', _this5._updateChart, _this5).on('eledata_added eledata_loaded', _this5._updateSummary, _this5);
|
|
2482
2314
|
|
|
2483
|
-
|
|
2315
|
+
_this5._updateChart();
|
|
2484
2316
|
|
|
2485
|
-
|
|
2317
|
+
_this5._updateSummary();
|
|
2486
2318
|
});
|
|
2487
2319
|
return container;
|
|
2488
2320
|
},
|
|
@@ -2513,7 +2345,7 @@
|
|
|
2513
2345
|
* Set default zoom level when "followMarker" is true.
|
|
2514
2346
|
*/
|
|
2515
2347
|
setZFollow: function setZFollow(zoom) {
|
|
2516
|
-
this.
|
|
2348
|
+
this.options.zFollow = zoom;
|
|
2517
2349
|
},
|
|
2518
2350
|
|
|
2519
2351
|
/**
|
|
@@ -2527,7 +2359,7 @@
|
|
|
2527
2359
|
* Parsing data either from GPX or GeoJSON and update the diagram data
|
|
2528
2360
|
*/
|
|
2529
2361
|
_addData: function _addData(d) {
|
|
2530
|
-
var
|
|
2362
|
+
var _this6 = this;
|
|
2531
2363
|
|
|
2532
2364
|
if (!d) {
|
|
2533
2365
|
return;
|
|
@@ -2544,7 +2376,7 @@
|
|
|
2544
2376
|
|
|
2545
2377
|
case 'MultiLineString':
|
|
2546
2378
|
each(geom.coordinates, function (coords) {
|
|
2547
|
-
return
|
|
2379
|
+
return _this6._addGeoJSONData(coords);
|
|
2548
2380
|
});
|
|
2549
2381
|
|
|
2550
2382
|
break;
|
|
@@ -2556,7 +2388,7 @@
|
|
|
2556
2388
|
|
|
2557
2389
|
if (d.type === "FeatureCollection") {
|
|
2558
2390
|
each(d.features, function (feature) {
|
|
2559
|
-
return
|
|
2391
|
+
return _this6._addData(feature);
|
|
2560
2392
|
});
|
|
2561
2393
|
}
|
|
2562
2394
|
|
|
@@ -2569,14 +2401,14 @@
|
|
|
2569
2401
|
* Parsing of GeoJSON data lines and their elevation in z-coordinate
|
|
2570
2402
|
*/
|
|
2571
2403
|
_addGeoJSONData: function _addGeoJSONData(coords) {
|
|
2572
|
-
var
|
|
2404
|
+
var _this7 = this;
|
|
2573
2405
|
|
|
2574
2406
|
each(coords, function (point) {
|
|
2575
|
-
|
|
2407
|
+
_this7._addPoint(point[1], point[0], point[2]);
|
|
2576
2408
|
|
|
2577
|
-
|
|
2409
|
+
_this7._fireEvt("elepoint_added", {
|
|
2578
2410
|
point: point,
|
|
2579
|
-
index:
|
|
2411
|
+
index: _this7._data.length - 1
|
|
2580
2412
|
});
|
|
2581
2413
|
});
|
|
2582
2414
|
|
|
@@ -2590,14 +2422,16 @@
|
|
|
2590
2422
|
* Parsing function for GPX data and their elevation in z-coordinate
|
|
2591
2423
|
*/
|
|
2592
2424
|
_addGPXData: function _addGPXData(coords) {
|
|
2593
|
-
var
|
|
2425
|
+
var _this8 = this;
|
|
2594
2426
|
|
|
2595
2427
|
each(coords, function (point) {
|
|
2596
|
-
|
|
2428
|
+
var _point$alt;
|
|
2429
|
+
|
|
2430
|
+
_this8._addPoint(point.lat, point.lng, (_point$alt = point.alt) !== null && _point$alt !== void 0 ? _point$alt : point.meta.ele);
|
|
2597
2431
|
|
|
2598
|
-
|
|
2432
|
+
_this8._fireEvt("elepoint_added", {
|
|
2599
2433
|
point: point,
|
|
2600
|
-
index:
|
|
2434
|
+
index: _this8._data.length - 1
|
|
2601
2435
|
});
|
|
2602
2436
|
});
|
|
2603
2437
|
|
|
@@ -2718,21 +2552,19 @@
|
|
|
2718
2552
|
opts.xTicks = this._xTicks();
|
|
2719
2553
|
opts.yTicks = this._yTicks();
|
|
2720
2554
|
|
|
2721
|
-
if (opts.
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
clientWidth = _this$_map$getContain.clientWidth;
|
|
2555
|
+
if (opts.detached) {
|
|
2556
|
+
var _this$eleDiv = this.eleDiv,
|
|
2557
|
+
offsetWidth = _this$eleDiv.offsetWidth,
|
|
2558
|
+
offsetHeight = _this$eleDiv.offsetHeight;
|
|
2559
|
+
if (offsetWidth > 0) opts.width = offsetWidth;
|
|
2560
|
+
if (offsetHeight > 20) opts.height = offsetHeight - 20; // 20 = horizontal scrollbar size.
|
|
2561
|
+
} else {
|
|
2562
|
+
var _this$_map$getContain = this._map.getContainer(),
|
|
2563
|
+
clientWidth = _this$_map$getContain.clientWidth;
|
|
2731
2564
|
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
}
|
|
2565
|
+
opts._maxWidth = opts._maxWidth > opts.width ? opts._maxWidth : opts.width;
|
|
2566
|
+
this._container.style.maxWidth = opts._maxWidth + 'px';
|
|
2567
|
+
if (opts._maxWidth > clientWidth) opts.width = clientWidth - 30;
|
|
2736
2568
|
}
|
|
2737
2569
|
|
|
2738
2570
|
var chart = this._chart = new Chart$1(opts, this);
|
|
@@ -2748,17 +2580,17 @@
|
|
|
2748
2580
|
this._fireEvt("elechart_init");
|
|
2749
2581
|
},
|
|
2750
2582
|
_initLayer: function _initLayer() {
|
|
2751
|
-
var
|
|
2583
|
+
var _this9 = this;
|
|
2752
2584
|
|
|
2753
2585
|
this._layers.on('layeradd layerremove', function (e) {
|
|
2754
2586
|
var layer = e.layer;
|
|
2755
2587
|
var node = layer.getElement && layer.getElement();
|
|
2756
2588
|
|
|
2757
|
-
toggleClass(node,
|
|
2589
|
+
toggleClass(node, _this9.options.polyline.className + ' ' + _this9.options.theme, e.type == 'layeradd');
|
|
2758
2590
|
|
|
2759
|
-
toggleEvent(layer, "mousemove",
|
|
2591
|
+
toggleEvent(layer, "mousemove", _this9._mousemoveLayerHandler.bind(_this9), e.type == 'layeradd');
|
|
2760
2592
|
|
|
2761
|
-
toggleEvent(layer, "mouseout",
|
|
2593
|
+
toggleEvent(layer, "mouseout", _this9._mouseoutHandler.bind(_this9), e.type == 'layeradd');
|
|
2762
2594
|
});
|
|
2763
2595
|
},
|
|
2764
2596
|
_initMarker: function _initMarker(map) {
|
|
@@ -2789,7 +2621,7 @@
|
|
|
2789
2621
|
container.setAttribute('aria-haspopup', true);
|
|
2790
2622
|
|
|
2791
2623
|
if (!this.options.detached) {
|
|
2792
|
-
L.DomEvent.disableClickPropagation(container)
|
|
2624
|
+
L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container);
|
|
2793
2625
|
}
|
|
2794
2626
|
|
|
2795
2627
|
if (L.Browser.mobile) {
|
|
@@ -2932,10 +2764,10 @@
|
|
|
2932
2764
|
* Add a waypoint marker to the diagram
|
|
2933
2765
|
*/
|
|
2934
2766
|
_registerCheckPoint: function _registerCheckPoint(props) {
|
|
2935
|
-
var
|
|
2767
|
+
var _this10 = this;
|
|
2936
2768
|
|
|
2937
2769
|
this.on("elechart_updated", function () {
|
|
2938
|
-
return
|
|
2770
|
+
return _this10._chart._registerCheckPoint(props);
|
|
2939
2771
|
});
|
|
2940
2772
|
},
|
|
2941
2773
|
|
|
@@ -2943,10 +2775,10 @@
|
|
|
2943
2775
|
* Add chart profile to diagram
|
|
2944
2776
|
*/
|
|
2945
2777
|
_registerAreaPath: function _registerAreaPath(props) {
|
|
2946
|
-
var
|
|
2778
|
+
var _this11 = this;
|
|
2947
2779
|
|
|
2948
2780
|
this.on("elechart_init", function () {
|
|
2949
|
-
return
|
|
2781
|
+
return _this11._chart._registerAreaPath(props);
|
|
2950
2782
|
});
|
|
2951
2783
|
},
|
|
2952
2784
|
|
|
@@ -2954,10 +2786,10 @@
|
|
|
2954
2786
|
* Add chart grid to diagram
|
|
2955
2787
|
*/
|
|
2956
2788
|
_registerAxisGrid: function _registerAxisGrid(props) {
|
|
2957
|
-
var
|
|
2789
|
+
var _this12 = this;
|
|
2958
2790
|
|
|
2959
2791
|
this.on("elechart_axis", function () {
|
|
2960
|
-
return
|
|
2792
|
+
return _this12._chart._registerAxisGrid(props);
|
|
2961
2793
|
});
|
|
2962
2794
|
},
|
|
2963
2795
|
|
|
@@ -2965,25 +2797,25 @@
|
|
|
2965
2797
|
* Add chart axis to diagram
|
|
2966
2798
|
*/
|
|
2967
2799
|
_registerAxisScale: function _registerAxisScale(props) {
|
|
2968
|
-
var
|
|
2800
|
+
var _this13 = this;
|
|
2969
2801
|
|
|
2970
2802
|
this.on("elechart_axis", function () {
|
|
2971
|
-
return
|
|
2803
|
+
return _this13._chart._registerAxisScale(props);
|
|
2972
2804
|
});
|
|
2973
2805
|
},
|
|
2974
2806
|
|
|
2975
2807
|
/**
|
|
2976
2808
|
* Add chart or marker tooltip info
|
|
2977
2809
|
*/
|
|
2978
|
-
|
|
2979
|
-
var
|
|
2810
|
+
_registerTooltip: function _registerTooltip(props) {
|
|
2811
|
+
var _this14 = this;
|
|
2980
2812
|
|
|
2981
2813
|
if (props.chart) {
|
|
2982
2814
|
var label = L.extend({}, props, {
|
|
2983
2815
|
value: props.chart
|
|
2984
2816
|
});
|
|
2985
2817
|
this.on("elechart_init", function () {
|
|
2986
|
-
return
|
|
2818
|
+
return _this14._chart._registerTooltip(label);
|
|
2987
2819
|
});
|
|
2988
2820
|
}
|
|
2989
2821
|
|
|
@@ -2993,7 +2825,7 @@
|
|
|
2993
2825
|
});
|
|
2994
2826
|
|
|
2995
2827
|
this.on("elechart_marker", function () {
|
|
2996
|
-
return
|
|
2828
|
+
return _this14._marker._registerTooltip(_label);
|
|
2997
2829
|
});
|
|
2998
2830
|
}
|
|
2999
2831
|
},
|
|
@@ -3002,10 +2834,10 @@
|
|
|
3002
2834
|
* Add summary info to diagram
|
|
3003
2835
|
*/
|
|
3004
2836
|
_registerSummary: function _registerSummary(props) {
|
|
3005
|
-
var
|
|
2837
|
+
var _this15 = this;
|
|
3006
2838
|
|
|
3007
2839
|
this.on('elechart_summary', function () {
|
|
3008
|
-
return
|
|
2840
|
+
return _this15._summary._registerSummary(props);
|
|
3009
2841
|
});
|
|
3010
2842
|
},
|
|
3011
2843
|
|
|
@@ -3037,34 +2869,32 @@
|
|
|
3037
2869
|
* Hacky way for handling chart resize. Deletes it and redraw chart.
|
|
3038
2870
|
*/
|
|
3039
2871
|
_resizeChart: function _resizeChart() {
|
|
3040
|
-
// prevent displaying chart on resize if hidden
|
|
2872
|
+
if (!this._container) return; // prevent displaying chart on resize if hidden
|
|
2873
|
+
|
|
3041
2874
|
if (style(this._container, "display") == "none") return;
|
|
3042
2875
|
var opts = this.options;
|
|
2876
|
+
var newWidth;
|
|
3043
2877
|
|
|
3044
|
-
if (opts.
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
} else {
|
|
3050
|
-
var _this$_map$getContain2 = this._map.getContainer(),
|
|
3051
|
-
clientWidth = _this$_map$getContain2.clientWidth;
|
|
2878
|
+
if (opts.detached) {
|
|
2879
|
+
newWidth = (this.eleDiv || this._container).offsetWidth;
|
|
2880
|
+
} else {
|
|
2881
|
+
var _this$_map$getContain2 = this._map.getContainer(),
|
|
2882
|
+
clientWidth = _this$_map$getContain2.clientWidth;
|
|
3052
2883
|
|
|
3053
|
-
|
|
3054
|
-
|
|
2884
|
+
newWidth = opts._maxWidth > clientWidth ? clientWidth - 30 : opts._maxWidth;
|
|
2885
|
+
}
|
|
3055
2886
|
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
2887
|
+
if (newWidth) {
|
|
2888
|
+
var chart = this._chart;
|
|
2889
|
+
opts.width = newWidth;
|
|
3059
2890
|
|
|
3060
|
-
|
|
3061
|
-
|
|
2891
|
+
if (chart && chart._chart) {
|
|
2892
|
+
chart._chart._resize(opts);
|
|
3062
2893
|
|
|
3063
|
-
|
|
3064
|
-
|
|
2894
|
+
opts.xTicks = this._xTicks();
|
|
2895
|
+
opts.yTicks = this._yTicks();
|
|
3065
2896
|
|
|
3066
|
-
|
|
3067
|
-
}
|
|
2897
|
+
this._updateChart();
|
|
3068
2898
|
}
|
|
3069
2899
|
}
|
|
3070
2900
|
|
|
@@ -3093,10 +2923,10 @@
|
|
|
3093
2923
|
|
|
3094
2924
|
var zoom = this._map.getZoom();
|
|
3095
2925
|
|
|
3096
|
-
|
|
3097
|
-
if (zoom < this._zFollow) zoom = this._zFollow;
|
|
2926
|
+
var z = this.options.zFollow;
|
|
3098
2927
|
|
|
3099
|
-
|
|
2928
|
+
if (typeof z === "number") {
|
|
2929
|
+
this._map.setView(item.latlng, zoom < z ? z : zoom, {
|
|
3100
2930
|
animate: true,
|
|
3101
2931
|
duration: 0.25
|
|
3102
2932
|
});
|
|
@@ -3112,7 +2942,7 @@
|
|
|
3112
2942
|
* Toggle chart data on legend click
|
|
3113
2943
|
*/
|
|
3114
2944
|
_toggleChartHandler: function _toggleChartHandler(e) {
|
|
3115
|
-
var
|
|
2945
|
+
var _this16 = this;
|
|
3116
2946
|
|
|
3117
2947
|
var path = e.path,
|
|
3118
2948
|
name = e.name,
|
|
@@ -3122,7 +2952,7 @@
|
|
|
3122
2952
|
this._layers.eachLayer(function (layer) {
|
|
3123
2953
|
var node = layer.getElement && layer.getElement();
|
|
3124
2954
|
|
|
3125
|
-
toggleClass(node,
|
|
2955
|
+
toggleClass(node, _this16.options.polyline.className + ' ' + _this16.options.theme, _this16._chartEnabled);
|
|
3126
2956
|
}); // toggle option value (eg. altitude = { 'disabled' || 'disabled' })
|
|
3127
2957
|
|
|
3128
2958
|
|
|
@@ -3141,7 +2971,7 @@
|
|
|
3141
2971
|
_updateChart: function _updateChart() {
|
|
3142
2972
|
if (
|
|
3143
2973
|
/*!this._data.length ||*/
|
|
3144
|
-
!this._container) return;
|
|
2974
|
+
!this._chart || !this._container) return;
|
|
3145
2975
|
|
|
3146
2976
|
this._fireEvt("elechart_axis");
|
|
3147
2977
|
|
|
@@ -3162,23 +2992,23 @@
|
|
|
3162
2992
|
* Update the position/height indicator marker drawn onto the map
|
|
3163
2993
|
*/
|
|
3164
2994
|
_updateMarker: function _updateMarker(item) {
|
|
3165
|
-
if (
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
}
|
|
2995
|
+
if (this._marker) {
|
|
2996
|
+
this._marker.update({
|
|
2997
|
+
map: this._map,
|
|
2998
|
+
item: item,
|
|
2999
|
+
maxElevation: this.track_info.elevation_max || 0,
|
|
3000
|
+
options: this.options
|
|
3001
|
+
});
|
|
3002
|
+
}
|
|
3173
3003
|
},
|
|
3174
3004
|
|
|
3175
3005
|
/**
|
|
3176
3006
|
* Fix marker rotation on rotated maps
|
|
3177
3007
|
*/
|
|
3178
3008
|
_rotateMarker: function _rotateMarker() {
|
|
3179
|
-
if (
|
|
3180
|
-
|
|
3181
|
-
|
|
3009
|
+
if (this._marker) {
|
|
3010
|
+
this._marker.update();
|
|
3011
|
+
}
|
|
3182
3012
|
},
|
|
3183
3013
|
|
|
3184
3014
|
/**
|
|
@@ -3196,7 +3026,7 @@
|
|
|
3196
3026
|
* Update chart summary.
|
|
3197
3027
|
*/
|
|
3198
3028
|
_updateSummary: function _updateSummary() {
|
|
3199
|
-
var
|
|
3029
|
+
var _this17 = this;
|
|
3200
3030
|
|
|
3201
3031
|
this._summary.reset();
|
|
3202
3032
|
|
|
@@ -3211,9 +3041,9 @@
|
|
|
3211
3041
|
select('.download a', this.summaryDiv).onclick = function (e) {
|
|
3212
3042
|
e.preventDefault();
|
|
3213
3043
|
|
|
3214
|
-
|
|
3215
|
-
downloadLink:
|
|
3216
|
-
confirm: saveFile.bind(
|
|
3044
|
+
_this17._fireEvt('eletrack_download', {
|
|
3045
|
+
downloadLink: _this17.options.downloadLink,
|
|
3046
|
+
confirm: saveFile.bind(_this17, _this17._downloadURL)
|
|
3217
3047
|
});
|
|
3218
3048
|
};
|
|
3219
3049
|
}
|
|
@@ -3249,6 +3079,12 @@
|
|
|
3249
3079
|
*/
|
|
3250
3080
|
|
|
3251
3081
|
Elevation.addInitHook(function () {
|
|
3082
|
+
// Alias deprecated functions
|
|
3083
|
+
this.enableDragging = this.enableBrush;
|
|
3084
|
+
this.disableDragging = this.disableBrush;
|
|
3085
|
+
this.loadChart = this.addTo;
|
|
3086
|
+
this.loadData = this.load;
|
|
3087
|
+
this.loadGPX = this.loadXML;
|
|
3252
3088
|
this.on('waypoint_added', function (e) {
|
|
3253
3089
|
var p = e.point,
|
|
3254
3090
|
pop = p._popup;
|
|
@@ -3277,7 +3113,7 @@
|
|
|
3277
3113
|
}
|
|
3278
3114
|
});
|
|
3279
3115
|
this.on('eledata_loaded', function (e) {
|
|
3280
|
-
var
|
|
3116
|
+
var _this18 = this;
|
|
3281
3117
|
|
|
3282
3118
|
var map = this._map;
|
|
3283
3119
|
var layer = e.layer;
|
|
@@ -3288,37 +3124,37 @@
|
|
|
3288
3124
|
}
|
|
3289
3125
|
|
|
3290
3126
|
map.once('layeradd', function (e) {
|
|
3291
|
-
return
|
|
3127
|
+
return _this18.options.autofitBounds && _this18.fitBounds(layer.getBounds());
|
|
3292
3128
|
});
|
|
3293
3129
|
|
|
3294
3130
|
if (L.Browser.mobile) {
|
|
3295
3131
|
if (this.options.polyline) layer.addTo(map);
|
|
3296
3132
|
} else {
|
|
3297
3133
|
// leaflet-geometryutil
|
|
3298
|
-
|
|
3134
|
+
this.lazyLoad(this.__LGEOMUTIL).then(function () {
|
|
3299
3135
|
// leaflet-almostover
|
|
3300
|
-
if (
|
|
3301
|
-
|
|
3136
|
+
if (_this18.options.almostOver) {
|
|
3137
|
+
_this18.lazyLoad(_this18.__LALMOSTOVER).then(function () {
|
|
3302
3138
|
map.addHandler('almostOver', L.Handler.AlmostOver);
|
|
3303
3139
|
|
|
3304
3140
|
if (L.GeometryUtil && map.almostOver && map.almostOver.enabled()) {
|
|
3305
3141
|
map.almostOver.addLayer(layer);
|
|
3306
3142
|
map.on('almost:move', function (e) {
|
|
3307
|
-
return
|
|
3143
|
+
return _this18._mousemoveLayerHandler(e);
|
|
3308
3144
|
}).on('almost:out', function (e) {
|
|
3309
|
-
return
|
|
3145
|
+
return _this18._mouseoutHandler(e);
|
|
3310
3146
|
});
|
|
3311
3147
|
}
|
|
3312
3148
|
});
|
|
3313
3149
|
} // leaflet-distance-markers
|
|
3314
3150
|
|
|
3315
3151
|
|
|
3316
|
-
if (
|
|
3317
|
-
|
|
3318
|
-
return
|
|
3152
|
+
if (_this18.options.distanceMarkers) {
|
|
3153
|
+
_this18.lazyLoad(_this18.__LDISTANCEM).then(function () {
|
|
3154
|
+
return _this18.options.polyline && layer.addTo(map);
|
|
3319
3155
|
});
|
|
3320
3156
|
} else {
|
|
3321
|
-
if (
|
|
3157
|
+
if (_this18.options.polyline) layer.addTo(map);
|
|
3322
3158
|
}
|
|
3323
3159
|
});
|
|
3324
3160
|
}
|
|
@@ -3339,7 +3175,7 @@
|
|
|
3339
3175
|
if (options.stroke && options.weight !== 0) {
|
|
3340
3176
|
var oldVal = ctx.globalCompositeOperation || 'source-over';
|
|
3341
3177
|
ctx.globalCompositeOperation = 'destination-over';
|
|
3342
|
-
ctx.strokeStyle = '#FFF';
|
|
3178
|
+
ctx.strokeStyle = color.outline || '#FFF';
|
|
3343
3179
|
ctx.lineWidth = options.weight * 1.75;
|
|
3344
3180
|
ctx.stroke();
|
|
3345
3181
|
ctx.globalCompositeOperation = oldVal;
|
|
@@ -3364,94 +3200,24 @@
|
|
|
3364
3200
|
});
|
|
3365
3201
|
|
|
3366
3202
|
Elevation.addInitHook(function () {
|
|
3367
|
-
var _this2 = this;
|
|
3368
|
-
|
|
3369
|
-
var opts = this.options;
|
|
3370
|
-
var distance = {};
|
|
3371
|
-
|
|
3372
|
-
if (this.options.imperial) {
|
|
3373
|
-
this._distanceFactor = this.__mileFactor;
|
|
3374
|
-
this._xLabel = "mi";
|
|
3375
|
-
} else {
|
|
3376
|
-
this._distanceFactor = opts.distanceFactor;
|
|
3377
|
-
this._xLabel = opts.xLabel;
|
|
3378
|
-
}
|
|
3379
|
-
|
|
3380
|
-
this.on("eledata_updated", function (e) {
|
|
3381
|
-
var data = this._data;
|
|
3382
|
-
var i = e.index;
|
|
3383
|
-
var track = this.track_info;
|
|
3384
|
-
var dist = track.distance || 0;
|
|
3385
|
-
var curr = data[i].latlng;
|
|
3386
|
-
var prev = i > 0 ? data[i - 1].latlng : curr;
|
|
3387
|
-
|
|
3388
|
-
var delta = curr.distanceTo(prev) * this._distanceFactor;
|
|
3389
|
-
|
|
3390
|
-
dist += Math.round(delta / 1000 * 100000) / 100000; // handles floating points calc
|
|
3391
|
-
|
|
3392
|
-
data[i].dist = dist;
|
|
3393
|
-
track.distance = dist;
|
|
3394
|
-
});
|
|
3395
|
-
this.on("elechart_axis", function () {
|
|
3396
|
-
this._chart._registerAxisGrid({
|
|
3397
|
-
axis: "x",
|
|
3398
|
-
position: "bottom",
|
|
3399
|
-
scale: this._chart._x
|
|
3400
|
-
});
|
|
3401
|
-
});
|
|
3402
|
-
|
|
3403
|
-
if (this.options.distance != "summary") {
|
|
3404
|
-
this.on("elechart_axis", function () {
|
|
3405
|
-
var _this = this;
|
|
3406
|
-
|
|
3407
|
-
distance.x = this._chart._x;
|
|
3408
|
-
distance.label = this._chart._xLabel;
|
|
3409
|
-
|
|
3410
|
-
this._chart._registerAxisScale({
|
|
3411
|
-
axis: "x",
|
|
3412
|
-
position: "bottom",
|
|
3413
|
-
scale: distance.x,
|
|
3414
|
-
label: distance.label,
|
|
3415
|
-
labelY: 25,
|
|
3416
|
-
labelX: function labelX() {
|
|
3417
|
-
return _this._width() + 6;
|
|
3418
|
-
},
|
|
3419
|
-
name: "distance"
|
|
3420
|
-
});
|
|
3421
|
-
});
|
|
3422
|
-
}
|
|
3423
|
-
|
|
3424
|
-
this._registerSummary({
|
|
3425
|
-
"totlen": {
|
|
3426
|
-
label: "Total Length: ",
|
|
3427
|
-
value: function value(track) {
|
|
3428
|
-
return (track.distance || 0).toFixed(2) + ' ' + _this2._xLabel;
|
|
3429
|
-
}
|
|
3430
|
-
}
|
|
3431
|
-
});
|
|
3432
|
-
});
|
|
3433
|
-
|
|
3434
|
-
Elevation.addInitHook(function () {
|
|
3435
|
-
var _this = this;
|
|
3436
|
-
|
|
3437
3203
|
var opts = this.options;
|
|
3438
3204
|
var altitude = {};
|
|
3439
3205
|
|
|
3440
3206
|
if (opts.imperial) {
|
|
3441
|
-
|
|
3442
|
-
|
|
3207
|
+
opts.altitudeFactor = this.__footFactor;
|
|
3208
|
+
altitude.label = "ft";
|
|
3443
3209
|
} else {
|
|
3444
|
-
|
|
3445
|
-
|
|
3210
|
+
opts.altitudeFactor = opts.heightFactor || opts.altitudeFactor || 1;
|
|
3211
|
+
altitude.label = opts.yLabel;
|
|
3446
3212
|
}
|
|
3447
3213
|
|
|
3448
3214
|
this.on("eledata_updated", function (e) {
|
|
3449
3215
|
var data = this._data;
|
|
3450
3216
|
var i = e.index;
|
|
3451
|
-
var z = data[i].z *
|
|
3217
|
+
var z = data[i].z * opts.altitudeFactor;
|
|
3452
3218
|
var track = this.track_info;
|
|
3453
|
-
var
|
|
3454
|
-
var
|
|
3219
|
+
var zMax = track.elevation_max || -Infinity;
|
|
3220
|
+
var zMin = track.elevation_min || +Infinity; // check and fix missing elevation data on last added point
|
|
3455
3221
|
|
|
3456
3222
|
if (!this.options.skipNullZCoords && i > 0) {
|
|
3457
3223
|
var prevZ = data[i - 1].z;
|
|
@@ -3475,14 +3241,12 @@
|
|
|
3475
3241
|
|
|
3476
3242
|
|
|
3477
3243
|
if (!isNaN(z)) {
|
|
3478
|
-
eleMax = eleMax < z ? z : eleMax;
|
|
3479
|
-
eleMin = eleMin > z ? z : eleMin;
|
|
3480
3244
|
this._lastValidZ = z;
|
|
3481
3245
|
}
|
|
3482
3246
|
|
|
3247
|
+
track.elevation_max = z > zMax ? z : zMax;
|
|
3248
|
+
track.elevation_min = z < zMin ? z : zMin;
|
|
3483
3249
|
data[i].z = z;
|
|
3484
|
-
track.elevation_max = eleMax;
|
|
3485
|
-
track.elevation_min = eleMin;
|
|
3486
3250
|
});
|
|
3487
3251
|
this.on("elechart_axis", function () {
|
|
3488
3252
|
this._chart._registerAxisGrid({
|
|
@@ -3494,13 +3258,10 @@
|
|
|
3494
3258
|
|
|
3495
3259
|
if (this.options.altitude != "summary") {
|
|
3496
3260
|
this.on("elechart_axis", function () {
|
|
3497
|
-
altitude.y = this._chart._y;
|
|
3498
|
-
altitude.label = this._yLabel;
|
|
3499
|
-
|
|
3500
3261
|
this._chart._registerAxisScale({
|
|
3501
3262
|
axis: "y",
|
|
3502
3263
|
position: "left",
|
|
3503
|
-
scale:
|
|
3264
|
+
scale: this._chart._y,
|
|
3504
3265
|
label: altitude.label,
|
|
3505
3266
|
labelX: -3,
|
|
3506
3267
|
labelY: -8,
|
|
@@ -3510,8 +3271,6 @@
|
|
|
3510
3271
|
this.on("elechart_init", function () {
|
|
3511
3272
|
var theme = this.options.theme.replace('-theme', '');
|
|
3512
3273
|
var color = Colors[theme] || {};
|
|
3513
|
-
var alpha = this.options.detached ? color.alpha || '0.8' : 1;
|
|
3514
|
-
var stroke = this.options.detached ? color.stroke : false;
|
|
3515
3274
|
|
|
3516
3275
|
this._chart._registerAreaPath({
|
|
3517
3276
|
name: 'altitude',
|
|
@@ -3519,25 +3278,103 @@
|
|
|
3519
3278
|
scaleX: 'distance',
|
|
3520
3279
|
scaleY: 'altitude',
|
|
3521
3280
|
color: color.area || theme,
|
|
3522
|
-
strokeColor: stroke
|
|
3281
|
+
strokeColor: this.options.detached ? color.stroke : '#000',
|
|
3523
3282
|
strokeOpacity: "1",
|
|
3524
|
-
fillOpacity: alpha,
|
|
3283
|
+
fillOpacity: this.options.detached ? color.alpha || '0.8' : 1,
|
|
3525
3284
|
preferCanvas: this.options.preferCanvas
|
|
3526
3285
|
});
|
|
3527
3286
|
});
|
|
3528
3287
|
}
|
|
3529
3288
|
|
|
3289
|
+
this._registerTooltip({
|
|
3290
|
+
name: 'y',
|
|
3291
|
+
chart: function chart(item) {
|
|
3292
|
+
return L._("y: ") + d3.format("." + opts.decimalsY + "f")(item[opts.yAttr]) + " " + altitude.label;
|
|
3293
|
+
},
|
|
3294
|
+
marker: function marker(item) {
|
|
3295
|
+
return d3.format("." + opts.decimalsY + "f")(item[opts.yAttr]) + " " + altitude.label;
|
|
3296
|
+
}
|
|
3297
|
+
});
|
|
3298
|
+
|
|
3530
3299
|
this._registerSummary({
|
|
3531
3300
|
"maxele": {
|
|
3532
3301
|
label: "Max Elevation: ",
|
|
3533
3302
|
value: function value(track) {
|
|
3534
|
-
return (track.elevation_max || 0).toFixed(2) + ' ' +
|
|
3303
|
+
return (track.elevation_max || 0).toFixed(2) + ' ' + altitude.label;
|
|
3535
3304
|
}
|
|
3536
3305
|
},
|
|
3537
3306
|
"minele": {
|
|
3538
3307
|
label: "Min Elevation: ",
|
|
3539
3308
|
value: function value(track) {
|
|
3540
|
-
return (track.elevation_min || 0).toFixed(2) + ' ' +
|
|
3309
|
+
return (track.elevation_min || 0).toFixed(2) + ' ' + altitude.label;
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
});
|
|
3313
|
+
});
|
|
3314
|
+
|
|
3315
|
+
Elevation.addInitHook(function () {
|
|
3316
|
+
var opts = this.options;
|
|
3317
|
+
var distance = {};
|
|
3318
|
+
|
|
3319
|
+
if (opts.imperial) {
|
|
3320
|
+
opts.distanceFactor = this.__mileFactor;
|
|
3321
|
+
distance.label = "mi";
|
|
3322
|
+
} else {
|
|
3323
|
+
opts.distanceFactor = opts.distanceFactor || 1;
|
|
3324
|
+
distance.label = opts.xLabel;
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
this.on("eledata_updated", function (e) {
|
|
3328
|
+
var data = this._data;
|
|
3329
|
+
var i = e.index;
|
|
3330
|
+
var track = this.track_info;
|
|
3331
|
+
var dist = track.distance || 0;
|
|
3332
|
+
var curr = data[i].latlng;
|
|
3333
|
+
var prev = i > 0 ? data[i - 1].latlng : curr;
|
|
3334
|
+
var delta = curr.distanceTo(prev) * opts.distanceFactor;
|
|
3335
|
+
dist += Math.round(delta / 1000 * 100000) / 100000; // handles floating points calc
|
|
3336
|
+
|
|
3337
|
+
track.distance = dist;
|
|
3338
|
+
data[i].dist = dist;
|
|
3339
|
+
});
|
|
3340
|
+
this.on("elechart_axis", function () {
|
|
3341
|
+
this._chart._registerAxisGrid({
|
|
3342
|
+
axis: "x",
|
|
3343
|
+
position: "bottom",
|
|
3344
|
+
scale: this._chart._x
|
|
3345
|
+
});
|
|
3346
|
+
});
|
|
3347
|
+
|
|
3348
|
+
if (this.options.distance != "summary") {
|
|
3349
|
+
this.on("elechart_axis", function () {
|
|
3350
|
+
var _this = this;
|
|
3351
|
+
|
|
3352
|
+
this._chart._registerAxisScale({
|
|
3353
|
+
axis: "x",
|
|
3354
|
+
position: "bottom",
|
|
3355
|
+
scale: this._chart._x,
|
|
3356
|
+
label: distance.label,
|
|
3357
|
+
labelY: 25,
|
|
3358
|
+
labelX: function labelX() {
|
|
3359
|
+
return _this._width() + 6;
|
|
3360
|
+
},
|
|
3361
|
+
name: "distance"
|
|
3362
|
+
});
|
|
3363
|
+
});
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
this._registerTooltip({
|
|
3367
|
+
name: 'x',
|
|
3368
|
+
chart: function chart(item) {
|
|
3369
|
+
return L._("x: ") + d3.format("." + opts.decimalsX + "f")(item[opts.xAttr]) + " " + distance.label;
|
|
3370
|
+
}
|
|
3371
|
+
});
|
|
3372
|
+
|
|
3373
|
+
this._registerSummary({
|
|
3374
|
+
"totlen": {
|
|
3375
|
+
label: "Total Length: ",
|
|
3376
|
+
value: function value(track) {
|
|
3377
|
+
return (track.distance || 0).toFixed(2) + ' ' + distance.label;
|
|
3541
3378
|
}
|
|
3542
3379
|
}
|
|
3543
3380
|
});
|
|
@@ -3549,7 +3386,7 @@
|
|
|
3549
3386
|
var opts = this.options;
|
|
3550
3387
|
var time = {};
|
|
3551
3388
|
time.label = opts.timeLabel || 't';
|
|
3552
|
-
|
|
3389
|
+
opts.timeFactor = opts.timeFactor || 3600;
|
|
3553
3390
|
/**
|
|
3554
3391
|
* Common AVG speeds:
|
|
3555
3392
|
* ----------------------
|
|
@@ -3614,7 +3451,7 @@
|
|
|
3614
3451
|
e.point.meta = e.point.meta || {};
|
|
3615
3452
|
var delta = data[i].dist - data[i > 0 ? i - 1 : i].dist;
|
|
3616
3453
|
var speed = this._timeAVGSpeed;
|
|
3617
|
-
e.point.meta.time = new Date(i > 0 ? data[i - 1].time.getTime() + delta / speed *
|
|
3454
|
+
e.point.meta.time = new Date(i > 0 ? data[i - 1].time.getTime() + delta / speed * opts.timeFactor * 1000 : Date.now());
|
|
3618
3455
|
}
|
|
3619
3456
|
|
|
3620
3457
|
var time = e.point.meta.time; // Handle timezone offset
|
|
@@ -3627,16 +3464,25 @@
|
|
|
3627
3464
|
var prevT = i > 0 ? data[i - 1].time : currT;
|
|
3628
3465
|
var deltaT = Math.abs(currT - prevT);
|
|
3629
3466
|
var duration = (this.track_info.time || 0) + deltaT;
|
|
3467
|
+
this.track_info.time = duration;
|
|
3630
3468
|
data[i].time = time;
|
|
3631
3469
|
data[i].duration = duration;
|
|
3632
|
-
this.track_info.time = duration;
|
|
3633
3470
|
});
|
|
3634
3471
|
|
|
3472
|
+
if (this.options.timestamps) {
|
|
3473
|
+
this._registerTooltip({
|
|
3474
|
+
name: 'date',
|
|
3475
|
+
chart: function chart(item) {
|
|
3476
|
+
return L._("t: ") + _this.options.timeFormat(item.time);
|
|
3477
|
+
}
|
|
3478
|
+
});
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3635
3481
|
if (this.options.time) {
|
|
3636
|
-
this.
|
|
3482
|
+
this._registerTooltip({
|
|
3637
3483
|
name: 'time',
|
|
3638
3484
|
chart: function chart(item) {
|
|
3639
|
-
return
|
|
3485
|
+
return L._("T: ") + formatTime(item.duration || 0);
|
|
3640
3486
|
}
|
|
3641
3487
|
});
|
|
3642
3488
|
|
|
@@ -3722,25 +3568,18 @@
|
|
|
3722
3568
|
} // Range of acceptable slope values.
|
|
3723
3569
|
|
|
3724
3570
|
|
|
3725
|
-
|
|
3726
|
-
var range = this.options.sRange;
|
|
3727
|
-
if (slope < range[0]) slope = range[0];else if (slope > range[1]) slope = range[1];
|
|
3728
|
-
}
|
|
3729
|
-
|
|
3730
|
-
slope = L.Util.formatNum(slope, 2);
|
|
3731
|
-
if (slope > sMax) sMax = slope;
|
|
3732
|
-
if (slope < sMin) sMin = slope;
|
|
3733
|
-
data[i].slope = slope;
|
|
3571
|
+
slope = clamp(slope, this.options.sRange);
|
|
3734
3572
|
track.ascent = tAsc;
|
|
3735
3573
|
track.descent = tDes;
|
|
3736
|
-
track.slope_max = sMax;
|
|
3737
|
-
track.slope_min = sMin;
|
|
3574
|
+
track.slope_max = slope > sMax ? slope : sMax;
|
|
3575
|
+
track.slope_min = slope < sMin ? slope : sMin;
|
|
3576
|
+
data[i].slope = L.Util.formatNum(slope, 2);
|
|
3738
3577
|
});
|
|
3739
3578
|
|
|
3740
|
-
this.
|
|
3579
|
+
this._registerTooltip({
|
|
3741
3580
|
name: 'slope',
|
|
3742
3581
|
chart: function chart(item) {
|
|
3743
|
-
return item.slope + slope.label;
|
|
3582
|
+
return L._("m: ") + item.slope + slope.label;
|
|
3744
3583
|
},
|
|
3745
3584
|
marker: function marker(item) {
|
|
3746
3585
|
return Math.round(item.slope) + slope.label;
|
|
@@ -3751,13 +3590,13 @@
|
|
|
3751
3590
|
"ascent": {
|
|
3752
3591
|
label: "Total Ascent: ",
|
|
3753
3592
|
value: function value(track) {
|
|
3754
|
-
return Math.round(track.ascent || 0) + ' ' + _this.
|
|
3593
|
+
return Math.round(track.ascent || 0) + ' ' + (_this.options.imperial ? 'ft' : 'm');
|
|
3755
3594
|
}
|
|
3756
3595
|
},
|
|
3757
3596
|
"descent": {
|
|
3758
3597
|
label: "Total Descent: ",
|
|
3759
3598
|
value: function value(track) {
|
|
3760
|
-
return Math.round(track.descent || 0) + ' ' + _this.
|
|
3599
|
+
return Math.round(track.descent || 0) + ' ' + (_this.options.imperial ? 'ft' : 'm');
|
|
3761
3600
|
}
|
|
3762
3601
|
},
|
|
3763
3602
|
"minslope": {
|
|
@@ -3779,8 +3618,8 @@
|
|
|
3779
3618
|
if (!this.options.speed && !this.options.acceleration) return;
|
|
3780
3619
|
var opts = this.options;
|
|
3781
3620
|
var speed = {};
|
|
3782
|
-
speed.label = opts.speedLabel || L._(
|
|
3783
|
-
|
|
3621
|
+
speed.label = opts.speedLabel || L._(opts.imperial ? 'mph' : 'km/h');
|
|
3622
|
+
opts.speedFactor = opts.speedFactor || 1;
|
|
3784
3623
|
|
|
3785
3624
|
if (this.options.speed && this.options.speed != "summary") {
|
|
3786
3625
|
this._registerAxisScale({
|
|
@@ -3827,7 +3666,7 @@
|
|
|
3827
3666
|
|
|
3828
3667
|
if (deltaT > 0) {
|
|
3829
3668
|
var delta = (data[i].dist - data[i > 0 ? i - 1 : i].dist) * 1000;
|
|
3830
|
-
speed = Math.abs(delta / deltaT *
|
|
3669
|
+
speed = Math.abs(delta / deltaT * opts.timeFactor) * opts.speedFactor;
|
|
3831
3670
|
} // Try to smooth "crazy" speed values.
|
|
3832
3671
|
|
|
3833
3672
|
|
|
@@ -3841,26 +3680,18 @@
|
|
|
3841
3680
|
} // Range of acceptable speed values.
|
|
3842
3681
|
|
|
3843
3682
|
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
speed = L.Util.formatNum(speed, 2);
|
|
3850
|
-
sMax = speed > sMax ? speed : sMax;
|
|
3851
|
-
sMin = speed < sMin ? speed : sMin;
|
|
3852
|
-
sAvg = (speed + sAvg) / 2.0;
|
|
3853
|
-
data[i].speed = speed;
|
|
3854
|
-
track.speed_max = sMax;
|
|
3855
|
-
track.speed_min = sMin;
|
|
3856
|
-
track.speed_avg = sAvg;
|
|
3683
|
+
speed = clamp(speed, this.options.speedRange);
|
|
3684
|
+
track.speed_max = speed > sMax ? speed : sMax;
|
|
3685
|
+
track.speed_min = speed < sMin ? speed : sMin;
|
|
3686
|
+
track.speed_avg = (speed + sAvg) / 2.0;
|
|
3687
|
+
data[i].speed = L.Util.formatNum(speed, 2);
|
|
3857
3688
|
});
|
|
3858
3689
|
|
|
3859
3690
|
if (this.options.speed) {
|
|
3860
|
-
this.
|
|
3691
|
+
this._registerTooltip({
|
|
3861
3692
|
name: 'speed',
|
|
3862
3693
|
chart: function chart(item) {
|
|
3863
|
-
return item.speed + " " + speed.label;
|
|
3694
|
+
return L._('v: ') + item.speed + " " + speed.label;
|
|
3864
3695
|
},
|
|
3865
3696
|
marker: function marker(item) {
|
|
3866
3697
|
return Math.round(item.speed) + " " + speed.label;
|
|
@@ -3894,8 +3725,8 @@
|
|
|
3894
3725
|
if (!this.options.acceleration) return;
|
|
3895
3726
|
var opts = this.options;
|
|
3896
3727
|
var acceleration = {};
|
|
3897
|
-
acceleration.label = opts.accelerationLabel || L._(
|
|
3898
|
-
|
|
3728
|
+
acceleration.label = opts.accelerationLabel || L._(opts.imperial ? 'ft/s²' : 'm/s²');
|
|
3729
|
+
opts.accelerationFactor = opts.accelerationFactor || 1;
|
|
3899
3730
|
|
|
3900
3731
|
if (this.options.acceleration != "summary") {
|
|
3901
3732
|
this._registerAxisScale({
|
|
@@ -3943,8 +3774,8 @@
|
|
|
3943
3774
|
if (deltaT > 0) {
|
|
3944
3775
|
var curr = data[i].speed;
|
|
3945
3776
|
var prev = i > 0 ? data[i - 1].speed : curr;
|
|
3946
|
-
var delta = (curr - prev) * (1000 /
|
|
3947
|
-
acceleration = Math.abs(delta / deltaT) *
|
|
3777
|
+
var delta = (curr - prev) * (1000 / opts.timeFactor);
|
|
3778
|
+
acceleration = Math.abs(delta / deltaT) * opts.accelerationFactor;
|
|
3948
3779
|
} // Try to smooth "crazy" acceleration values.
|
|
3949
3780
|
|
|
3950
3781
|
|
|
@@ -3958,25 +3789,17 @@
|
|
|
3958
3789
|
} // Range of acceptable acceleration values.
|
|
3959
3790
|
|
|
3960
3791
|
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
acceleration = L.Util.formatNum(acceleration, 2);
|
|
3967
|
-
if (acceleration > sMax) sMax = acceleration;
|
|
3968
|
-
if (acceleration < sMin) sMin = acceleration;
|
|
3969
|
-
sAvg = (acceleration + sAvg) / 2.0;
|
|
3970
|
-
data[i].acceleration = acceleration;
|
|
3971
|
-
track.acceleration_max = sMax;
|
|
3972
|
-
track.acceleration_min = sMin;
|
|
3973
|
-
track.acceleration_avg = sAvg;
|
|
3792
|
+
acceleration = clamp(acceleration, this.options.accelerationRange);
|
|
3793
|
+
track.acceleration_max = acceleration > sMax ? acceleration : sMax;
|
|
3794
|
+
track.acceleration_min = acceleration < sMin ? acceleration : sMin;
|
|
3795
|
+
track.acceleration_avg = (acceleration + sAvg) / 2.0;
|
|
3796
|
+
data[i].acceleration = L.Util.formatNum(acceleration, 2);
|
|
3974
3797
|
});
|
|
3975
3798
|
|
|
3976
|
-
this.
|
|
3799
|
+
this._registerTooltip({
|
|
3977
3800
|
name: 'acceleration',
|
|
3978
3801
|
chart: function chart(item) {
|
|
3979
|
-
return item.acceleration + " " + acceleration.label;
|
|
3802
|
+
return L._("a: ") + item.acceleration + " " + acceleration.label;
|
|
3980
3803
|
},
|
|
3981
3804
|
marker: function marker(item) {
|
|
3982
3805
|
return Math.round(item.acceleration) + " " + acceleration.label;
|
|
@@ -4043,6 +3866,19 @@
|
|
|
4043
3866
|
Elevation.Utils = _;
|
|
4044
3867
|
Elevation.Components = D3;
|
|
4045
3868
|
Elevation.Chart = Chart$1;
|
|
3869
|
+
/* Temporary fix for empty values evaluated as false (leaflet-i18n v0.3.1) */
|
|
3870
|
+
|
|
3871
|
+
(function () {
|
|
3872
|
+
var proto = L.i18n.bind({});
|
|
3873
|
+
|
|
3874
|
+
L.i18n = L._ = function (string, data) {
|
|
3875
|
+
if (L.locale && L.locales[L.locale] && L.locales[L.locale][string] == "") {
|
|
3876
|
+
L.locales[L.locale][string] = "\u200B";
|
|
3877
|
+
}
|
|
3878
|
+
|
|
3879
|
+
return proto.call(null, string, data);
|
|
3880
|
+
};
|
|
3881
|
+
})();
|
|
4046
3882
|
|
|
4047
3883
|
L.control.elevation = function (options) {
|
|
4048
3884
|
return new Elevation(options);
|