@raruto/leaflet-elevation 2.3.2 → 2.3.4

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.
@@ -6,7 +6,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
6
6
 
7
7
  includes: L.Evented ? L.Evented.prototype : L.Mixin.Events,
8
8
 
9
- initialize: function(opts, control) {
9
+ initialize(opts, control) {
10
10
  this.options = opts;
11
11
  this.control = control;
12
12
 
@@ -73,7 +73,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
73
73
 
74
74
  },
75
75
 
76
- update: function(props) {
76
+ update(props) {
77
77
  if (props) {
78
78
  if (props.data) this._data = props.data;
79
79
  if (props.options) this.options = props.options;
@@ -92,11 +92,11 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
92
92
  return this;
93
93
  },
94
94
 
95
- render: function() {
95
+ render() {
96
96
  return container => container.append(() => this._container.node());
97
97
  },
98
98
 
99
- clear: function() {
99
+ clear() {
100
100
  this._resetDrag();
101
101
  this._hideDiagramIndicator()
102
102
  this._area.selectAll('path').attr("d", "M0 0");
@@ -110,7 +110,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
110
110
  // }
111
111
  },
112
112
 
113
- _drawPath: function(name) {
113
+ _drawPath(name) {
114
114
  let path = this._paths[name];
115
115
  let area = this._props.areas[name];
116
116
 
@@ -132,7 +132,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
132
132
  }
133
133
  },
134
134
 
135
- _hasActiveLayers: function() {
135
+ _hasActiveLayers() {
136
136
  const paths = this._paths;
137
137
  for (var i in paths) {
138
138
  if (!paths[i].classed('leaflet-hidden')) {
@@ -145,7 +145,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
145
145
  /**
146
146
  * Initialize "d3-brush".
147
147
  */
148
- _initBrush: function(e) {
148
+ _initBrush(e) {
149
149
  const brush = ({selection}) => {
150
150
  if (selection && this._data.length) {
151
151
  let start = this._findIndexForXCoord(selection[0]);
@@ -180,7 +180,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
180
180
  /**
181
181
  * Initialize "d3-zoom"
182
182
  */
183
- _initClipper: function() {
183
+ _initClipper() {
184
184
  let svg = this._container;
185
185
  let margin = this.options.margins;
186
186
 
@@ -245,7 +245,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
245
245
 
246
246
  },
247
247
 
248
- _initInteractions: function() {
248
+ _initInteractions() {
249
249
  this._initBrush();
250
250
  this._initRuler();
251
251
  this._initClipper();
@@ -255,7 +255,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
255
255
  /**
256
256
  * Toggle chart data on legend click
257
257
  */
258
- _initLegend: function() {
258
+ _initLegend() {
259
259
  this._container.on('legend_clicked', ({detail}) => {
260
260
  let { path, legend, name, enabled } = detail;
261
261
  if (path) {
@@ -273,7 +273,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
273
273
  /**
274
274
  * Initialize "ruler".
275
275
  */
276
- _initRuler: function() {
276
+ _initRuler() {
277
277
  if (!this.options.ruler) return;
278
278
 
279
279
  // const yMax = this._height();
@@ -315,7 +315,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
315
315
  /**
316
316
  * Initialize x and y scales
317
317
  */
318
- _initScale: function() {
318
+ _initScale() {
319
319
  let opts = this.options;
320
320
 
321
321
  this._registerAxisScale({
@@ -340,7 +340,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
340
340
  this._y = this._scales.altitude;
341
341
  },
342
342
 
343
- _registerAreaPath: function(props) {
343
+ _registerAreaPath(props) {
344
344
  if (props.scale == 'y') props.scale = this._y;
345
345
  else if (props.scale == 'x') props.scale = this._x;
346
346
 
@@ -366,14 +366,14 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
366
366
 
367
367
  },
368
368
 
369
- _registerAxisGrid: function(props) {
369
+ _registerAxisGrid(props) {
370
370
  if (props.scale == 'y') props.scale = this._y;
371
371
  else if(props.scale == 'x') props.scale = this._x;
372
372
 
373
373
  this._props.grids[props.name || props.axis] = props;
374
374
  },
375
375
 
376
- _registerAxisScale: function(props) {
376
+ _registerAxisScale(props) {
377
377
  if (props.scale == 'y') props.scale = this._y;
378
378
  else if(props.scale == 'x') props.scale = this._x;
379
379
 
@@ -416,7 +416,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
416
416
  /**
417
417
  * Add a point of interest over the chart
418
418
  */
419
- _registerCheckPoint: function(point) {
419
+ _registerCheckPoint(point) {
420
420
  if (!this._data.length) return;
421
421
 
422
422
  const {xAttr, yAttr} = this.options;
@@ -441,18 +441,18 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
441
441
  }));
442
442
  },
443
443
 
444
- _registerTooltip: function(props) {
444
+ _registerTooltip(props) {
445
445
  props.order = props.order ?? 1000;
446
446
  this._props.tooltipItems[props.name] = props;
447
447
  },
448
448
 
449
- _updateArea: function() {
449
+ _updateArea() {
450
450
  // Reset and update chart profiles
451
451
  this._context.clearRect(0, 0, this._width(), this._height());
452
452
  _.each(this._paths, (path, i) => !path.classed('leaflet-hidden') && this._drawPath(i));
453
453
  },
454
454
 
455
- _updateAxis: function() {
455
+ _updateAxis() {
456
456
 
457
457
  let opts = this.options;
458
458
 
@@ -503,7 +503,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
503
503
 
504
504
  },
505
505
 
506
- _updateClipper: function() {
506
+ _updateClipper() {
507
507
  const { xAttr, margins } = this.options;
508
508
  const data = this._data;
509
509
 
@@ -591,7 +591,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
591
591
 
592
592
  },
593
593
 
594
- _updateMargins: function() {
594
+ _updateMargins() {
595
595
  // Get chart margins
596
596
  let xAxesB = this._axis.selectAll('.x.axis.bottom').nodes().length;
597
597
  let xAxesL = this._axis.selectAll('.y.axis.left').nodes().length;
@@ -625,7 +625,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
625
625
  }
626
626
  },
627
627
 
628
- _updateScale: function() {
628
+ _updateScale() {
629
629
  if (this.zooming) return { x: this._x, y: this._y };
630
630
 
631
631
  for (let i in this._scales) {
@@ -640,7 +640,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
640
640
  /**
641
641
  * Calculates chart width.
642
642
  */
643
- _width: function() {
643
+ _width() {
644
644
  if (this._chart) this._chart._width;
645
645
  const { width, margins } = this.options;
646
646
  return width - margins.left - margins.right;
@@ -649,7 +649,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
649
649
  /**
650
650
  * Calculates chart height.
651
651
  */
652
- _height: function() {
652
+ _height() {
653
653
  if (this._chart) return this._chart._height;
654
654
  const { height, margins } = this.options;
655
655
  return height - margins.top - margins.bottom;
@@ -658,7 +658,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
658
658
  /*
659
659
  * Finds data entries above a given y-elevation value and returns geo-coordinates
660
660
  */
661
- _findCoordsForY: function(y) {
661
+ _findCoordsForY(y) {
662
662
  let data = this._data;
663
663
  let z = this._y.invert(y);
664
664
 
@@ -691,7 +691,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
691
691
  /*
692
692
  * Finds a data entry for a given x-coordinate of the diagram
693
693
  */
694
- _findIndexForXCoord: function(x) {
694
+ _findIndexForXCoord(x) {
695
695
  return d3
696
696
  .bisector(d => d[this.options.xAttr])
697
697
  .left(this._data || [0, 1], this._x.invert(x));
@@ -700,7 +700,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
700
700
  /*
701
701
  * Finds a data entry for a given latlng of the map
702
702
  */
703
- _findIndexForLatLng: function(latlng) {
703
+ _findIndexForLatLng(latlng) {
704
704
  let result = null;
705
705
  let d = Infinity;
706
706
  this._data.forEach((item, index) => {
@@ -716,7 +716,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
716
716
  /*
717
717
  * Removes the drag rectangle and zoms back to the total extent of the data.
718
718
  */
719
- _resetDrag: function() {
719
+ _resetDrag() {
720
720
  if (this._chart.panes.brush.select(".selection").attr('width')) {
721
721
  this._chart.panes.brush.call(this._brush.clear);
722
722
  this._hideDiagramIndicator();
@@ -724,7 +724,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
724
724
  }
725
725
  },
726
726
 
727
- _resetZoom: function() {
727
+ _resetZoom() {
728
728
  if (this._zoom) {
729
729
  this._zoom.transform(this._chart.svg, d3.zoomIdentity);
730
730
  }
@@ -733,7 +733,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
733
733
  /**
734
734
  * Display distance and altitude level ("focus-rect").
735
735
  */
736
- _showDiagramIndicator: function(item, xCoordinate) {
736
+ _showDiagramIndicator(item, xCoordinate) {
737
737
  this._tooltip
738
738
  .attr("display", null)
739
739
  .call(D3.Tooltip({
@@ -761,14 +761,14 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
761
761
  }
762
762
  },
763
763
 
764
- _hideDiagramIndicator: function() {
764
+ _hideDiagramIndicator() {
765
765
  this._tooltip.attr("display", 'none');
766
766
  },
767
767
 
768
768
  /**
769
769
  * Calculate chart xTicks
770
770
  */
771
- _xTicks: function() {
771
+ _xTicks() {
772
772
  if (this.__xTicks) this.__xTicks = this.options.xTicks;
773
773
  return this.__xTicks || Math.round(this._width() / 75);
774
774
  },
@@ -776,7 +776,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
776
776
  /**
777
777
  * Calculate chart yTicks
778
778
  */
779
- _yTicks: function() {
779
+ _yTicks() {
780
780
  if (this.__yTicks) this.__yTicks = this.options.yTicks;
781
781
  return this.__yTicks || Math.round(this._height() / 30);
782
782
  }
@@ -4,7 +4,7 @@ const _ = L.Control.Elevation.Utils;
4
4
 
5
5
  export var Marker = L.Class.extend({
6
6
 
7
- initialize: function(options, control) {
7
+ initialize(options, control) {
8
8
  this.options = options;
9
9
  this.control = control
10
10
 
@@ -23,7 +23,7 @@ export var Marker = L.Class.extend({
23
23
  return this;
24
24
  },
25
25
 
26
- addTo: function(map) {
26
+ addTo(map) {
27
27
  this._map = map;
28
28
  switch(this.options.marker) {
29
29
  case 'elevation-line': this._container = d3.select(map.getPane('elevationPane')).select("svg > g").call(D3.PositionMarker({})); break;
@@ -35,7 +35,7 @@ export var Marker = L.Class.extend({
35
35
  /**
36
36
  * Update position marker ("leaflet-marker").
37
37
  */
38
- update: function(props) {
38
+ update(props) {
39
39
  if (props) this._props = props;
40
40
  else props = this._props;
41
41
 
@@ -77,7 +77,7 @@ export var Marker = L.Class.extend({
77
77
  /*
78
78
  * Hides the position/height indicator marker drawn onto the map
79
79
  */
80
- remove: function() {
80
+ remove() {
81
81
  this._props = null;
82
82
  switch(this.options.marker) {
83
83
  case 'elevation-line': this._container && this._container.classed("leaflet-hidden", true); break;
@@ -85,11 +85,11 @@ export var Marker = L.Class.extend({
85
85
  }
86
86
  },
87
87
 
88
- getLatLng: function() {
88
+ getLatLng() {
89
89
  return this._latlng;
90
90
  },
91
91
 
92
- _registerTooltip: function(props) {
92
+ _registerTooltip(props) {
93
93
  this._labels[props.name] = props;
94
94
  }
95
95
 
@@ -1,7 +1,7 @@
1
1
  const _ = L.Control.Elevation.Utils;
2
2
 
3
3
  export var Summary = L.Class.extend({
4
- initialize: function(opts, control) {
4
+ initialize(opts, control) {
5
5
  this.options = opts;
6
6
  this.control = control;
7
7
  this.labels = {};
@@ -10,20 +10,20 @@ export var Summary = L.Class.extend({
10
10
  _.style(summary, 'max-width', opts.width ? opts.width + 'px' : '');
11
11
  },
12
12
 
13
- render: function() {
13
+ render() {
14
14
  return container => container.append(() => this._container);
15
15
  },
16
16
 
17
- reset: function() {
17
+ reset() {
18
18
  this._container.innerHTML = '';
19
19
  },
20
20
 
21
- append: function(className, label, value) {
21
+ append(className, label, value) {
22
22
  this._container.innerHTML += `<span class="${className}"><span class="summarylabel">${label}</span><span class="summaryvalue">${value}</span></span>`;
23
23
  return this;
24
24
  },
25
25
 
26
- update: function() {
26
+ update() {
27
27
  Object
28
28
  .keys(this.labels)
29
29
  .sort((a, b) => this.labels[a].order - this.labels[b].order) // TODO: any performance issues?
@@ -33,7 +33,7 @@ export var Summary = L.Class.extend({
33
33
  });
34
34
  },
35
35
 
36
- _registerSummary: function(data) {
36
+ _registerSummary(data) {
37
37
  for (let i in data) {
38
38
  data[i].order = data[i].order ?? 1000;
39
39
  this.labels[i] = data[i];