@raruto/leaflet-elevation 1.7.4 → 1.8.0
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.js +637 -847
- package/dist/leaflet-elevation.js.map +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 +55 -175
- package/src/components.js +159 -111
- package/src/control.js +115 -209
- package/src/distance.js +15 -13
- 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 +113 -137
|
@@ -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;
|
|
@@ -172,8 +147,9 @@
|
|
|
172
147
|
} : L.extend({
|
|
173
148
|
lazy: true
|
|
174
149
|
}, control.options.distanceMarkers);
|
|
175
|
-
var
|
|
176
|
-
|
|
150
|
+
var _control$options = control.options,
|
|
151
|
+
wptIcons = _control$options.wptIcons,
|
|
152
|
+
wptLabels = _control$options.wptLabels;
|
|
177
153
|
var layer = L.geoJson(data, {
|
|
178
154
|
distanceMarkers: distanceMarkers,
|
|
179
155
|
style: function style(feature) {
|
|
@@ -192,23 +168,17 @@
|
|
|
192
168
|
var prop = feature.properties;
|
|
193
169
|
var desc = (_prop$desc = prop.desc) !== null && _prop$desc !== void 0 ? _prop$desc : '';
|
|
194
170
|
var name = (_prop$name = prop.name) !== null && _prop$name !== void 0 ? _prop$name : '';
|
|
195
|
-
var sym = ((_prop$sym = prop.sym) !== null && _prop$sym !== void 0 ? _prop$sym : name).replace(' ', '-').replace('"', '').replace("'", '').toLowerCase(); // Handle
|
|
196
|
-
|
|
197
|
-
if (!wptLabels) {
|
|
198
|
-
name = '';
|
|
199
|
-
desc = '';
|
|
200
|
-
} // Handle chart waypoints (dots)
|
|
171
|
+
var sym = ((_prop$sym = prop.sym) !== null && _prop$sym !== void 0 ? _prop$sym : name).replace(' ', '-').replace('"', '').replace("'", '').toLowerCase(); // Handle chart waypoints (dots)
|
|
201
172
|
|
|
202
|
-
|
|
203
|
-
if ([true, "dots"].includes(control.options.waypoints)) {
|
|
173
|
+
if ([true, 'dots'].includes(control.options.waypoints)) {
|
|
204
174
|
control._registerCheckPoint({
|
|
205
175
|
latlng: latlng,
|
|
206
|
-
label: name
|
|
176
|
+
label: [true, 'dots'].includes(wptLabels) ? name : ''
|
|
207
177
|
}, true);
|
|
208
178
|
} // Handle map waypoints (markers)
|
|
209
179
|
|
|
210
180
|
|
|
211
|
-
if ([true,
|
|
181
|
+
if ([true, 'markers'].includes(control.options.waypoints) && wptIcons != false) {
|
|
212
182
|
// generate and cache appropriate icon symbol
|
|
213
183
|
if (!wptIcons.hasOwnProperty(sym)) {
|
|
214
184
|
wptIcons[sym] = L.divIcon(L.extend({}, wptIcons[""].options, {
|
|
@@ -220,7 +190,7 @@
|
|
|
220
190
|
icon: wptIcons[sym]
|
|
221
191
|
});
|
|
222
192
|
|
|
223
|
-
if (name || desc) {
|
|
193
|
+
if ([true, 'markers'].includes(wptLabels) && (name || desc)) {
|
|
224
194
|
marker.bindPopup("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : '')).openPopup();
|
|
225
195
|
}
|
|
226
196
|
|
|
@@ -288,13 +258,6 @@
|
|
|
288
258
|
|
|
289
259
|
return layer;
|
|
290
260
|
}
|
|
291
|
-
/**
|
|
292
|
-
* Check DOM element visibility.
|
|
293
|
-
*/
|
|
294
|
-
|
|
295
|
-
function isDomVisible(elem) {
|
|
296
|
-
return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
|
|
297
|
-
}
|
|
298
261
|
/**
|
|
299
262
|
* Check object type.
|
|
300
263
|
*/
|
|
@@ -302,40 +265,6 @@
|
|
|
302
265
|
function isObject(item) {
|
|
303
266
|
return item && _typeof(item) === 'object' && !Array.isArray(item);
|
|
304
267
|
}
|
|
305
|
-
/**
|
|
306
|
-
* Check DOM element viewport visibility.
|
|
307
|
-
*/
|
|
308
|
-
|
|
309
|
-
function isVisible(elem) {
|
|
310
|
-
if (!elem) return false;
|
|
311
|
-
var styles = window.getComputedStyle(elem);
|
|
312
|
-
|
|
313
|
-
function isVisibleByStyles(elem, styles) {
|
|
314
|
-
return styles.visibility !== 'hidden' && styles.display !== 'none';
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function isAboveOtherElements(elem, styles) {
|
|
318
|
-
var boundingRect = elem.getBoundingClientRect();
|
|
319
|
-
var left = boundingRect.left + 1;
|
|
320
|
-
var right = boundingRect.right - 1;
|
|
321
|
-
var top = boundingRect.top + 1;
|
|
322
|
-
var bottom = boundingRect.bottom - 1;
|
|
323
|
-
var above = true;
|
|
324
|
-
var pointerEvents = elem.style.pointerEvents;
|
|
325
|
-
if (styles['pointer-events'] == 'none') elem.style.pointerEvents = 'auto';
|
|
326
|
-
if (document.elementFromPoint(left, top) !== elem) above = false;
|
|
327
|
-
if (document.elementFromPoint(right, top) !== elem) above = false; // Only for completely visible elements
|
|
328
|
-
// if (document.elementFromPoint(left, bottom) !== elem) above = false;
|
|
329
|
-
// if (document.elementFromPoint(right, bottom) !== elem) above = false;
|
|
330
|
-
|
|
331
|
-
elem.style.pointerEvents = pointerEvents;
|
|
332
|
-
return above;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (!isVisibleByStyles(elem, styles)) return false;
|
|
336
|
-
if (!isAboveOtherElements(elem, styles)) return false;
|
|
337
|
-
return true;
|
|
338
|
-
}
|
|
339
268
|
/**
|
|
340
269
|
* Check JSON object type.
|
|
341
270
|
*/
|
|
@@ -373,6 +302,22 @@
|
|
|
373
302
|
return documentElement ? documentElement.nodeName !== "HTML" : false;
|
|
374
303
|
}
|
|
375
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
|
+
}
|
|
376
321
|
/**
|
|
377
322
|
* Async JS script download.
|
|
378
323
|
*/
|
|
@@ -395,50 +340,69 @@
|
|
|
395
340
|
document.head.appendChild(tag);
|
|
396
341
|
});
|
|
397
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
|
+
}
|
|
398
377
|
/**
|
|
399
|
-
*
|
|
378
|
+
* Convert SVG Path into Path2D and then update canvas
|
|
400
379
|
*/
|
|
401
380
|
|
|
402
|
-
function
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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();
|
|
413
398
|
}
|
|
414
399
|
/**
|
|
415
|
-
*
|
|
400
|
+
* Limit a number between min / max values
|
|
416
401
|
*/
|
|
417
402
|
|
|
418
|
-
function
|
|
419
|
-
return
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
var scrollFn = function scrollFn() {
|
|
423
|
-
if (!ticking) {
|
|
424
|
-
L.Util.requestAnimFrame(function () {
|
|
425
|
-
if (isVisible(elem)) {
|
|
426
|
-
window.removeEventListener('scroll', scrollFn);
|
|
427
|
-
resolve();
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
ticking = false;
|
|
431
|
-
});
|
|
432
|
-
ticking = true;
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
window.addEventListener('scroll', scrollFn);
|
|
437
|
-
if (elem) elem.addEventListener('mouseenter', scrollFn, {
|
|
438
|
-
once: true
|
|
439
|
-
});
|
|
440
|
-
scrollFn();
|
|
441
|
-
});
|
|
403
|
+
function clamp(val, range) {
|
|
404
|
+
if (range) return val < range[0] ? range[0] : val > range[1] ? range[1] : val;
|
|
405
|
+
return val;
|
|
442
406
|
}
|
|
443
407
|
/**
|
|
444
408
|
* A little bit safier than L.DomUtil.addClass
|
|
@@ -529,9 +493,17 @@
|
|
|
529
493
|
*/
|
|
530
494
|
|
|
531
495
|
var hasClass = L.DomUtil.hasClass;
|
|
496
|
+
/**
|
|
497
|
+
* Generate a random string
|
|
498
|
+
*/
|
|
499
|
+
|
|
532
500
|
function randomId() {
|
|
533
501
|
return Math.random().toString(36).substr(2, 9);
|
|
534
502
|
}
|
|
503
|
+
/**
|
|
504
|
+
* Execute a function foreach element in object
|
|
505
|
+
*/
|
|
506
|
+
|
|
535
507
|
function each(obj, fn) {
|
|
536
508
|
for (var i in obj) {
|
|
537
509
|
fn(obj[i], i);
|
|
@@ -541,18 +513,16 @@
|
|
|
541
513
|
var _ = /*#__PURE__*/Object.freeze({
|
|
542
514
|
__proto__: null,
|
|
543
515
|
deepMerge: deepMerge,
|
|
544
|
-
deferFunc: deferFunc,
|
|
545
|
-
debounce: debounce,
|
|
546
516
|
formatTime: formatTime,
|
|
547
517
|
GeoJSONLoader: GeoJSONLoader,
|
|
548
|
-
isDomVisible: isDomVisible,
|
|
549
518
|
isObject: isObject,
|
|
550
|
-
isVisible: isVisible,
|
|
551
519
|
isJSONDoc: isJSONDoc,
|
|
552
520
|
isXMLDoc: isXMLDoc,
|
|
553
|
-
lazyLoader: lazyLoader,
|
|
554
521
|
saveFile: saveFile,
|
|
555
|
-
|
|
522
|
+
lazyLoader: lazyLoader,
|
|
523
|
+
lazyLoad: lazyLoad,
|
|
524
|
+
drawCanvas: drawCanvas,
|
|
525
|
+
clamp: clamp,
|
|
556
526
|
addClass: addClass,
|
|
557
527
|
removeClass: removeClass,
|
|
558
528
|
toggleClass: toggleClass,
|
|
@@ -677,58 +647,59 @@
|
|
|
677
647
|
props.type = "grid";
|
|
678
648
|
return Axis(props);
|
|
679
649
|
};
|
|
680
|
-
var
|
|
650
|
+
var PositionMarker = function PositionMarker(_ref4) {
|
|
681
651
|
var theme = _ref4.theme,
|
|
682
652
|
_ref4$xCoord = _ref4.xCoord,
|
|
683
653
|
xCoord = _ref4$xCoord === void 0 ? 0 : _ref4$xCoord,
|
|
684
654
|
_ref4$yCoord = _ref4.yCoord,
|
|
685
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,
|
|
686
660
|
_ref4$length = _ref4.length,
|
|
687
661
|
length = _ref4$length === void 0 ? 0 : _ref4$length;
|
|
688
|
-
return function (
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
var
|
|
702
|
-
|
|
703
|
-
|
|
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");
|
|
704
686
|
text.selectAll('tspan').attr("x", xCoord + 5);
|
|
705
|
-
return
|
|
706
|
-
};
|
|
707
|
-
};
|
|
708
|
-
var HeightFocusMarker = function HeightFocusMarker(_ref6) {
|
|
709
|
-
var theme = _ref6.theme,
|
|
710
|
-
_ref6$xCoord = _ref6.xCoord,
|
|
711
|
-
xCoord = _ref6$xCoord === void 0 ? 0 : _ref6$xCoord,
|
|
712
|
-
_ref6$yCoord = _ref6.yCoord,
|
|
713
|
-
yCoord = _ref6$yCoord === void 0 ? 0 : _ref6$yCoord;
|
|
714
|
-
return function (circle) {
|
|
715
|
-
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;
|
|
716
688
|
};
|
|
717
689
|
};
|
|
718
|
-
var LegendItem = function LegendItem(
|
|
719
|
-
var name =
|
|
720
|
-
label =
|
|
721
|
-
width =
|
|
722
|
-
height =
|
|
723
|
-
|
|
724
|
-
margins =
|
|
725
|
-
color =
|
|
726
|
-
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;
|
|
727
699
|
return function (g) {
|
|
728
700
|
g.attr("class", "legend-item legend-" + name.toLowerCase()).attr("data-name", name);
|
|
729
|
-
var svg = d3.select(g.node().ownerSVGElement || g);
|
|
730
701
|
g.on('click.legend', function () {
|
|
731
|
-
return
|
|
702
|
+
return d3.select(g.node().ownerSVGElement || g).dispatch("legend_clicked", {
|
|
732
703
|
detail: {
|
|
733
704
|
path: path.node(),
|
|
734
705
|
name: name,
|
|
@@ -742,34 +713,24 @@
|
|
|
742
713
|
return g;
|
|
743
714
|
};
|
|
744
715
|
};
|
|
745
|
-
var
|
|
746
|
-
var
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
var xCoord = _ref9.xCoord,
|
|
755
|
-
yCoord = _ref9.yCoord,
|
|
756
|
-
_ref9$labelX = _ref9.labelX,
|
|
757
|
-
labelX = _ref9$labelX === void 0 ? "" : _ref9$labelX,
|
|
758
|
-
_ref9$labelY = _ref9.labelY,
|
|
759
|
-
labelY = _ref9$labelY === void 0 ? "" : _ref9$labelY,
|
|
760
|
-
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;
|
|
761
725
|
return function (g) {
|
|
762
|
-
g.
|
|
763
|
-
var
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
var
|
|
767
|
-
|
|
768
|
-
if (!
|
|
769
|
-
if (!
|
|
770
|
-
if (!x.node()) x = text.append("svg:tspan");
|
|
771
|
-
y.text(labelY);
|
|
772
|
-
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
|
|
773
734
|
|
|
774
735
|
var xAlign = 0;
|
|
775
736
|
var yAlign = 0;
|
|
@@ -786,17 +747,30 @@
|
|
|
786
747
|
|
|
787
748
|
if (xCoord) xAlign = xCoord + (xCoord < width / 2 ? 10 : -bbox.width - 10);
|
|
788
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');
|
|
789
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);
|
|
790
753
|
text.attr("class", "mouse-focus-label-text").style("font-weight", "700").attr("y", yAlign);
|
|
791
|
-
|
|
792
|
-
|
|
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");
|
|
793
767
|
text.selectAll('tspan').attr("x", xAlign);
|
|
794
768
|
return g;
|
|
795
769
|
};
|
|
796
770
|
};
|
|
797
|
-
var Ruler = function Ruler(
|
|
798
|
-
var height =
|
|
799
|
-
width =
|
|
771
|
+
var Ruler = function Ruler(_ref7) {
|
|
772
|
+
var height = _ref7.height,
|
|
773
|
+
width = _ref7.width;
|
|
800
774
|
return function (g) {
|
|
801
775
|
g.data([{
|
|
802
776
|
"x": 0,
|
|
@@ -843,13 +817,64 @@
|
|
|
843
817
|
return g;
|
|
844
818
|
};
|
|
845
819
|
};
|
|
846
|
-
var
|
|
847
|
-
var
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
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;
|
|
853
878
|
return function (data) {
|
|
854
879
|
attr = attr || name;
|
|
855
880
|
if (scale && scale.attr) attr = scale.attr;
|
|
@@ -868,19 +893,19 @@
|
|
|
868
893
|
return domain;
|
|
869
894
|
};
|
|
870
895
|
};
|
|
871
|
-
var Range = function Range(
|
|
872
|
-
var axis =
|
|
896
|
+
var Range = function Range(_ref10) {
|
|
897
|
+
var axis = _ref10.axis;
|
|
873
898
|
return function (width, height) {
|
|
874
899
|
if (axis == 'x') return [0, width];else if (axis == 'y') return [height, 0];
|
|
875
900
|
};
|
|
876
901
|
};
|
|
877
|
-
var Scale = function Scale(
|
|
878
|
-
var data =
|
|
879
|
-
attr =
|
|
880
|
-
min =
|
|
881
|
-
max =
|
|
882
|
-
forceBounds =
|
|
883
|
-
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;
|
|
884
909
|
return d3.scaleLinear().range(range).domain(Domain({
|
|
885
910
|
min: min,
|
|
886
911
|
max: max,
|
|
@@ -888,22 +913,22 @@
|
|
|
888
913
|
forceBounds: forceBounds
|
|
889
914
|
})(data));
|
|
890
915
|
};
|
|
891
|
-
var Bisect = function Bisect(
|
|
892
|
-
var
|
|
893
|
-
data =
|
|
894
|
-
scale =
|
|
895
|
-
x =
|
|
896
|
-
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;
|
|
897
922
|
return d3.bisector(function (d) {
|
|
898
923
|
return d[attr];
|
|
899
924
|
}).left(data, scale.invert(x));
|
|
900
925
|
};
|
|
901
|
-
var Chart = function Chart(
|
|
902
|
-
var width =
|
|
903
|
-
height =
|
|
904
|
-
|
|
905
|
-
margins =
|
|
906
|
-
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;
|
|
907
932
|
|
|
908
933
|
var _width = width - margins.left - margins.right;
|
|
909
934
|
|
|
@@ -929,26 +954,18 @@
|
|
|
929
954
|
|
|
930
955
|
var foreignObject = panes.area.append('svg:foreignObject');
|
|
931
956
|
var canvas = foreignObject.append('xhtml:canvas').attr('class', 'canvas-plot');
|
|
932
|
-
var context = canvas.node().getContext('2d'); //
|
|
957
|
+
var context = canvas.node().getContext('2d'); // Add tooltip
|
|
933
958
|
|
|
934
|
-
|
|
935
|
-
var focusG = panes.tooltip;
|
|
936
|
-
var brushG = panes.brush;
|
|
937
|
-
focusG.append('svg:line').call(MouseFocusLine({
|
|
938
|
-
xCoord: 0,
|
|
939
|
-
height: _height
|
|
940
|
-
}));
|
|
941
|
-
focusG.append("g").call(MouseFocusLabel({
|
|
959
|
+
panes.tooltip.call(Tooltip({
|
|
942
960
|
xCoord: 0,
|
|
943
961
|
yCoord: 0,
|
|
944
962
|
height: _height,
|
|
945
963
|
width: _width,
|
|
946
|
-
|
|
947
|
-
labelY: ""
|
|
964
|
+
labels: {}
|
|
948
965
|
})); // Add the brushing
|
|
949
966
|
|
|
950
967
|
var brush = d3.brushX().on('start.cursor end.cursor brush.cursor', function () {
|
|
951
|
-
return
|
|
968
|
+
return panes.brush.select(".overlay").attr('cursor', null);
|
|
952
969
|
}); // Scales
|
|
953
970
|
|
|
954
971
|
var scale = function scale(opts) {
|
|
@@ -962,8 +979,6 @@
|
|
|
962
979
|
clipPath: clipPath,
|
|
963
980
|
canvas: canvas,
|
|
964
981
|
context: context,
|
|
965
|
-
dragG: dragG,
|
|
966
|
-
focusG: focusG,
|
|
967
982
|
brush: brush
|
|
968
983
|
};
|
|
969
984
|
var chart = {
|
|
@@ -974,12 +989,12 @@
|
|
|
974
989
|
scale: scale
|
|
975
990
|
}; // Resize
|
|
976
991
|
|
|
977
|
-
chart._resize = function (
|
|
978
|
-
var width =
|
|
979
|
-
height =
|
|
980
|
-
|
|
981
|
-
margins =
|
|
982
|
-
ruler =
|
|
992
|
+
chart._resize = function (_ref14) {
|
|
993
|
+
var width = _ref14.width,
|
|
994
|
+
height = _ref14.height,
|
|
995
|
+
_ref14$margins = _ref14.margins,
|
|
996
|
+
margins = _ref14$margins === void 0 ? {} : _ref14$margins,
|
|
997
|
+
ruler = _ref14.ruler;
|
|
983
998
|
|
|
984
999
|
var _width = width - margins.left - margins.right;
|
|
985
1000
|
|
|
@@ -997,14 +1012,14 @@
|
|
|
997
1012
|
canvas.attr('width', _width).attr('height', _height);
|
|
998
1013
|
|
|
999
1014
|
if (ruler) {
|
|
1000
|
-
|
|
1015
|
+
panes.ruler.call(Ruler({
|
|
1001
1016
|
height: _height,
|
|
1002
1017
|
width: _width
|
|
1003
1018
|
}));
|
|
1004
1019
|
}
|
|
1005
1020
|
|
|
1006
|
-
|
|
1007
|
-
|
|
1021
|
+
panes.brush.call(brush.extent([[0, 0], [_width, _height]]));
|
|
1022
|
+
panes.brush.select(".overlay").attr('cursor', null);
|
|
1008
1023
|
chart._width = _width;
|
|
1009
1024
|
chart._height = _height;
|
|
1010
1025
|
chart.svg.dispatch('resize', {
|
|
@@ -1043,13 +1058,11 @@
|
|
|
1043
1058
|
Path: Path,
|
|
1044
1059
|
Axis: Axis,
|
|
1045
1060
|
Grid: Grid,
|
|
1046
|
-
|
|
1047
|
-
HeightFocusLabel: HeightFocusLabel,
|
|
1048
|
-
HeightFocusMarker: HeightFocusMarker,
|
|
1061
|
+
PositionMarker: PositionMarker,
|
|
1049
1062
|
LegendItem: LegendItem,
|
|
1050
|
-
|
|
1051
|
-
MouseFocusLabel: MouseFocusLabel,
|
|
1063
|
+
Tooltip: Tooltip,
|
|
1052
1064
|
Ruler: Ruler,
|
|
1065
|
+
CheckPoint: CheckPoint,
|
|
1053
1066
|
Domain: Domain,
|
|
1054
1067
|
Range: Range,
|
|
1055
1068
|
Scale: Scale,
|
|
@@ -1071,7 +1084,7 @@
|
|
|
1071
1084
|
grids: {},
|
|
1072
1085
|
axes: {},
|
|
1073
1086
|
legendItems: {},
|
|
1074
|
-
|
|
1087
|
+
tooltipItems: {}
|
|
1075
1088
|
};
|
|
1076
1089
|
this._scales = {};
|
|
1077
1090
|
this._domains = {};
|
|
@@ -1079,15 +1092,6 @@
|
|
|
1079
1092
|
this._paths = {};
|
|
1080
1093
|
this._brushEnabled = opts.dragging;
|
|
1081
1094
|
this._zoomEnabled = opts.zooming;
|
|
1082
|
-
|
|
1083
|
-
if (opts.imperial) {
|
|
1084
|
-
this._xLabel = "mi";
|
|
1085
|
-
this._yLabel = "ft";
|
|
1086
|
-
} else {
|
|
1087
|
-
this._xLabel = opts.xLabel;
|
|
1088
|
-
this._yLabel = opts.yLabel;
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
1095
|
var chart = this._chart = Chart(opts); // SVG Container
|
|
1092
1096
|
|
|
1093
1097
|
var svg = this._container = chart.svg; // Panes
|
|
@@ -1096,20 +1100,16 @@
|
|
|
1096
1100
|
this._area = chart.pane('area');
|
|
1097
1101
|
this._point = chart.pane('point');
|
|
1098
1102
|
this._axis = chart.pane('axis');
|
|
1099
|
-
this._legend = chart.pane('legend');
|
|
1103
|
+
this._legend = chart.pane('legend');
|
|
1104
|
+
this._tooltip = chart.pane('tooltip');
|
|
1105
|
+
this._ruler = chart.pane('ruler'); // Scales
|
|
1100
1106
|
|
|
1101
1107
|
this._initScale(); // Helpers
|
|
1102
1108
|
|
|
1103
1109
|
|
|
1104
1110
|
this._clipPath = chart.get('clipPath');
|
|
1105
|
-
this._canvas = chart.get('canvas');
|
|
1106
1111
|
this._context = chart.get('context');
|
|
1107
|
-
this.
|
|
1108
|
-
this._focusG = chart.get('focusG');
|
|
1109
|
-
this._brush = chart.get('brush'); // Tooltip
|
|
1110
|
-
|
|
1111
|
-
this._focusline = this._focusG.select('.mouse-focus-line');
|
|
1112
|
-
this._focuslabel = this._focusG.select('.mouse-focus-label');
|
|
1112
|
+
this._brush = chart.get('brush');
|
|
1113
1113
|
this._zoom = d3.zoom();
|
|
1114
1114
|
this._drag = d3.drag(); // Interactions
|
|
1115
1115
|
|
|
@@ -1150,52 +1150,28 @@
|
|
|
1150
1150
|
|
|
1151
1151
|
this._area.selectAll('path').attr("d", "M0 0");
|
|
1152
1152
|
|
|
1153
|
-
this._context.clearRect(0, 0, this._width(), this._height());
|
|
1153
|
+
this._context.clearRect(0, 0, this._width(), this._height()); // if (this._path) {
|
|
1154
|
+
// this._x.domain([0, 1]);
|
|
1155
|
+
// this._y.domain([0, 1]);
|
|
1156
|
+
// }
|
|
1154
1157
|
|
|
1155
|
-
if (this._path) ;
|
|
1156
1158
|
},
|
|
1157
1159
|
_drawPath: function _drawPath(name) {
|
|
1158
|
-
var opts = this.options;
|
|
1159
|
-
var ctx = this._context;
|
|
1160
1160
|
var path = this._paths[name];
|
|
1161
1161
|
var area = this._props.areas[name];
|
|
1162
|
-
|
|
1163
|
-
var scaleX = this._scales[area.scaleX];
|
|
1164
|
-
var scaleY = this._scales[area.scaleY];
|
|
1165
|
-
area = L.extend({}, area, {
|
|
1162
|
+
path.datum(this._data).attr("d", Area(L.extend({}, area, {
|
|
1166
1163
|
width: this._width(),
|
|
1167
1164
|
height: this._height(),
|
|
1168
|
-
scaleX: scaleX,
|
|
1169
|
-
scaleY: scaleY
|
|
1170
|
-
});
|
|
1171
|
-
|
|
1172
|
-
if (!scaleY || !scaleY) {
|
|
1173
|
-
return console.warn('Unable to render path:' + name);
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
path.datum(this._data).attr("d", Area(area));
|
|
1165
|
+
scaleX: this._scales[area.scaleX],
|
|
1166
|
+
scaleY: this._scales[area.scaleY]
|
|
1167
|
+
})));
|
|
1177
1168
|
if (path.classed('leaflet-hidden')) return;
|
|
1178
1169
|
|
|
1179
|
-
if (
|
|
1180
|
-
|
|
1181
|
-
ctx.beginPath();
|
|
1182
|
-
ctx.moveTo(0, 0);
|
|
1183
|
-
var p = new Path2D(path.attr('d'));
|
|
1184
|
-
ctx.strokeStyle = path.attr('stroke');
|
|
1185
|
-
ctx.fillStyle = path.attr('fill');
|
|
1186
|
-
ctx.lineWidth = 1.25;
|
|
1187
|
-
ctx.globalCompositeOperation = 'source-over'; // stroke opacity
|
|
1188
|
-
|
|
1189
|
-
ctx.globalAlpha = path.attr('stroke-opacity') || 0.3;
|
|
1190
|
-
ctx.stroke(p); // fill opacity
|
|
1191
|
-
|
|
1192
|
-
ctx.globalAlpha = path.attr('fill-opacity') || 0.45;
|
|
1193
|
-
ctx.fill(p);
|
|
1194
|
-
ctx.globalAlpha = 1;
|
|
1195
|
-
ctx.closePath();
|
|
1170
|
+
if (this.options.preferCanvas) {
|
|
1171
|
+
drawCanvas(this._context, path);
|
|
1196
1172
|
} else {
|
|
1197
1173
|
this._area.append(function () {
|
|
1198
|
-
return node;
|
|
1174
|
+
return path.node();
|
|
1199
1175
|
});
|
|
1200
1176
|
}
|
|
1201
1177
|
},
|
|
@@ -1370,9 +1346,9 @@
|
|
|
1370
1346
|
var label = function label(e, d) {
|
|
1371
1347
|
var yMax = _this5._height();
|
|
1372
1348
|
|
|
1373
|
-
var y = _this5.
|
|
1349
|
+
var y = _this5._ruler.data()[0].y;
|
|
1374
1350
|
|
|
1375
|
-
if (y >= yMax || y <= 0) _this5.
|
|
1351
|
+
if (y >= yMax || y <= 0) _this5._ruler.select(".horizontal-drag-label").text('');
|
|
1376
1352
|
|
|
1377
1353
|
_this5._hideDiagramIndicator();
|
|
1378
1354
|
};
|
|
@@ -1385,15 +1361,15 @@
|
|
|
1385
1361
|
|
|
1386
1362
|
var z = _this5._y.invert(y);
|
|
1387
1363
|
|
|
1388
|
-
var data = L.extend(_this5.
|
|
1364
|
+
var data = L.extend(_this5._ruler.data()[0], {
|
|
1389
1365
|
y: y
|
|
1390
1366
|
});
|
|
1391
1367
|
|
|
1392
|
-
_this5.
|
|
1368
|
+
_this5._ruler.data([data]).attr("transform", function (d) {
|
|
1393
1369
|
return "translate(" + d.x + "," + d.y + ")";
|
|
1394
1370
|
}).classed('active', y < yMax);
|
|
1395
1371
|
|
|
1396
|
-
_this5._container.select(".horizontal-drag-label").text(formatNum(z) + " " + _this5.
|
|
1372
|
+
_this5._container.select(".horizontal-drag-label").text(formatNum(z) + " " + (_this5.options.imperial ? 'ft' : 'm'));
|
|
1397
1373
|
|
|
1398
1374
|
_this5.fire('ruler_filter', {
|
|
1399
1375
|
coords: yCoord < yMax && yCoord > 0 ? _this5._findCoordsForY(yCoord) : []
|
|
@@ -1402,7 +1378,7 @@
|
|
|
1402
1378
|
|
|
1403
1379
|
drag.on("start end", label).on("drag", position);
|
|
1404
1380
|
|
|
1405
|
-
this.
|
|
1381
|
+
this._ruler.call(drag);
|
|
1406
1382
|
},
|
|
1407
1383
|
|
|
1408
1384
|
/**
|
|
@@ -1481,7 +1457,7 @@
|
|
|
1481
1457
|
},
|
|
1482
1458
|
|
|
1483
1459
|
/**
|
|
1484
|
-
* Add a
|
|
1460
|
+
* Add a point of interest over the chart
|
|
1485
1461
|
*/
|
|
1486
1462
|
_registerCheckPoint: function _registerCheckPoint(point) {
|
|
1487
1463
|
if (!this._data.length) return;
|
|
@@ -1495,49 +1471,18 @@
|
|
|
1495
1471
|
x = this._x(point.dist);
|
|
1496
1472
|
item = this._data[this._findIndexForXCoord(x)];
|
|
1497
1473
|
y = this._y(item.z);
|
|
1498
|
-
} else if (isNaN(x) || isNaN(y)) return;
|
|
1499
|
-
|
|
1500
|
-
if (!point.item || !point.item.property('isConnected')) {
|
|
1501
|
-
point.position = point.position || "bottom";
|
|
1502
|
-
point.item = this._point.append('g');
|
|
1503
|
-
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;");
|
|
1504
|
-
point.item.append("svg:circle").attr("class", " height-focus circle-lower").attr("r", 3);
|
|
1505
|
-
|
|
1506
|
-
if (point.label) {
|
|
1507
|
-
point.item.append("svg:text").attr("dx", "4px").attr("dy", "-4px");
|
|
1508
|
-
}
|
|
1509
1474
|
}
|
|
1510
1475
|
|
|
1511
|
-
|
|
1512
|
-
|
|
1476
|
+
this._point.call(CheckPoint({
|
|
1477
|
+
point: point,
|
|
1478
|
+
width: this._width(),
|
|
1479
|
+
height: this._height(),
|
|
1513
1480
|
x: x,
|
|
1514
1481
|
y: y
|
|
1515
|
-
})
|
|
1516
|
-
return "point " + d.pos;
|
|
1517
|
-
}).attr("transform", function (d) {
|
|
1518
|
-
return "translate(" + d.x + "," + d.y + ")";
|
|
1519
|
-
});
|
|
1520
|
-
point.item.select('line').datum({
|
|
1521
|
-
y2: {
|
|
1522
|
-
'top': -y,
|
|
1523
|
-
'bottom': this._height() - y
|
|
1524
|
-
}[point.position],
|
|
1525
|
-
x2: {
|
|
1526
|
-
'left': -x,
|
|
1527
|
-
'right': this._width() - x
|
|
1528
|
-
}[point.position] || 0
|
|
1529
|
-
}).attr("y2", function (d) {
|
|
1530
|
-
return d.y2;
|
|
1531
|
-
}).attr("x2", function (d) {
|
|
1532
|
-
return d.x2;
|
|
1533
|
-
});
|
|
1534
|
-
|
|
1535
|
-
if (point.label) {
|
|
1536
|
-
point.item.select('text').text(point.label);
|
|
1537
|
-
}
|
|
1482
|
+
}));
|
|
1538
1483
|
},
|
|
1539
|
-
|
|
1540
|
-
this._props.
|
|
1484
|
+
_registerTooltip: function _registerTooltip(props) {
|
|
1485
|
+
this._props.tooltipItems[props.name] = props;
|
|
1541
1486
|
},
|
|
1542
1487
|
_updateArea: function _updateArea() {
|
|
1543
1488
|
var paths = this._paths; // Reset and update chart profiles
|
|
@@ -1607,7 +1552,7 @@
|
|
|
1607
1552
|
_updateLegend: function _updateLegend() {
|
|
1608
1553
|
var _this6 = this;
|
|
1609
1554
|
|
|
1610
|
-
if (this.options.legend
|
|
1555
|
+
if (this.options.legend === false) return;
|
|
1611
1556
|
var legends = this._props.legendItems;
|
|
1612
1557
|
var legend; // Reset legend items
|
|
1613
1558
|
|
|
@@ -1684,13 +1629,9 @@
|
|
|
1684
1629
|
x: this._x,
|
|
1685
1630
|
y: this._y
|
|
1686
1631
|
};
|
|
1687
|
-
var opts = this.options;
|
|
1688
|
-
var scales = this._scales;
|
|
1689
|
-
var d = this._domains;
|
|
1690
|
-
var r = this._ranges;
|
|
1691
1632
|
|
|
1692
|
-
for (var i in
|
|
1693
|
-
|
|
1633
|
+
for (var i in this._scales) {
|
|
1634
|
+
this._scales[i].domain(this._domains[i](this._data)).range(this._ranges[i](this._width(), this._height()));
|
|
1694
1635
|
}
|
|
1695
1636
|
|
|
1696
1637
|
return {
|
|
@@ -1796,47 +1737,17 @@
|
|
|
1796
1737
|
* Display distance and altitude level ("focus-rect").
|
|
1797
1738
|
*/
|
|
1798
1739
|
_showDiagramIndicator: function _showDiagramIndicator(item, xCoordinate) {
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
var yCoordinate = this._y(item[opts.yAttr]);
|
|
1802
|
-
|
|
1803
|
-
this._focusG.attr("display", null);
|
|
1804
|
-
|
|
1805
|
-
this._focusline.call(MouseFocusLine({
|
|
1806
|
-
xCoord: xCoordinate,
|
|
1807
|
-
height: this._height()
|
|
1808
|
-
}));
|
|
1809
|
-
|
|
1810
|
-
this._focuslabel.call(MouseFocusLabel({
|
|
1740
|
+
this._tooltip.attr("display", null).call(Tooltip({
|
|
1811
1741
|
xCoord: xCoordinate,
|
|
1812
|
-
yCoord:
|
|
1742
|
+
yCoord: this._y(item[this.options.yAttr]),
|
|
1813
1743
|
height: this._height(),
|
|
1814
1744
|
width: this._width(),
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
}));
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
var labels = this._props.focusLabels;
|
|
1821
|
-
|
|
1822
|
-
var tooltip = this._focuslabel.select('text');
|
|
1823
|
-
|
|
1824
|
-
var label;
|
|
1825
|
-
|
|
1826
|
-
for (var i in labels) {
|
|
1827
|
-
label = tooltip.select(".mouse-focus-label-" + labels[i].name);
|
|
1828
|
-
|
|
1829
|
-
if (!label.size()) {
|
|
1830
|
-
label = tooltip.append("svg:tspan", ".mouse-focus-label-x").attr("class", "mouse-focus-label-" + labels[i].name).attr("dy", "1.5em");
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
label.text(typeof labels[i].value !== "function" ? labels[i].value : labels[i].value(item));
|
|
1834
|
-
|
|
1835
|
-
this._focuslabel.select('.mouse-focus-label-x').attr("dy", "1.5em");
|
|
1836
|
-
}
|
|
1745
|
+
labels: this._props.tooltipItems,
|
|
1746
|
+
item: item
|
|
1747
|
+
}));
|
|
1837
1748
|
},
|
|
1838
1749
|
_hideDiagramIndicator: function _hideDiagramIndicator() {
|
|
1839
|
-
this.
|
|
1750
|
+
this._tooltip.attr("display", 'none');
|
|
1840
1751
|
}
|
|
1841
1752
|
});
|
|
1842
1753
|
|
|
@@ -1844,51 +1755,40 @@
|
|
|
1844
1755
|
initialize: function initialize(options) {
|
|
1845
1756
|
this.options = options;
|
|
1846
1757
|
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
// this._marker = L.circleMarker([0, 0], { pane: 'overlayPane', radius: 6, fillColor: '#fff', fillOpacity:1, color: '#000', weight:1, interactive: false });
|
|
1862
|
-
this._marker = L.marker([0, 0], {
|
|
1863
|
-
icon: this.options.markerIcon,
|
|
1864
|
-
zIndexOffset: 1000000,
|
|
1865
|
-
interactive: false
|
|
1866
|
-
});
|
|
1758
|
+
switch (this.options.marker) {
|
|
1759
|
+
case 'elevation-line':
|
|
1760
|
+
// this._container = d3.create("g").attr("class", "height-focus-group");
|
|
1761
|
+
this._container = d3.select(map.getPane('elevationPane')).select("svg > g").attr("class", "height-focus-group");
|
|
1762
|
+
break;
|
|
1763
|
+
|
|
1764
|
+
case 'position-marker':
|
|
1765
|
+
// this._marker = L.circleMarker([0, 0], { pane: 'overlayPane', radius: 6, fillColor: '#fff', fillOpacity:1, color: '#000', weight:1, interactive: false });
|
|
1766
|
+
this._marker = L.marker([0, 0], {
|
|
1767
|
+
icon: this.options.markerIcon,
|
|
1768
|
+
zIndexOffset: 1000000,
|
|
1769
|
+
interactive: false
|
|
1770
|
+
});
|
|
1771
|
+
break;
|
|
1867
1772
|
}
|
|
1868
1773
|
|
|
1869
|
-
this.
|
|
1774
|
+
this._labels = {};
|
|
1870
1775
|
return this;
|
|
1871
1776
|
},
|
|
1872
1777
|
addTo: function addTo(map) {
|
|
1873
|
-
var _this = this;
|
|
1874
|
-
|
|
1875
1778
|
this._map = map;
|
|
1876
1779
|
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
this._marker.addTo(map, {
|
|
1890
|
-
pane: 'overlayPane'
|
|
1891
|
-
});
|
|
1780
|
+
switch (this.options.marker) {
|
|
1781
|
+
case 'elevation-line':
|
|
1782
|
+
this._container.call(PositionMarker({}));
|
|
1783
|
+
|
|
1784
|
+
break;
|
|
1785
|
+
|
|
1786
|
+
case 'position-marker':
|
|
1787
|
+
this._marker.addTo(map, {
|
|
1788
|
+
pane: 'overlayPane'
|
|
1789
|
+
});
|
|
1790
|
+
|
|
1791
|
+
break;
|
|
1892
1792
|
}
|
|
1893
1793
|
|
|
1894
1794
|
return this;
|
|
@@ -1902,62 +1802,34 @@
|
|
|
1902
1802
|
if (!props) return;
|
|
1903
1803
|
if (props.options) this.options = props.options;
|
|
1904
1804
|
if (!this._map) this.addTo(props.map);
|
|
1905
|
-
var opts = this.options;
|
|
1906
|
-
var map = this._map;
|
|
1907
1805
|
this._latlng = props.item.latlng;
|
|
1908
|
-
var pos = map.latLngToLayerPoint(this._latlng);
|
|
1909
|
-
|
|
1910
|
-
if (map._rotate) {
|
|
1911
|
-
pos = map.rotatedPointToMapPanePoint(pos);
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
var point = L.extend({}, props.item, pos);
|
|
1915
|
-
|
|
1916
|
-
if (this.options.marker == 'elevation-line') {
|
|
1917
|
-
var normalizedAlt = this._height() / props.maxElevation * point.z;
|
|
1918
|
-
var normalizedY = point.y - normalizedAlt;
|
|
1919
|
-
|
|
1920
|
-
this._container.classed("leaflet-hidden", false);
|
|
1921
|
-
|
|
1922
|
-
this._focusmarker.call(HeightFocusMarker({
|
|
1923
|
-
theme: opts.theme,
|
|
1924
|
-
xCoord: point.x,
|
|
1925
|
-
yCoord: point.y
|
|
1926
|
-
}));
|
|
1927
1806
|
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
yCoord: point.y,
|
|
1932
|
-
length: normalizedY
|
|
1933
|
-
}));
|
|
1807
|
+
switch (this.options.marker) {
|
|
1808
|
+
case 'elevation-line':
|
|
1809
|
+
var point = this._map.latLngToLayerPoint(this._latlng);
|
|
1934
1810
|
|
|
1935
|
-
|
|
1936
|
-
theme: opts.theme,
|
|
1937
|
-
xCoord: point.x,
|
|
1938
|
-
yCoord: normalizedY,
|
|
1939
|
-
label: d3.format("." + opts.decimalsY + "f")(point[opts.yAttr]) + " " + this._yLabel
|
|
1940
|
-
}));
|
|
1811
|
+
point = L.extend({}, props.item, this._map._rotate ? this._map.rotatedPointToMapPanePoint(point) : point);
|
|
1941
1812
|
|
|
1942
|
-
|
|
1943
|
-
var tooltip = this._focuslabel;
|
|
1944
|
-
var label;
|
|
1813
|
+
this._container.classed("leaflet-hidden", false);
|
|
1945
1814
|
|
|
1946
|
-
|
|
1947
|
-
|
|
1815
|
+
this._container.call(PositionMarker({
|
|
1816
|
+
theme: this.options.theme,
|
|
1817
|
+
xCoord: point.x,
|
|
1818
|
+
yCoord: point.y,
|
|
1819
|
+
length: point.y - this._height() / props.maxElevation * point.z,
|
|
1820
|
+
// normalized Y
|
|
1821
|
+
labels: this._labels,
|
|
1822
|
+
item: point
|
|
1823
|
+
}));
|
|
1948
1824
|
|
|
1949
|
-
|
|
1950
|
-
label = tooltip.append("svg:tspan").attr("class", "height-focus-" + labels[i].name).attr("dy", "1.5em");
|
|
1951
|
-
}
|
|
1825
|
+
break;
|
|
1952
1826
|
|
|
1953
|
-
|
|
1827
|
+
case 'position-marker':
|
|
1828
|
+
removeClass(this._marker.getElement(), 'leaflet-hidden');
|
|
1954
1829
|
|
|
1955
|
-
this.
|
|
1956
|
-
}
|
|
1957
|
-
} else if (this.options.marker == 'position-marker') {
|
|
1958
|
-
removeClass(this._marker.getElement(), 'leaflet-hidden');
|
|
1830
|
+
this._marker.setLatLng(this._latlng);
|
|
1959
1831
|
|
|
1960
|
-
|
|
1832
|
+
break;
|
|
1961
1833
|
}
|
|
1962
1834
|
},
|
|
1963
1835
|
|
|
@@ -1967,10 +1839,15 @@
|
|
|
1967
1839
|
remove: function remove() {
|
|
1968
1840
|
this._props = null;
|
|
1969
1841
|
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1842
|
+
switch (this.options.marker) {
|
|
1843
|
+
case 'elevation-line':
|
|
1844
|
+
this._container && this._container.classed("leaflet-hidden", true);
|
|
1845
|
+
break;
|
|
1846
|
+
|
|
1847
|
+
case 'position-marker':
|
|
1848
|
+
addClass(this._marker.getElement(), 'leaflet-hidden');
|
|
1849
|
+
|
|
1850
|
+
break;
|
|
1974
1851
|
}
|
|
1975
1852
|
},
|
|
1976
1853
|
getLatLng: function getLatLng() {
|
|
@@ -1984,8 +1861,8 @@
|
|
|
1984
1861
|
var opts = this.options;
|
|
1985
1862
|
return opts.height - opts.margins.top - opts.margins.bottom;
|
|
1986
1863
|
},
|
|
1987
|
-
|
|
1988
|
-
this.
|
|
1864
|
+
_registerTooltip: function _registerTooltip(props) {
|
|
1865
|
+
this._labels[props.name] = props;
|
|
1989
1866
|
}
|
|
1990
1867
|
});
|
|
1991
1868
|
|
|
@@ -2030,7 +1907,6 @@
|
|
|
2030
1907
|
collapsed: false,
|
|
2031
1908
|
detached: true,
|
|
2032
1909
|
distance: true,
|
|
2033
|
-
distanceFactor: 1,
|
|
2034
1910
|
distanceMarkers: false,
|
|
2035
1911
|
decimalsX: 2,
|
|
2036
1912
|
decimalsY: 0,
|
|
@@ -2040,15 +1916,10 @@
|
|
|
2040
1916
|
followMarker: true,
|
|
2041
1917
|
forceAxisBounds: false,
|
|
2042
1918
|
height: 200,
|
|
2043
|
-
heightFactor: 1,
|
|
2044
1919
|
imperial: false,
|
|
2045
1920
|
interpolation: "curveLinear",
|
|
2046
1921
|
lazyLoadJS: true,
|
|
2047
1922
|
legend: true,
|
|
2048
|
-
loadData: {
|
|
2049
|
-
defer: false,
|
|
2050
|
-
lazy: false
|
|
2051
|
-
},
|
|
2052
1923
|
margins: {
|
|
2053
1924
|
top: 30,
|
|
2054
1925
|
right: 30,
|
|
@@ -2062,7 +1933,6 @@
|
|
|
2062
1933
|
iconSize: [32, 32],
|
|
2063
1934
|
iconAnchor: [16, 16]
|
|
2064
1935
|
}),
|
|
2065
|
-
placeholder: false,
|
|
2066
1936
|
position: "topright",
|
|
2067
1937
|
polyline: {
|
|
2068
1938
|
className: 'elevation-polyline',
|
|
@@ -2081,7 +1951,6 @@
|
|
|
2081
1951
|
ruler: true,
|
|
2082
1952
|
skipNullZCoords: false,
|
|
2083
1953
|
theme: "lightblue-theme",
|
|
2084
|
-
responsive: true,
|
|
2085
1954
|
summary: 'inline',
|
|
2086
1955
|
slope: false,
|
|
2087
1956
|
speed: false,
|
|
@@ -2089,6 +1958,7 @@
|
|
|
2089
1958
|
time: false,
|
|
2090
1959
|
timeFactor: 3600,
|
|
2091
1960
|
timeFormat: false,
|
|
1961
|
+
timestamps: false,
|
|
2092
1962
|
sDeltaMax: undefined,
|
|
2093
1963
|
sInterpolation: "curveStepAfter",
|
|
2094
1964
|
sRange: undefined,
|
|
@@ -2124,7 +1994,7 @@
|
|
|
2124
1994
|
__TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@4.3.0/dist/togeojson.umd.js',
|
|
2125
1995
|
__LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js',
|
|
2126
1996
|
__LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',
|
|
2127
|
-
__LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.7.
|
|
1997
|
+
__LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.7.5/libs/leaflet-distance-marker.min.js',
|
|
2128
1998
|
|
|
2129
1999
|
/*
|
|
2130
2000
|
* Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
|
|
@@ -2132,11 +2002,11 @@
|
|
|
2132
2002
|
addData: function addData(d, layer) {
|
|
2133
2003
|
var _this = this;
|
|
2134
2004
|
|
|
2135
|
-
|
|
2136
|
-
layer
|
|
2137
|
-
|
|
2005
|
+
this.lazyLoad(this.__D3).then(function () {
|
|
2006
|
+
if (typeof layer === "undefined" && d.on) {
|
|
2007
|
+
layer = d;
|
|
2008
|
+
}
|
|
2138
2009
|
|
|
2139
|
-
Elevation._d3LazyLoader = lazyLoader(this.__D3, (typeof d3 === "undefined" ? "undefined" : _typeof(d3)) !== 'object' || !this.options.lazyLoadJS, Elevation._d3LazyLoader).then(function () {
|
|
2140
2010
|
_this._addData(d);
|
|
2141
2011
|
|
|
2142
2012
|
_this._addLayer(layer);
|
|
@@ -2231,20 +2101,6 @@
|
|
|
2231
2101
|
this._chart._brushEnabled = true;
|
|
2232
2102
|
},
|
|
2233
2103
|
|
|
2234
|
-
/**
|
|
2235
|
-
* Alias for enableBrush
|
|
2236
|
-
*/
|
|
2237
|
-
enableDragging: function enableDragging() {
|
|
2238
|
-
this.enableBrushing();
|
|
2239
|
-
},
|
|
2240
|
-
|
|
2241
|
-
/**
|
|
2242
|
-
* Alias for disableBrush
|
|
2243
|
-
*/
|
|
2244
|
-
disableDragging: function disableDragging() {
|
|
2245
|
-
this.disableBrushing();
|
|
2246
|
-
},
|
|
2247
|
-
|
|
2248
2104
|
/**
|
|
2249
2105
|
* Disable chart zooming.
|
|
2250
2106
|
*/
|
|
@@ -2279,7 +2135,7 @@
|
|
|
2279
2135
|
* Get default zoom level when "followMarker" is true.
|
|
2280
2136
|
*/
|
|
2281
2137
|
getZFollow: function getZFollow() {
|
|
2282
|
-
return this.
|
|
2138
|
+
return this.options.zFollow;
|
|
2283
2139
|
},
|
|
2284
2140
|
|
|
2285
2141
|
/**
|
|
@@ -2299,50 +2155,29 @@
|
|
|
2299
2155
|
this._markedSegments = L.polyline([]);
|
|
2300
2156
|
this._chartEnabled = true, this.track_info = {};
|
|
2301
2157
|
this.options = deepMerge({}, this.options, options);
|
|
2302
|
-
this._zFollow = this.options.zFollow;
|
|
2303
2158
|
if (this.options.followMarker) this._setMapView = L.Util.throttle(this._setMapView, 300, this);
|
|
2304
|
-
if (this.options.placeholder) this.options.loadData.lazy = this.options.loadData.defer = true;
|
|
2305
2159
|
if (this.options.legend) this.options.margins.bottom += 30;
|
|
2306
2160
|
if (this.options.theme) this.options.polylineSegments.className += ' ' + this.options.theme;
|
|
2161
|
+
if (this.options.wptIcons === true) this.options.wptIcons = Options.wptIcons;
|
|
2307
2162
|
|
|
2308
|
-
this._markedSegments.setStyle(this.options.polylineSegments); //
|
|
2309
|
-
// this._resizeChart = L.Util.throttle(this._resizeChart, 300, this);
|
|
2310
|
-
// if (L.Browser.mobile) {
|
|
2311
|
-
// this._updateChart = _.debounce(this._updateChart, 300, this);
|
|
2312
|
-
// this._updateSummary = _.debounce(this._updateSummary, 300, this);
|
|
2313
|
-
// }
|
|
2314
|
-
|
|
2163
|
+
this._markedSegments.setStyle(this.options.polylineSegments); // Leaflet canvas renderer colors
|
|
2315
2164
|
|
|
2316
|
-
if (this.options.wptIcons === true) this.options.wptIcons = Options.wptIcons; // Leaflet canvas renderer colors
|
|
2317
2165
|
|
|
2318
2166
|
L.extend(Colors, this.options.colors || {});
|
|
2319
2167
|
},
|
|
2320
2168
|
|
|
2321
2169
|
/**
|
|
2322
|
-
*
|
|
2323
|
-
*/
|
|
2324
|
-
load: function load(data, opts) {
|
|
2325
|
-
this.loadData(data, opts);
|
|
2326
|
-
},
|
|
2327
|
-
|
|
2328
|
-
/**
|
|
2329
|
-
* Alias for addTo
|
|
2170
|
+
* Javascript scripts downloader (lazy loader)
|
|
2330
2171
|
*/
|
|
2331
|
-
|
|
2332
|
-
this
|
|
2172
|
+
lazyLoad: function lazyLoad$1(src) {
|
|
2173
|
+
return lazyLoad(src, this);
|
|
2333
2174
|
},
|
|
2334
2175
|
|
|
2335
2176
|
/**
|
|
2336
2177
|
* Load elevation data (GPX, GeoJSON or KML).
|
|
2337
2178
|
*/
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
if (opts.defer) {
|
|
2342
|
-
this.loadDefer(data, opts);
|
|
2343
|
-
} else if (opts.lazy) {
|
|
2344
|
-
this.loadLazy(data, opts);
|
|
2345
|
-
} else if (isXMLDoc(data)) {
|
|
2179
|
+
load: function load(data) {
|
|
2180
|
+
if (isXMLDoc(data)) {
|
|
2346
2181
|
this.loadXML(data);
|
|
2347
2182
|
} else if (isJSONDoc(data)) {
|
|
2348
2183
|
this.loadGeoJSON(data);
|
|
@@ -2351,16 +2186,6 @@
|
|
|
2351
2186
|
}
|
|
2352
2187
|
},
|
|
2353
2188
|
|
|
2354
|
-
/**
|
|
2355
|
-
* Wait for document load before download data.
|
|
2356
|
-
*/
|
|
2357
|
-
loadDefer: function loadDefer(data, opts) {
|
|
2358
|
-
opts = L.extend({}, this.options.loadData, opts);
|
|
2359
|
-
opts.defer = false;
|
|
2360
|
-
|
|
2361
|
-
deferFunc(L.bind(this.loadData, this, data, opts));
|
|
2362
|
-
},
|
|
2363
|
-
|
|
2364
2189
|
/**
|
|
2365
2190
|
* Load data from a remote url.
|
|
2366
2191
|
*/
|
|
@@ -2372,10 +2197,7 @@
|
|
|
2372
2197
|
}).then(function (data) {
|
|
2373
2198
|
_this3._downloadURL = url; // TODO: handle multiple urls?
|
|
2374
2199
|
|
|
2375
|
-
_this3.
|
|
2376
|
-
lazy: false,
|
|
2377
|
-
defer: false
|
|
2378
|
-
});
|
|
2200
|
+
_this3.load(data);
|
|
2379
2201
|
}).catch(function (err) {
|
|
2380
2202
|
return console.warn(err);
|
|
2381
2203
|
});
|
|
@@ -2388,20 +2210,13 @@
|
|
|
2388
2210
|
GeoJSONLoader(data, this);
|
|
2389
2211
|
},
|
|
2390
2212
|
|
|
2391
|
-
/**
|
|
2392
|
-
* Alias for loadXML
|
|
2393
|
-
*/
|
|
2394
|
-
loadGPX: function loadGPX(data) {
|
|
2395
|
-
this.loadXML(data);
|
|
2396
|
-
},
|
|
2397
|
-
|
|
2398
2213
|
/**
|
|
2399
2214
|
* Load raw XML data.
|
|
2400
2215
|
*/
|
|
2401
2216
|
loadXML: function loadXML(data) {
|
|
2402
2217
|
var _this4 = this;
|
|
2403
2218
|
|
|
2404
|
-
|
|
2219
|
+
this.lazyLoad(this.__TOGEOJSON).then(function () {
|
|
2405
2220
|
var xml = new DOMParser().parseFromString(data, "text/xml");
|
|
2406
2221
|
var type = xml.documentElement.tagName.toLowerCase(); // "kml" or "gpx"
|
|
2407
2222
|
|
|
@@ -2422,32 +2237,12 @@
|
|
|
2422
2237
|
});
|
|
2423
2238
|
},
|
|
2424
2239
|
|
|
2425
|
-
/**
|
|
2426
|
-
* Wait for chart container visible before download data.
|
|
2427
|
-
*/
|
|
2428
|
-
loadLazy: function loadLazy(data, opts) {
|
|
2429
|
-
var _this5 = this;
|
|
2430
|
-
|
|
2431
|
-
opts = L.extend({}, this.options.loadData, opts);
|
|
2432
|
-
var elem = opts.lazy.parentNode ? opts.lazy : this.placeholder;
|
|
2433
|
-
|
|
2434
|
-
waitHolder(elem).then(function () {
|
|
2435
|
-
opts.lazy = false;
|
|
2436
|
-
|
|
2437
|
-
_this5.loadData(data, opts);
|
|
2438
|
-
|
|
2439
|
-
_this5.once('eledata_loaded', function () {
|
|
2440
|
-
return _this5.placeholder.parentNode.removeChild(elem);
|
|
2441
|
-
});
|
|
2442
|
-
});
|
|
2443
|
-
},
|
|
2444
|
-
|
|
2445
2240
|
/**
|
|
2446
2241
|
* Create container DOM element and related event listeners.
|
|
2447
2242
|
* Called on control.addTo(map).
|
|
2448
2243
|
*/
|
|
2449
2244
|
onAdd: function onAdd(map) {
|
|
2450
|
-
var
|
|
2245
|
+
var _this5 = this;
|
|
2451
2246
|
|
|
2452
2247
|
this._map = map;
|
|
2453
2248
|
|
|
@@ -2457,37 +2252,28 @@
|
|
|
2457
2252
|
addClass(container, 'leaflet-control');
|
|
2458
2253
|
}
|
|
2459
2254
|
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
src: this.options.placeholder,
|
|
2463
|
-
alt: ''
|
|
2464
|
-
} : this.options.placeholder);
|
|
2465
|
-
|
|
2466
|
-
insert(container, this.placeholder, 'afterbegin');
|
|
2467
|
-
}
|
|
2468
|
-
|
|
2469
|
-
Elevation._d3LazyLoader = lazyLoader(this.__D3, (typeof d3 === "undefined" ? "undefined" : _typeof(d3)) !== 'object' || !this.options.lazyLoadJS, Elevation._d3LazyLoader).then(function () {
|
|
2470
|
-
_this6._initButton(container);
|
|
2255
|
+
this.lazyLoad(this.__D3).then(function () {
|
|
2256
|
+
_this5._initButton(container);
|
|
2471
2257
|
|
|
2472
|
-
|
|
2258
|
+
_this5._initChart(container);
|
|
2473
2259
|
|
|
2474
|
-
|
|
2260
|
+
_this5._initSummary(container);
|
|
2475
2261
|
|
|
2476
|
-
|
|
2262
|
+
_this5._initMarker(map);
|
|
2477
2263
|
|
|
2478
|
-
|
|
2264
|
+
_this5._initLayer(map);
|
|
2479
2265
|
|
|
2480
|
-
map.on('zoom viewreset zoomanim',
|
|
2266
|
+
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);
|
|
2481
2267
|
|
|
2482
|
-
on(map.getContainer(), 'mousewheel',
|
|
2268
|
+
on(map.getContainer(), 'mousewheel', _this5._resetDrag, _this5);
|
|
2483
2269
|
|
|
2484
|
-
on(map.getContainer(), 'touchstart',
|
|
2270
|
+
on(map.getContainer(), 'touchstart', _this5._resetDrag, _this5);
|
|
2485
2271
|
|
|
2486
|
-
|
|
2272
|
+
_this5.on('eledata_added eledata_loaded', _this5._updateChart, _this5).on('eledata_added eledata_loaded', _this5._updateSummary, _this5);
|
|
2487
2273
|
|
|
2488
|
-
|
|
2274
|
+
_this5._updateChart();
|
|
2489
2275
|
|
|
2490
|
-
|
|
2276
|
+
_this5._updateSummary();
|
|
2491
2277
|
});
|
|
2492
2278
|
return container;
|
|
2493
2279
|
},
|
|
@@ -2518,7 +2304,7 @@
|
|
|
2518
2304
|
* Set default zoom level when "followMarker" is true.
|
|
2519
2305
|
*/
|
|
2520
2306
|
setZFollow: function setZFollow(zoom) {
|
|
2521
|
-
this.
|
|
2307
|
+
this.options.zFollow = zoom;
|
|
2522
2308
|
},
|
|
2523
2309
|
|
|
2524
2310
|
/**
|
|
@@ -2532,7 +2318,7 @@
|
|
|
2532
2318
|
* Parsing data either from GPX or GeoJSON and update the diagram data
|
|
2533
2319
|
*/
|
|
2534
2320
|
_addData: function _addData(d) {
|
|
2535
|
-
var
|
|
2321
|
+
var _this6 = this;
|
|
2536
2322
|
|
|
2537
2323
|
if (!d) {
|
|
2538
2324
|
return;
|
|
@@ -2549,7 +2335,7 @@
|
|
|
2549
2335
|
|
|
2550
2336
|
case 'MultiLineString':
|
|
2551
2337
|
each(geom.coordinates, function (coords) {
|
|
2552
|
-
return
|
|
2338
|
+
return _this6._addGeoJSONData(coords);
|
|
2553
2339
|
});
|
|
2554
2340
|
|
|
2555
2341
|
break;
|
|
@@ -2561,7 +2347,7 @@
|
|
|
2561
2347
|
|
|
2562
2348
|
if (d.type === "FeatureCollection") {
|
|
2563
2349
|
each(d.features, function (feature) {
|
|
2564
|
-
return
|
|
2350
|
+
return _this6._addData(feature);
|
|
2565
2351
|
});
|
|
2566
2352
|
}
|
|
2567
2353
|
|
|
@@ -2574,14 +2360,14 @@
|
|
|
2574
2360
|
* Parsing of GeoJSON data lines and their elevation in z-coordinate
|
|
2575
2361
|
*/
|
|
2576
2362
|
_addGeoJSONData: function _addGeoJSONData(coords) {
|
|
2577
|
-
var
|
|
2363
|
+
var _this7 = this;
|
|
2578
2364
|
|
|
2579
2365
|
each(coords, function (point) {
|
|
2580
|
-
|
|
2366
|
+
_this7._addPoint(point[1], point[0], point[2]);
|
|
2581
2367
|
|
|
2582
|
-
|
|
2368
|
+
_this7._fireEvt("elepoint_added", {
|
|
2583
2369
|
point: point,
|
|
2584
|
-
index:
|
|
2370
|
+
index: _this7._data.length - 1
|
|
2585
2371
|
});
|
|
2586
2372
|
});
|
|
2587
2373
|
|
|
@@ -2595,14 +2381,16 @@
|
|
|
2595
2381
|
* Parsing function for GPX data and their elevation in z-coordinate
|
|
2596
2382
|
*/
|
|
2597
2383
|
_addGPXData: function _addGPXData(coords) {
|
|
2598
|
-
var
|
|
2384
|
+
var _this8 = this;
|
|
2599
2385
|
|
|
2600
2386
|
each(coords, function (point) {
|
|
2601
|
-
|
|
2387
|
+
var _point$alt;
|
|
2388
|
+
|
|
2389
|
+
_this8._addPoint(point.lat, point.lng, (_point$alt = point.alt) !== null && _point$alt !== void 0 ? _point$alt : point.meta.ele);
|
|
2602
2390
|
|
|
2603
|
-
|
|
2391
|
+
_this8._fireEvt("elepoint_added", {
|
|
2604
2392
|
point: point,
|
|
2605
|
-
index:
|
|
2393
|
+
index: _this8._data.length - 1
|
|
2606
2394
|
});
|
|
2607
2395
|
});
|
|
2608
2396
|
|
|
@@ -2723,21 +2511,19 @@
|
|
|
2723
2511
|
opts.xTicks = this._xTicks();
|
|
2724
2512
|
opts.yTicks = this._yTicks();
|
|
2725
2513
|
|
|
2726
|
-
if (opts.
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
clientWidth = _this$_map$getContain.clientWidth;
|
|
2514
|
+
if (opts.detached) {
|
|
2515
|
+
var _this$eleDiv = this.eleDiv,
|
|
2516
|
+
offsetWidth = _this$eleDiv.offsetWidth,
|
|
2517
|
+
offsetHeight = _this$eleDiv.offsetHeight;
|
|
2518
|
+
if (offsetWidth > 0) opts.width = offsetWidth;
|
|
2519
|
+
if (offsetHeight > 20) opts.height = offsetHeight - 20; // 20 = horizontal scrollbar size.
|
|
2520
|
+
} else {
|
|
2521
|
+
var _this$_map$getContain = this._map.getContainer(),
|
|
2522
|
+
clientWidth = _this$_map$getContain.clientWidth;
|
|
2736
2523
|
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
}
|
|
2524
|
+
opts._maxWidth = opts._maxWidth > opts.width ? opts._maxWidth : opts.width;
|
|
2525
|
+
this._container.style.maxWidth = opts._maxWidth + 'px';
|
|
2526
|
+
if (opts._maxWidth > clientWidth) opts.width = clientWidth - 30;
|
|
2741
2527
|
}
|
|
2742
2528
|
|
|
2743
2529
|
var chart = this._chart = new Chart$1(opts, this);
|
|
@@ -2753,17 +2539,17 @@
|
|
|
2753
2539
|
this._fireEvt("elechart_init");
|
|
2754
2540
|
},
|
|
2755
2541
|
_initLayer: function _initLayer() {
|
|
2756
|
-
var
|
|
2542
|
+
var _this9 = this;
|
|
2757
2543
|
|
|
2758
2544
|
this._layers.on('layeradd layerremove', function (e) {
|
|
2759
2545
|
var layer = e.layer;
|
|
2760
2546
|
var node = layer.getElement && layer.getElement();
|
|
2761
2547
|
|
|
2762
|
-
toggleClass(node,
|
|
2548
|
+
toggleClass(node, _this9.options.polyline.className + ' ' + _this9.options.theme, e.type == 'layeradd');
|
|
2763
2549
|
|
|
2764
|
-
toggleEvent(layer, "mousemove",
|
|
2550
|
+
toggleEvent(layer, "mousemove", _this9._mousemoveLayerHandler.bind(_this9), e.type == 'layeradd');
|
|
2765
2551
|
|
|
2766
|
-
toggleEvent(layer, "mouseout",
|
|
2552
|
+
toggleEvent(layer, "mouseout", _this9._mouseoutHandler.bind(_this9), e.type == 'layeradd');
|
|
2767
2553
|
});
|
|
2768
2554
|
},
|
|
2769
2555
|
_initMarker: function _initMarker(map) {
|
|
@@ -2794,7 +2580,7 @@
|
|
|
2794
2580
|
container.setAttribute('aria-haspopup', true);
|
|
2795
2581
|
|
|
2796
2582
|
if (!this.options.detached) {
|
|
2797
|
-
L.DomEvent.disableClickPropagation(container)
|
|
2583
|
+
L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container);
|
|
2798
2584
|
}
|
|
2799
2585
|
|
|
2800
2586
|
if (L.Browser.mobile) {
|
|
@@ -2937,10 +2723,10 @@
|
|
|
2937
2723
|
* Add a waypoint marker to the diagram
|
|
2938
2724
|
*/
|
|
2939
2725
|
_registerCheckPoint: function _registerCheckPoint(props) {
|
|
2940
|
-
var
|
|
2726
|
+
var _this10 = this;
|
|
2941
2727
|
|
|
2942
2728
|
this.on("elechart_updated", function () {
|
|
2943
|
-
return
|
|
2729
|
+
return _this10._chart._registerCheckPoint(props);
|
|
2944
2730
|
});
|
|
2945
2731
|
},
|
|
2946
2732
|
|
|
@@ -2948,10 +2734,10 @@
|
|
|
2948
2734
|
* Add chart profile to diagram
|
|
2949
2735
|
*/
|
|
2950
2736
|
_registerAreaPath: function _registerAreaPath(props) {
|
|
2951
|
-
var
|
|
2737
|
+
var _this11 = this;
|
|
2952
2738
|
|
|
2953
2739
|
this.on("elechart_init", function () {
|
|
2954
|
-
return
|
|
2740
|
+
return _this11._chart._registerAreaPath(props);
|
|
2955
2741
|
});
|
|
2956
2742
|
},
|
|
2957
2743
|
|
|
@@ -2959,10 +2745,10 @@
|
|
|
2959
2745
|
* Add chart grid to diagram
|
|
2960
2746
|
*/
|
|
2961
2747
|
_registerAxisGrid: function _registerAxisGrid(props) {
|
|
2962
|
-
var
|
|
2748
|
+
var _this12 = this;
|
|
2963
2749
|
|
|
2964
2750
|
this.on("elechart_axis", function () {
|
|
2965
|
-
return
|
|
2751
|
+
return _this12._chart._registerAxisGrid(props);
|
|
2966
2752
|
});
|
|
2967
2753
|
},
|
|
2968
2754
|
|
|
@@ -2970,25 +2756,25 @@
|
|
|
2970
2756
|
* Add chart axis to diagram
|
|
2971
2757
|
*/
|
|
2972
2758
|
_registerAxisScale: function _registerAxisScale(props) {
|
|
2973
|
-
var
|
|
2759
|
+
var _this13 = this;
|
|
2974
2760
|
|
|
2975
2761
|
this.on("elechart_axis", function () {
|
|
2976
|
-
return
|
|
2762
|
+
return _this13._chart._registerAxisScale(props);
|
|
2977
2763
|
});
|
|
2978
2764
|
},
|
|
2979
2765
|
|
|
2980
2766
|
/**
|
|
2981
2767
|
* Add chart or marker tooltip info
|
|
2982
2768
|
*/
|
|
2983
|
-
|
|
2984
|
-
var
|
|
2769
|
+
_registerTooltip: function _registerTooltip(props) {
|
|
2770
|
+
var _this14 = this;
|
|
2985
2771
|
|
|
2986
2772
|
if (props.chart) {
|
|
2987
2773
|
var label = L.extend({}, props, {
|
|
2988
2774
|
value: props.chart
|
|
2989
2775
|
});
|
|
2990
2776
|
this.on("elechart_init", function () {
|
|
2991
|
-
return
|
|
2777
|
+
return _this14._chart._registerTooltip(label);
|
|
2992
2778
|
});
|
|
2993
2779
|
}
|
|
2994
2780
|
|
|
@@ -2998,7 +2784,7 @@
|
|
|
2998
2784
|
});
|
|
2999
2785
|
|
|
3000
2786
|
this.on("elechart_marker", function () {
|
|
3001
|
-
return
|
|
2787
|
+
return _this14._marker._registerTooltip(_label);
|
|
3002
2788
|
});
|
|
3003
2789
|
}
|
|
3004
2790
|
},
|
|
@@ -3007,10 +2793,10 @@
|
|
|
3007
2793
|
* Add summary info to diagram
|
|
3008
2794
|
*/
|
|
3009
2795
|
_registerSummary: function _registerSummary(props) {
|
|
3010
|
-
var
|
|
2796
|
+
var _this15 = this;
|
|
3011
2797
|
|
|
3012
2798
|
this.on('elechart_summary', function () {
|
|
3013
|
-
return
|
|
2799
|
+
return _this15._summary._registerSummary(props);
|
|
3014
2800
|
});
|
|
3015
2801
|
},
|
|
3016
2802
|
|
|
@@ -3042,34 +2828,32 @@
|
|
|
3042
2828
|
* Hacky way for handling chart resize. Deletes it and redraw chart.
|
|
3043
2829
|
*/
|
|
3044
2830
|
_resizeChart: function _resizeChart() {
|
|
3045
|
-
// prevent displaying chart on resize if hidden
|
|
2831
|
+
if (!this._container) return; // prevent displaying chart on resize if hidden
|
|
2832
|
+
|
|
3046
2833
|
if (style(this._container, "display") == "none") return;
|
|
3047
2834
|
var opts = this.options;
|
|
2835
|
+
var newWidth;
|
|
3048
2836
|
|
|
3049
|
-
if (opts.
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
} else {
|
|
3055
|
-
var _this$_map$getContain2 = this._map.getContainer(),
|
|
3056
|
-
clientWidth = _this$_map$getContain2.clientWidth;
|
|
2837
|
+
if (opts.detached) {
|
|
2838
|
+
newWidth = (this.eleDiv || this._container).offsetWidth;
|
|
2839
|
+
} else {
|
|
2840
|
+
var _this$_map$getContain2 = this._map.getContainer(),
|
|
2841
|
+
clientWidth = _this$_map$getContain2.clientWidth;
|
|
3057
2842
|
|
|
3058
|
-
|
|
3059
|
-
|
|
2843
|
+
newWidth = opts._maxWidth > clientWidth ? clientWidth - 30 : opts._maxWidth;
|
|
2844
|
+
}
|
|
3060
2845
|
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
2846
|
+
if (newWidth) {
|
|
2847
|
+
var chart = this._chart;
|
|
2848
|
+
opts.width = newWidth;
|
|
3064
2849
|
|
|
3065
|
-
|
|
3066
|
-
|
|
2850
|
+
if (chart && chart._chart) {
|
|
2851
|
+
chart._chart._resize(opts);
|
|
3067
2852
|
|
|
3068
|
-
|
|
3069
|
-
|
|
2853
|
+
opts.xTicks = this._xTicks();
|
|
2854
|
+
opts.yTicks = this._yTicks();
|
|
3070
2855
|
|
|
3071
|
-
|
|
3072
|
-
}
|
|
2856
|
+
this._updateChart();
|
|
3073
2857
|
}
|
|
3074
2858
|
}
|
|
3075
2859
|
|
|
@@ -3098,10 +2882,10 @@
|
|
|
3098
2882
|
|
|
3099
2883
|
var zoom = this._map.getZoom();
|
|
3100
2884
|
|
|
3101
|
-
|
|
3102
|
-
if (zoom < this._zFollow) zoom = this._zFollow;
|
|
2885
|
+
var z = this.options.zFollow;
|
|
3103
2886
|
|
|
3104
|
-
|
|
2887
|
+
if (typeof z === "number") {
|
|
2888
|
+
this._map.setView(item.latlng, zoom < z ? z : zoom, {
|
|
3105
2889
|
animate: true,
|
|
3106
2890
|
duration: 0.25
|
|
3107
2891
|
});
|
|
@@ -3117,7 +2901,7 @@
|
|
|
3117
2901
|
* Toggle chart data on legend click
|
|
3118
2902
|
*/
|
|
3119
2903
|
_toggleChartHandler: function _toggleChartHandler(e) {
|
|
3120
|
-
var
|
|
2904
|
+
var _this16 = this;
|
|
3121
2905
|
|
|
3122
2906
|
var path = e.path,
|
|
3123
2907
|
name = e.name,
|
|
@@ -3127,7 +2911,7 @@
|
|
|
3127
2911
|
this._layers.eachLayer(function (layer) {
|
|
3128
2912
|
var node = layer.getElement && layer.getElement();
|
|
3129
2913
|
|
|
3130
|
-
toggleClass(node,
|
|
2914
|
+
toggleClass(node, _this16.options.polyline.className + ' ' + _this16.options.theme, _this16._chartEnabled);
|
|
3131
2915
|
}); // toggle option value (eg. altitude = { 'disabled' || 'disabled' })
|
|
3132
2916
|
|
|
3133
2917
|
|
|
@@ -3146,7 +2930,7 @@
|
|
|
3146
2930
|
_updateChart: function _updateChart() {
|
|
3147
2931
|
if (
|
|
3148
2932
|
/*!this._data.length ||*/
|
|
3149
|
-
!this._container) return;
|
|
2933
|
+
!this._chart || !this._container) return;
|
|
3150
2934
|
|
|
3151
2935
|
this._fireEvt("elechart_axis");
|
|
3152
2936
|
|
|
@@ -3167,23 +2951,23 @@
|
|
|
3167
2951
|
* Update the position/height indicator marker drawn onto the map
|
|
3168
2952
|
*/
|
|
3169
2953
|
_updateMarker: function _updateMarker(item) {
|
|
3170
|
-
if (
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
}
|
|
2954
|
+
if (this._marker) {
|
|
2955
|
+
this._marker.update({
|
|
2956
|
+
map: this._map,
|
|
2957
|
+
item: item,
|
|
2958
|
+
maxElevation: this.track_info.elevation_max || 0,
|
|
2959
|
+
options: this.options
|
|
2960
|
+
});
|
|
2961
|
+
}
|
|
3178
2962
|
},
|
|
3179
2963
|
|
|
3180
2964
|
/**
|
|
3181
2965
|
* Fix marker rotation on rotated maps
|
|
3182
2966
|
*/
|
|
3183
2967
|
_rotateMarker: function _rotateMarker() {
|
|
3184
|
-
if (
|
|
3185
|
-
|
|
3186
|
-
|
|
2968
|
+
if (this._marker) {
|
|
2969
|
+
this._marker.update();
|
|
2970
|
+
}
|
|
3187
2971
|
},
|
|
3188
2972
|
|
|
3189
2973
|
/**
|
|
@@ -3201,7 +2985,7 @@
|
|
|
3201
2985
|
* Update chart summary.
|
|
3202
2986
|
*/
|
|
3203
2987
|
_updateSummary: function _updateSummary() {
|
|
3204
|
-
var
|
|
2988
|
+
var _this17 = this;
|
|
3205
2989
|
|
|
3206
2990
|
this._summary.reset();
|
|
3207
2991
|
|
|
@@ -3216,9 +3000,9 @@
|
|
|
3216
3000
|
select('.download a', this.summaryDiv).onclick = function (e) {
|
|
3217
3001
|
e.preventDefault();
|
|
3218
3002
|
|
|
3219
|
-
|
|
3220
|
-
downloadLink:
|
|
3221
|
-
confirm: saveFile.bind(
|
|
3003
|
+
_this17._fireEvt('eletrack_download', {
|
|
3004
|
+
downloadLink: _this17.options.downloadLink,
|
|
3005
|
+
confirm: saveFile.bind(_this17, _this17._downloadURL)
|
|
3222
3006
|
});
|
|
3223
3007
|
};
|
|
3224
3008
|
}
|
|
@@ -3254,6 +3038,12 @@
|
|
|
3254
3038
|
*/
|
|
3255
3039
|
|
|
3256
3040
|
Elevation.addInitHook(function () {
|
|
3041
|
+
// Alias deprecated functions
|
|
3042
|
+
this.enableDragging = this.enableBrush;
|
|
3043
|
+
this.disableDragging = this.disableBrush;
|
|
3044
|
+
this.loadChart = this.addTo;
|
|
3045
|
+
this.loadData = this.load;
|
|
3046
|
+
this.loadGPX = this.loadXML;
|
|
3257
3047
|
this.on('waypoint_added', function (e) {
|
|
3258
3048
|
var p = e.point,
|
|
3259
3049
|
pop = p._popup;
|
|
@@ -3282,7 +3072,7 @@
|
|
|
3282
3072
|
}
|
|
3283
3073
|
});
|
|
3284
3074
|
this.on('eledata_loaded', function (e) {
|
|
3285
|
-
var
|
|
3075
|
+
var _this18 = this;
|
|
3286
3076
|
|
|
3287
3077
|
var map = this._map;
|
|
3288
3078
|
var layer = e.layer;
|
|
@@ -3293,37 +3083,37 @@
|
|
|
3293
3083
|
}
|
|
3294
3084
|
|
|
3295
3085
|
map.once('layeradd', function (e) {
|
|
3296
|
-
return
|
|
3086
|
+
return _this18.options.autofitBounds && _this18.fitBounds(layer.getBounds());
|
|
3297
3087
|
});
|
|
3298
3088
|
|
|
3299
3089
|
if (L.Browser.mobile) {
|
|
3300
3090
|
if (this.options.polyline) layer.addTo(map);
|
|
3301
3091
|
} else {
|
|
3302
3092
|
// leaflet-geometryutil
|
|
3303
|
-
|
|
3093
|
+
this.lazyLoad(this.__LGEOMUTIL).then(function () {
|
|
3304
3094
|
// leaflet-almostover
|
|
3305
|
-
if (
|
|
3306
|
-
|
|
3095
|
+
if (_this18.options.almostOver) {
|
|
3096
|
+
_this18.lazyLoad(_this18.__LALMOSTOVER).then(function () {
|
|
3307
3097
|
map.addHandler('almostOver', L.Handler.AlmostOver);
|
|
3308
3098
|
|
|
3309
3099
|
if (L.GeometryUtil && map.almostOver && map.almostOver.enabled()) {
|
|
3310
3100
|
map.almostOver.addLayer(layer);
|
|
3311
3101
|
map.on('almost:move', function (e) {
|
|
3312
|
-
return
|
|
3102
|
+
return _this18._mousemoveLayerHandler(e);
|
|
3313
3103
|
}).on('almost:out', function (e) {
|
|
3314
|
-
return
|
|
3104
|
+
return _this18._mouseoutHandler(e);
|
|
3315
3105
|
});
|
|
3316
3106
|
}
|
|
3317
3107
|
});
|
|
3318
3108
|
} // leaflet-distance-markers
|
|
3319
3109
|
|
|
3320
3110
|
|
|
3321
|
-
if (
|
|
3322
|
-
|
|
3323
|
-
return
|
|
3111
|
+
if (_this18.options.distanceMarkers) {
|
|
3112
|
+
_this18.lazyLoad(_this18.__LDISTANCEM).then(function () {
|
|
3113
|
+
return _this18.options.polyline && layer.addTo(map);
|
|
3324
3114
|
});
|
|
3325
3115
|
} else {
|
|
3326
|
-
if (
|
|
3116
|
+
if (_this18.options.polyline) layer.addTo(map);
|
|
3327
3117
|
}
|
|
3328
3118
|
});
|
|
3329
3119
|
}
|
|
@@ -3344,7 +3134,7 @@
|
|
|
3344
3134
|
if (options.stroke && options.weight !== 0) {
|
|
3345
3135
|
var oldVal = ctx.globalCompositeOperation || 'source-over';
|
|
3346
3136
|
ctx.globalCompositeOperation = 'destination-over';
|
|
3347
|
-
ctx.strokeStyle = '#FFF';
|
|
3137
|
+
ctx.strokeStyle = color.outline || '#FFF';
|
|
3348
3138
|
ctx.lineWidth = options.weight * 1.75;
|
|
3349
3139
|
ctx.stroke();
|
|
3350
3140
|
ctx.globalCompositeOperation = oldVal;
|
|
@@ -3369,94 +3159,24 @@
|
|
|
3369
3159
|
});
|
|
3370
3160
|
|
|
3371
3161
|
Elevation.addInitHook(function () {
|
|
3372
|
-
var _this2 = this;
|
|
3373
|
-
|
|
3374
|
-
var opts = this.options;
|
|
3375
|
-
var distance = {};
|
|
3376
|
-
|
|
3377
|
-
if (this.options.imperial) {
|
|
3378
|
-
this._distanceFactor = this.__mileFactor;
|
|
3379
|
-
this._xLabel = "mi";
|
|
3380
|
-
} else {
|
|
3381
|
-
this._distanceFactor = opts.distanceFactor;
|
|
3382
|
-
this._xLabel = opts.xLabel;
|
|
3383
|
-
}
|
|
3384
|
-
|
|
3385
|
-
this.on("eledata_updated", function (e) {
|
|
3386
|
-
var data = this._data;
|
|
3387
|
-
var i = e.index;
|
|
3388
|
-
var track = this.track_info;
|
|
3389
|
-
var dist = track.distance || 0;
|
|
3390
|
-
var curr = data[i].latlng;
|
|
3391
|
-
var prev = i > 0 ? data[i - 1].latlng : curr;
|
|
3392
|
-
|
|
3393
|
-
var delta = curr.distanceTo(prev) * this._distanceFactor;
|
|
3394
|
-
|
|
3395
|
-
dist += Math.round(delta / 1000 * 100000) / 100000; // handles floating points calc
|
|
3396
|
-
|
|
3397
|
-
data[i].dist = dist;
|
|
3398
|
-
track.distance = dist;
|
|
3399
|
-
});
|
|
3400
|
-
this.on("elechart_axis", function () {
|
|
3401
|
-
this._chart._registerAxisGrid({
|
|
3402
|
-
axis: "x",
|
|
3403
|
-
position: "bottom",
|
|
3404
|
-
scale: this._chart._x
|
|
3405
|
-
});
|
|
3406
|
-
});
|
|
3407
|
-
|
|
3408
|
-
if (this.options.distance != "summary") {
|
|
3409
|
-
this.on("elechart_axis", function () {
|
|
3410
|
-
var _this = this;
|
|
3411
|
-
|
|
3412
|
-
distance.x = this._chart._x;
|
|
3413
|
-
distance.label = this._chart._xLabel;
|
|
3414
|
-
|
|
3415
|
-
this._chart._registerAxisScale({
|
|
3416
|
-
axis: "x",
|
|
3417
|
-
position: "bottom",
|
|
3418
|
-
scale: distance.x,
|
|
3419
|
-
label: distance.label,
|
|
3420
|
-
labelY: 25,
|
|
3421
|
-
labelX: function labelX() {
|
|
3422
|
-
return _this._width() + 6;
|
|
3423
|
-
},
|
|
3424
|
-
name: "distance"
|
|
3425
|
-
});
|
|
3426
|
-
});
|
|
3427
|
-
}
|
|
3428
|
-
|
|
3429
|
-
this._registerSummary({
|
|
3430
|
-
"totlen": {
|
|
3431
|
-
label: "Total Length: ",
|
|
3432
|
-
value: function value(track) {
|
|
3433
|
-
return (track.distance || 0).toFixed(2) + ' ' + _this2._xLabel;
|
|
3434
|
-
}
|
|
3435
|
-
}
|
|
3436
|
-
});
|
|
3437
|
-
});
|
|
3438
|
-
|
|
3439
|
-
Elevation.addInitHook(function () {
|
|
3440
|
-
var _this = this;
|
|
3441
|
-
|
|
3442
3162
|
var opts = this.options;
|
|
3443
3163
|
var altitude = {};
|
|
3444
3164
|
|
|
3445
3165
|
if (opts.imperial) {
|
|
3446
|
-
|
|
3447
|
-
|
|
3166
|
+
opts.altitudeFactor = this.__footFactor;
|
|
3167
|
+
altitude.label = "ft";
|
|
3448
3168
|
} else {
|
|
3449
|
-
|
|
3450
|
-
|
|
3169
|
+
opts.altitudeFactor = opts.heightFactor || opts.altitudeFactor || 1;
|
|
3170
|
+
altitude.label = opts.yLabel;
|
|
3451
3171
|
}
|
|
3452
3172
|
|
|
3453
3173
|
this.on("eledata_updated", function (e) {
|
|
3454
3174
|
var data = this._data;
|
|
3455
3175
|
var i = e.index;
|
|
3456
|
-
var z = data[i].z *
|
|
3176
|
+
var z = data[i].z * opts.altitudeFactor;
|
|
3457
3177
|
var track = this.track_info;
|
|
3458
|
-
var
|
|
3459
|
-
var
|
|
3178
|
+
var zMax = track.elevation_max || -Infinity;
|
|
3179
|
+
var zMin = track.elevation_min || +Infinity; // check and fix missing elevation data on last added point
|
|
3460
3180
|
|
|
3461
3181
|
if (!this.options.skipNullZCoords && i > 0) {
|
|
3462
3182
|
var prevZ = data[i - 1].z;
|
|
@@ -3480,14 +3200,12 @@
|
|
|
3480
3200
|
|
|
3481
3201
|
|
|
3482
3202
|
if (!isNaN(z)) {
|
|
3483
|
-
eleMax = eleMax < z ? z : eleMax;
|
|
3484
|
-
eleMin = eleMin > z ? z : eleMin;
|
|
3485
3203
|
this._lastValidZ = z;
|
|
3486
3204
|
}
|
|
3487
3205
|
|
|
3206
|
+
track.elevation_max = z > zMax ? z : zMax;
|
|
3207
|
+
track.elevation_min = z < zMin ? z : zMin;
|
|
3488
3208
|
data[i].z = z;
|
|
3489
|
-
track.elevation_max = eleMax;
|
|
3490
|
-
track.elevation_min = eleMin;
|
|
3491
3209
|
});
|
|
3492
3210
|
this.on("elechart_axis", function () {
|
|
3493
3211
|
this._chart._registerAxisGrid({
|
|
@@ -3499,13 +3217,10 @@
|
|
|
3499
3217
|
|
|
3500
3218
|
if (this.options.altitude != "summary") {
|
|
3501
3219
|
this.on("elechart_axis", function () {
|
|
3502
|
-
altitude.y = this._chart._y;
|
|
3503
|
-
altitude.label = this._yLabel;
|
|
3504
|
-
|
|
3505
3220
|
this._chart._registerAxisScale({
|
|
3506
3221
|
axis: "y",
|
|
3507
3222
|
position: "left",
|
|
3508
|
-
scale:
|
|
3223
|
+
scale: this._chart._y,
|
|
3509
3224
|
label: altitude.label,
|
|
3510
3225
|
labelX: -3,
|
|
3511
3226
|
labelY: -8,
|
|
@@ -3515,8 +3230,6 @@
|
|
|
3515
3230
|
this.on("elechart_init", function () {
|
|
3516
3231
|
var theme = this.options.theme.replace('-theme', '');
|
|
3517
3232
|
var color = Colors[theme] || {};
|
|
3518
|
-
var alpha = this.options.detached ? color.alpha || '0.8' : 1;
|
|
3519
|
-
var stroke = this.options.detached ? color.stroke : false;
|
|
3520
3233
|
|
|
3521
3234
|
this._chart._registerAreaPath({
|
|
3522
3235
|
name: 'altitude',
|
|
@@ -3524,25 +3237,103 @@
|
|
|
3524
3237
|
scaleX: 'distance',
|
|
3525
3238
|
scaleY: 'altitude',
|
|
3526
3239
|
color: color.area || theme,
|
|
3527
|
-
strokeColor: stroke
|
|
3240
|
+
strokeColor: this.options.detached ? color.stroke : '#000',
|
|
3528
3241
|
strokeOpacity: "1",
|
|
3529
|
-
fillOpacity: alpha,
|
|
3242
|
+
fillOpacity: this.options.detached ? color.alpha || '0.8' : 1,
|
|
3530
3243
|
preferCanvas: this.options.preferCanvas
|
|
3531
3244
|
});
|
|
3532
3245
|
});
|
|
3533
3246
|
}
|
|
3534
3247
|
|
|
3248
|
+
this._registerTooltip({
|
|
3249
|
+
name: 'y',
|
|
3250
|
+
chart: function chart(item) {
|
|
3251
|
+
return L._("y: ") + d3.format("." + opts.decimalsY + "f")(item[opts.yAttr]) + " " + altitude.label;
|
|
3252
|
+
},
|
|
3253
|
+
marker: function marker(item) {
|
|
3254
|
+
return d3.format("." + opts.decimalsY + "f")(item[opts.yAttr]) + " " + altitude.label;
|
|
3255
|
+
}
|
|
3256
|
+
});
|
|
3257
|
+
|
|
3535
3258
|
this._registerSummary({
|
|
3536
3259
|
"maxele": {
|
|
3537
3260
|
label: "Max Elevation: ",
|
|
3538
3261
|
value: function value(track) {
|
|
3539
|
-
return (track.elevation_max || 0).toFixed(2) + ' ' +
|
|
3262
|
+
return (track.elevation_max || 0).toFixed(2) + ' ' + altitude.label;
|
|
3540
3263
|
}
|
|
3541
3264
|
},
|
|
3542
3265
|
"minele": {
|
|
3543
3266
|
label: "Min Elevation: ",
|
|
3544
3267
|
value: function value(track) {
|
|
3545
|
-
return (track.elevation_min || 0).toFixed(2) + ' ' +
|
|
3268
|
+
return (track.elevation_min || 0).toFixed(2) + ' ' + altitude.label;
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
});
|
|
3272
|
+
});
|
|
3273
|
+
|
|
3274
|
+
Elevation.addInitHook(function () {
|
|
3275
|
+
var opts = this.options;
|
|
3276
|
+
var distance = {};
|
|
3277
|
+
|
|
3278
|
+
if (opts.imperial) {
|
|
3279
|
+
opts.distanceFactor = this.__mileFactor;
|
|
3280
|
+
distance.label = "mi";
|
|
3281
|
+
} else {
|
|
3282
|
+
opts.distanceFactor = opts.distanceFactor || 1;
|
|
3283
|
+
distance.label = opts.xLabel;
|
|
3284
|
+
}
|
|
3285
|
+
|
|
3286
|
+
this.on("eledata_updated", function (e) {
|
|
3287
|
+
var data = this._data;
|
|
3288
|
+
var i = e.index;
|
|
3289
|
+
var track = this.track_info;
|
|
3290
|
+
var dist = track.distance || 0;
|
|
3291
|
+
var curr = data[i].latlng;
|
|
3292
|
+
var prev = i > 0 ? data[i - 1].latlng : curr;
|
|
3293
|
+
var delta = curr.distanceTo(prev) * opts.distanceFactor;
|
|
3294
|
+
dist += Math.round(delta / 1000 * 100000) / 100000; // handles floating points calc
|
|
3295
|
+
|
|
3296
|
+
track.distance = dist;
|
|
3297
|
+
data[i].dist = dist;
|
|
3298
|
+
});
|
|
3299
|
+
this.on("elechart_axis", function () {
|
|
3300
|
+
this._chart._registerAxisGrid({
|
|
3301
|
+
axis: "x",
|
|
3302
|
+
position: "bottom",
|
|
3303
|
+
scale: this._chart._x
|
|
3304
|
+
});
|
|
3305
|
+
});
|
|
3306
|
+
|
|
3307
|
+
if (this.options.distance != "summary") {
|
|
3308
|
+
this.on("elechart_axis", function () {
|
|
3309
|
+
var _this = this;
|
|
3310
|
+
|
|
3311
|
+
this._chart._registerAxisScale({
|
|
3312
|
+
axis: "x",
|
|
3313
|
+
position: "bottom",
|
|
3314
|
+
scale: this._chart._x,
|
|
3315
|
+
label: distance.label,
|
|
3316
|
+
labelY: 25,
|
|
3317
|
+
labelX: function labelX() {
|
|
3318
|
+
return _this._width() + 6;
|
|
3319
|
+
},
|
|
3320
|
+
name: "distance"
|
|
3321
|
+
});
|
|
3322
|
+
});
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3325
|
+
this._registerTooltip({
|
|
3326
|
+
name: 'x',
|
|
3327
|
+
chart: function chart(item) {
|
|
3328
|
+
return L._("x: ") + d3.format("." + opts.decimalsX + "f")(item[opts.xAttr]) + " " + distance.label;
|
|
3329
|
+
}
|
|
3330
|
+
});
|
|
3331
|
+
|
|
3332
|
+
this._registerSummary({
|
|
3333
|
+
"totlen": {
|
|
3334
|
+
label: "Total Length: ",
|
|
3335
|
+
value: function value(track) {
|
|
3336
|
+
return (track.distance || 0).toFixed(2) + ' ' + distance.label;
|
|
3546
3337
|
}
|
|
3547
3338
|
}
|
|
3548
3339
|
});
|
|
@@ -3554,7 +3345,7 @@
|
|
|
3554
3345
|
var opts = this.options;
|
|
3555
3346
|
var time = {};
|
|
3556
3347
|
time.label = opts.timeLabel || 't';
|
|
3557
|
-
|
|
3348
|
+
opts.timeFactor = opts.timeFactor || 3600;
|
|
3558
3349
|
/**
|
|
3559
3350
|
* Common AVG speeds:
|
|
3560
3351
|
* ----------------------
|
|
@@ -3619,7 +3410,7 @@
|
|
|
3619
3410
|
e.point.meta = e.point.meta || {};
|
|
3620
3411
|
var delta = data[i].dist - data[i > 0 ? i - 1 : i].dist;
|
|
3621
3412
|
var speed = this._timeAVGSpeed;
|
|
3622
|
-
e.point.meta.time = new Date(i > 0 ? data[i - 1].time.getTime() + delta / speed *
|
|
3413
|
+
e.point.meta.time = new Date(i > 0 ? data[i - 1].time.getTime() + delta / speed * opts.timeFactor * 1000 : Date.now());
|
|
3623
3414
|
}
|
|
3624
3415
|
|
|
3625
3416
|
var time = e.point.meta.time; // Handle timezone offset
|
|
@@ -3632,16 +3423,25 @@
|
|
|
3632
3423
|
var prevT = i > 0 ? data[i - 1].time : currT;
|
|
3633
3424
|
var deltaT = Math.abs(currT - prevT);
|
|
3634
3425
|
var duration = (this.track_info.time || 0) + deltaT;
|
|
3426
|
+
this.track_info.time = duration;
|
|
3635
3427
|
data[i].time = time;
|
|
3636
3428
|
data[i].duration = duration;
|
|
3637
|
-
this.track_info.time = duration;
|
|
3638
3429
|
});
|
|
3639
3430
|
|
|
3431
|
+
if (this.options.timestamps) {
|
|
3432
|
+
this._registerTooltip({
|
|
3433
|
+
name: 'date',
|
|
3434
|
+
chart: function chart(item) {
|
|
3435
|
+
return L._("t: ") + _this.options.timeFormat(item.time);
|
|
3436
|
+
}
|
|
3437
|
+
});
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3640
3440
|
if (this.options.time) {
|
|
3641
|
-
this.
|
|
3441
|
+
this._registerTooltip({
|
|
3642
3442
|
name: 'time',
|
|
3643
3443
|
chart: function chart(item) {
|
|
3644
|
-
return
|
|
3444
|
+
return L._("T: ") + formatTime(item.duration || 0);
|
|
3645
3445
|
}
|
|
3646
3446
|
});
|
|
3647
3447
|
|
|
@@ -3727,25 +3527,18 @@
|
|
|
3727
3527
|
} // Range of acceptable slope values.
|
|
3728
3528
|
|
|
3729
3529
|
|
|
3730
|
-
|
|
3731
|
-
var range = this.options.sRange;
|
|
3732
|
-
if (slope < range[0]) slope = range[0];else if (slope > range[1]) slope = range[1];
|
|
3733
|
-
}
|
|
3734
|
-
|
|
3735
|
-
slope = L.Util.formatNum(slope, 2);
|
|
3736
|
-
if (slope > sMax) sMax = slope;
|
|
3737
|
-
if (slope < sMin) sMin = slope;
|
|
3738
|
-
data[i].slope = slope;
|
|
3530
|
+
slope = clamp(slope, this.options.sRange);
|
|
3739
3531
|
track.ascent = tAsc;
|
|
3740
3532
|
track.descent = tDes;
|
|
3741
|
-
track.slope_max = sMax;
|
|
3742
|
-
track.slope_min = sMin;
|
|
3533
|
+
track.slope_max = slope > sMax ? slope : sMax;
|
|
3534
|
+
track.slope_min = slope < sMin ? slope : sMin;
|
|
3535
|
+
data[i].slope = L.Util.formatNum(slope, 2);
|
|
3743
3536
|
});
|
|
3744
3537
|
|
|
3745
|
-
this.
|
|
3538
|
+
this._registerTooltip({
|
|
3746
3539
|
name: 'slope',
|
|
3747
3540
|
chart: function chart(item) {
|
|
3748
|
-
return item.slope + slope.label;
|
|
3541
|
+
return L._("m: ") + item.slope + slope.label;
|
|
3749
3542
|
},
|
|
3750
3543
|
marker: function marker(item) {
|
|
3751
3544
|
return Math.round(item.slope) + slope.label;
|
|
@@ -3756,13 +3549,13 @@
|
|
|
3756
3549
|
"ascent": {
|
|
3757
3550
|
label: "Total Ascent: ",
|
|
3758
3551
|
value: function value(track) {
|
|
3759
|
-
return Math.round(track.ascent || 0) + ' ' + _this.
|
|
3552
|
+
return Math.round(track.ascent || 0) + ' ' + (_this.options.imperial ? 'ft' : 'm');
|
|
3760
3553
|
}
|
|
3761
3554
|
},
|
|
3762
3555
|
"descent": {
|
|
3763
3556
|
label: "Total Descent: ",
|
|
3764
3557
|
value: function value(track) {
|
|
3765
|
-
return Math.round(track.descent || 0) + ' ' + _this.
|
|
3558
|
+
return Math.round(track.descent || 0) + ' ' + (_this.options.imperial ? 'ft' : 'm');
|
|
3766
3559
|
}
|
|
3767
3560
|
},
|
|
3768
3561
|
"minslope": {
|
|
@@ -3784,8 +3577,8 @@
|
|
|
3784
3577
|
if (!this.options.speed && !this.options.acceleration) return;
|
|
3785
3578
|
var opts = this.options;
|
|
3786
3579
|
var speed = {};
|
|
3787
|
-
speed.label = opts.speedLabel || L._(
|
|
3788
|
-
|
|
3580
|
+
speed.label = opts.speedLabel || L._(opts.imperial ? 'mph' : 'km/h');
|
|
3581
|
+
opts.speedFactor = opts.speedFactor || 1;
|
|
3789
3582
|
|
|
3790
3583
|
if (this.options.speed && this.options.speed != "summary") {
|
|
3791
3584
|
this._registerAxisScale({
|
|
@@ -3832,7 +3625,7 @@
|
|
|
3832
3625
|
|
|
3833
3626
|
if (deltaT > 0) {
|
|
3834
3627
|
var delta = (data[i].dist - data[i > 0 ? i - 1 : i].dist) * 1000;
|
|
3835
|
-
speed = Math.abs(delta / deltaT *
|
|
3628
|
+
speed = Math.abs(delta / deltaT * opts.timeFactor) * opts.speedFactor;
|
|
3836
3629
|
} // Try to smooth "crazy" speed values.
|
|
3837
3630
|
|
|
3838
3631
|
|
|
@@ -3846,26 +3639,18 @@
|
|
|
3846
3639
|
} // Range of acceptable speed values.
|
|
3847
3640
|
|
|
3848
3641
|
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
speed = L.Util.formatNum(speed, 2);
|
|
3855
|
-
sMax = speed > sMax ? speed : sMax;
|
|
3856
|
-
sMin = speed < sMin ? speed : sMin;
|
|
3857
|
-
sAvg = (speed + sAvg) / 2.0;
|
|
3858
|
-
data[i].speed = speed;
|
|
3859
|
-
track.speed_max = sMax;
|
|
3860
|
-
track.speed_min = sMin;
|
|
3861
|
-
track.speed_avg = sAvg;
|
|
3642
|
+
speed = clamp(speed, this.options.speedRange);
|
|
3643
|
+
track.speed_max = speed > sMax ? speed : sMax;
|
|
3644
|
+
track.speed_min = speed < sMin ? speed : sMin;
|
|
3645
|
+
track.speed_avg = (speed + sAvg) / 2.0;
|
|
3646
|
+
data[i].speed = L.Util.formatNum(speed, 2);
|
|
3862
3647
|
});
|
|
3863
3648
|
|
|
3864
3649
|
if (this.options.speed) {
|
|
3865
|
-
this.
|
|
3650
|
+
this._registerTooltip({
|
|
3866
3651
|
name: 'speed',
|
|
3867
3652
|
chart: function chart(item) {
|
|
3868
|
-
return item.speed + " " + speed.label;
|
|
3653
|
+
return L._('v: ') + item.speed + " " + speed.label;
|
|
3869
3654
|
},
|
|
3870
3655
|
marker: function marker(item) {
|
|
3871
3656
|
return Math.round(item.speed) + " " + speed.label;
|
|
@@ -3899,8 +3684,8 @@
|
|
|
3899
3684
|
if (!this.options.acceleration) return;
|
|
3900
3685
|
var opts = this.options;
|
|
3901
3686
|
var acceleration = {};
|
|
3902
|
-
acceleration.label = opts.accelerationLabel || L._(
|
|
3903
|
-
|
|
3687
|
+
acceleration.label = opts.accelerationLabel || L._(opts.imperial ? 'ft/s²' : 'm/s²');
|
|
3688
|
+
opts.accelerationFactor = opts.accelerationFactor || 1;
|
|
3904
3689
|
|
|
3905
3690
|
if (this.options.acceleration != "summary") {
|
|
3906
3691
|
this._registerAxisScale({
|
|
@@ -3948,8 +3733,8 @@
|
|
|
3948
3733
|
if (deltaT > 0) {
|
|
3949
3734
|
var curr = data[i].speed;
|
|
3950
3735
|
var prev = i > 0 ? data[i - 1].speed : curr;
|
|
3951
|
-
var delta = (curr - prev) * (1000 /
|
|
3952
|
-
acceleration = Math.abs(delta / deltaT) *
|
|
3736
|
+
var delta = (curr - prev) * (1000 / opts.timeFactor);
|
|
3737
|
+
acceleration = Math.abs(delta / deltaT) * opts.accelerationFactor;
|
|
3953
3738
|
} // Try to smooth "crazy" acceleration values.
|
|
3954
3739
|
|
|
3955
3740
|
|
|
@@ -3963,25 +3748,17 @@
|
|
|
3963
3748
|
} // Range of acceptable acceleration values.
|
|
3964
3749
|
|
|
3965
3750
|
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
acceleration = L.Util.formatNum(acceleration, 2);
|
|
3972
|
-
if (acceleration > sMax) sMax = acceleration;
|
|
3973
|
-
if (acceleration < sMin) sMin = acceleration;
|
|
3974
|
-
sAvg = (acceleration + sAvg) / 2.0;
|
|
3975
|
-
data[i].acceleration = acceleration;
|
|
3976
|
-
track.acceleration_max = sMax;
|
|
3977
|
-
track.acceleration_min = sMin;
|
|
3978
|
-
track.acceleration_avg = sAvg;
|
|
3751
|
+
acceleration = clamp(acceleration, this.options.accelerationRange);
|
|
3752
|
+
track.acceleration_max = acceleration > sMax ? acceleration : sMax;
|
|
3753
|
+
track.acceleration_min = acceleration < sMin ? acceleration : sMin;
|
|
3754
|
+
track.acceleration_avg = (acceleration + sAvg) / 2.0;
|
|
3755
|
+
data[i].acceleration = L.Util.formatNum(acceleration, 2);
|
|
3979
3756
|
});
|
|
3980
3757
|
|
|
3981
|
-
this.
|
|
3758
|
+
this._registerTooltip({
|
|
3982
3759
|
name: 'acceleration',
|
|
3983
3760
|
chart: function chart(item) {
|
|
3984
|
-
return item.acceleration + " " + acceleration.label;
|
|
3761
|
+
return L._("a: ") + item.acceleration + " " + acceleration.label;
|
|
3985
3762
|
},
|
|
3986
3763
|
marker: function marker(item) {
|
|
3987
3764
|
return Math.round(item.acceleration) + " " + acceleration.label;
|
|
@@ -4048,6 +3825,19 @@
|
|
|
4048
3825
|
Elevation.Utils = _;
|
|
4049
3826
|
Elevation.Components = D3;
|
|
4050
3827
|
Elevation.Chart = Chart$1;
|
|
3828
|
+
/* Temporary fix for empty values evaluated as false (leaflet-i18n v0.3.1) */
|
|
3829
|
+
|
|
3830
|
+
(function () {
|
|
3831
|
+
var proto = L.i18n.bind({});
|
|
3832
|
+
|
|
3833
|
+
L.i18n = L._ = function (string, data) {
|
|
3834
|
+
if (L.locale && L.locales[L.locale] && L.locales[L.locale][string] == "") {
|
|
3835
|
+
L.locales[L.locale][string] = "\u200B";
|
|
3836
|
+
}
|
|
3837
|
+
|
|
3838
|
+
return proto.call(null, string, data);
|
|
3839
|
+
};
|
|
3840
|
+
})();
|
|
4051
3841
|
|
|
4052
3842
|
L.control.elevation = function (options) {
|
|
4053
3843
|
return new Elevation(options);
|