@raruto/leaflet-elevation 1.9.5 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -189,7 +189,7 @@ L.GpxGroup = L.Class.extend({
189
189
  });
190
190
 
191
191
 
192
- this._elevation.lazyLoad(this._elevation.__LGEOMUTIL).then(() => {
192
+ this._elevation.import(this._elevation.__LGEOMUTIL).then(() => {
193
193
  route.addTo(this._layers);
194
194
 
195
195
  route.eachLayer((layer) => this._onEachRouteLayer(route, layer));
@@ -279,7 +279,7 @@ L.GpxGroup = L.Class.extend({
279
279
 
280
280
  if (route && route.isSelected()) {
281
281
  if (!eleDiv) {
282
- elevation.loadChart(this._map);
282
+ elevation.addTo(this._map);
283
283
  }
284
284
  route.getLayers().forEach(function(layer) {
285
285
  if (layer instanceof L.Polyline) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raruto/leaflet-elevation",
3
- "version": "1.9.5",
3
+ "version": "2.0.1",
4
4
  "description": "A Leaflet plugin that allows to add elevation profiles using d3js",
5
5
  "main": "dist/leaflet-elevation.min.js",
6
6
  "module": "src/index.js",
@@ -45,24 +45,22 @@
45
45
  },
46
46
  "homepage": "https://github.com/Raruto/leaflet-elevation#readme",
47
47
  "devDependencies": {
48
- "@babel/core": "^7.10.2",
49
- "@babel/preset-env": "^7.10.2",
50
- "@rollup/plugin-babel": "^5.0.3",
51
48
  "postcss-copy": "^7.1.0",
52
- "postcss-import": "^12.0.1",
53
- "rollup": "^2.2.0",
49
+ "postcss-import": "^14.0.2",
50
+ "rollup": "^2.70.0",
54
51
  "rollup-plugin-commonjs": "^10.1.0",
55
52
  "rollup-plugin-git-version": "^0.3.1",
56
53
  "rollup-plugin-node-resolve": "^5.2.0",
57
- "rollup-plugin-postcss": "^2.5.0",
54
+ "rollup-plugin-postcss": "^4.0.2",
58
55
  "rollup-plugin-terser": "^7.0.2"
59
56
  },
60
57
  "peerDependencies": {
61
- "leaflet": "^1.6.0",
62
- "leaflet-gpx": "^1.5.0",
63
- "d3": "5.15.0"
58
+ "leaflet": "^1.7.0",
59
+ "d3": "6.5.0",
60
+ "@tmcw/togeojson": "4.6.0"
64
61
  },
65
62
  "dependencies": {
66
- "leaflet-i18n": "^0.3.1"
63
+ "leaflet-i18n": "^0.3.1",
64
+ "postcss": "^8.4.8"
67
65
  }
68
66
  }
@@ -1,8 +1,8 @@
1
- import 'leaflet-i18n';
2
- import * as _ from './utils';
3
- import * as D3 from './components';
1
+ import * as D3 from './d3.js';
4
2
 
5
- export var Chart = L.Class.extend({
3
+ const _ = L.Control.Elevation.Utils;
4
+
5
+ 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
 
@@ -10,7 +10,7 @@ export var Chart = L.Class.extend({
10
10
  this.options = opts;
11
11
  this.control = control;
12
12
 
13
- this._data = [];
13
+ this._data = control._data || [];
14
14
 
15
15
  // cache registered components
16
16
  this._props = {
@@ -31,10 +31,13 @@ export var Chart = L.Class.extend({
31
31
  this._brushEnabled = opts.dragging;
32
32
  this._zoomEnabled = opts.zooming;
33
33
 
34
+ opts.xTicks = this._xTicks();
35
+ opts.yTicks = this._yTicks();
36
+
34
37
  let chart = this._chart = D3.Chart(opts);
35
38
 
36
39
  // SVG Container
37
- let svg = this._container = chart.svg;
40
+ this._container = chart.svg;
38
41
 
39
42
  // Panes
40
43
  this._grid = chart.pane('grid');
@@ -49,23 +52,23 @@ export var Chart = L.Class.extend({
49
52
  this._initScale();
50
53
 
51
54
  // Helpers
52
- this._mask = chart.get('mask');
55
+ this._mask = chart.get('mask');
53
56
  this._context = chart.get('context');
54
57
  this._brush = chart.get('brush');
55
58
 
56
- this._zoom = d3.zoom();
57
- this._drag = d3.drag();
59
+ this._zoom = d3.zoom();
60
+ this._drag = d3.drag();
58
61
 
59
62
  // Interactions
60
63
  this._initInteractions();
61
64
 
62
65
  // svg.on('resize', (e)=>console.log(e.detail));
63
66
 
64
- // Handle multi-track segments (BETA)
67
+ // Handle multi-track segments
65
68
  this._maskGaps = [];
66
- control.on('eletrack_added', (e) => {
67
- this._maskGaps.push(e.index);
68
- control.once('eledata_updated', (e) => this._maskGaps.push(e.index));
69
+ control.on('eletrack_added', ({index}) => {
70
+ this._maskGaps.push(index);
71
+ control.once('elepoint_added', ({index}) => this._maskGaps.push(index));
69
72
  });
70
73
 
71
74
  },
@@ -76,6 +79,9 @@ export var Chart = L.Class.extend({
76
79
  if (props.options) this.options = props.options;
77
80
  }
78
81
 
82
+ this.options.xTicks = this._xTicks();
83
+ this.options.yTicks = this._yTicks();
84
+
79
85
  this._updateScale();
80
86
  this._updateArea();
81
87
  this._updateAxis();
@@ -94,14 +100,13 @@ export var Chart = L.Class.extend({
94
100
  this._hideDiagramIndicator()
95
101
  this._area.selectAll('path').attr("d", "M0 0");
96
102
  this._context.clearRect(0, 0, this._width(), this._height());
103
+ this._mask.selectAll(".gap").remove();
104
+ this._maskGaps = [];
97
105
 
98
106
  // if (this._path) {
99
107
  // this._x.domain([0, 1]);
100
108
  // this._y.domain([0, 1]);
101
109
  // }
102
-
103
- this._maskGaps = [];
104
- this._mask.selectAll(".gap").remove();
105
110
  },
106
111
 
107
112
  _drawPath: function(name) {
@@ -119,12 +124,10 @@ export var Chart = L.Class.extend({
119
124
  )
120
125
  );
121
126
 
122
- if (path.classed('leaflet-hidden')) return;
123
-
124
- if (this.options.preferCanvas) {
125
- _.drawCanvas(this._context, path);
126
- } else {
127
- this._area.append(() => path.node());
127
+ if (!path.classed('leaflet-hidden')) {
128
+ this.options.preferCanvas
129
+ ? _.drawCanvas(this._context, path)
130
+ : _.append(this._area.node(), path.node());
128
131
  }
129
132
  },
130
133
 
@@ -142,29 +145,27 @@ export var Chart = L.Class.extend({
142
145
  * Initialize "d3-brush".
143
146
  */
144
147
  _initBrush: function(e) {
145
- const brush = (e) => {
146
- if (!this._data.length) return;
147
- let extent = e.selection;
148
- if (extent) {
149
- let start = this._findIndexForXCoord(extent[0]);
150
- let end = this._findIndexForXCoord(extent[1]);
148
+ const brush = ({selection}) => {
149
+ if (selection && this._data.length) {
150
+ let start = this._findIndexForXCoord(selection[0]);
151
+ let end = this._findIndexForXCoord(selection[1]);
151
152
  this.fire('dragged', { dragstart: this._data[start], dragend: this._data[end] });
152
153
  }
153
154
  }
154
155
 
155
156
  const focus = (e) => {
156
- if (!this._data.length) return;
157
- if (e.type == 'brush' && !e.sourceEvent) return;
158
- let rect = this._chart.panes.brush.select('.overlay').node();
159
- let coords = d3.pointers(e, rect)[0];
160
- let xCoord = coords[0];
161
- let item = this._data[this._findIndexForXCoord(xCoord)];
162
-
163
- this.fire("mouse_move", { item: item, xCoord: xCoord });
157
+ if (this._data.length && (e.type != 'brush' /*|| e.sourceEvent*/)) {
158
+ let rect = this._chart.panes.brush.select('.overlay').node();
159
+ let coords = d3.pointers(e, rect)[0];
160
+ let xCoord = coords[0];
161
+ let item = this._data[this._findIndexForXCoord(xCoord)];
162
+
163
+ this.fire("mouse_move", { item: item, xCoord: xCoord });
164
+ }
164
165
  };
165
166
 
166
167
  this._brush
167
- .filter((e) => this._brushEnabled && !e.shiftKey && !e.button)
168
+ .filter(({shiftKey, button}) => !shiftKey && !button && this._brushEnabled)
168
169
  .on("end.update", brush)
169
170
  .on("brush.update", focus);
170
171
 
@@ -184,11 +185,11 @@ export var Chart = L.Class.extend({
184
185
 
185
186
  const zoom = this._zoom;
186
187
 
187
- const onStart = (e) => {
188
- if (e.sourceEvent && e.sourceEvent.type == "mousedown") svg.style('cursor', 'grabbing');
189
- if (e.transform.k == 1 && e.transform.x == 0) {
188
+ const onStart = ({transform, sourceEvent}) => {
189
+ if (sourceEvent && sourceEvent.type == "mousedown") svg.style('cursor', 'grabbing');
190
+ if (transform.k == 1 && transform.x == 0) {
190
191
  this._container.classed('zoomed', true);
191
- // Apply d3-zoom (bind <clipPath> mask)
192
+ // Apply d3-zoom and bind <mask>
192
193
  if (this._mask) {
193
194
  this._point.attr('mask', 'url(#' + this._mask.attr('id') + ')');
194
195
  }
@@ -196,10 +197,10 @@ export var Chart = L.Class.extend({
196
197
  this.zooming = true;
197
198
  };
198
199
 
199
- const onEnd = (e) => {
200
- if (e.transform.k ==1 && e.transform.x == 0){
200
+ const onEnd = ({transform}) => {
201
+ if (transform.k ==1 && transform.x == 0) {
201
202
  this._container.classed('zoomed', false);
202
- // Apply d3-zoom (bind <clipPath> mask)
203
+ // Reset d3-zoom and remove <mask>
203
204
  if (this._mask) {
204
205
  this._point.attr('mask', null);
205
206
  }
@@ -208,15 +209,15 @@ export var Chart = L.Class.extend({
208
209
  svg.style('cursor', '');
209
210
  };
210
211
 
211
- const onZoom = (e) => {
212
+ const onZoom = ({transform, sourceEvent}) => {
212
213
  // TODO: find a faster way to redraw the chart.
213
214
  this.zooming = false;
214
215
  this._updateScale(); // hacky way for restoring x scale when zooming out
215
216
  this.zooming = true;
216
- this._scales.distance = this._x = e.transform.rescaleX(this._x); // calculate x scale at zoom level
217
- if (this._scales.time) this._scales.time = e.transform.rescaleX(this._scales.time); // calculate x scale at zoom level
217
+ this._scales.distance = this._x = transform.rescaleX(this._x); // calculate x scale at zoom level
218
+ if (this._scales.time) this._scales.time = transform.rescaleX(this._scales.time); // calculate x scale at zoom level
218
219
  this._resetDrag();
219
- if (e.sourceEvent && e.sourceEvent.type == "mousemove") {
220
+ if (sourceEvent && sourceEvent.type == "mousemove") {
220
221
  this._hideDiagramIndicator();
221
222
  }
222
223
  this.fire('zoom');
@@ -232,7 +233,7 @@ export var Chart = L.Class.extend({
232
233
  [margin.left, -Infinity],
233
234
  [this._width() - margin.right, Infinity]
234
235
  ])
235
- .filter((e) => this._zoomEnabled && (e.shiftKey || e.buttons == 4))
236
+ .filter(({shiftKey, buttons}) => (shiftKey || buttons == 4) && this._zoomEnabled)
236
237
  .on("start", onStart)
237
238
  .on("end", onEnd)
238
239
  .on("zoom", onZoom);
@@ -254,21 +255,17 @@ export var Chart = L.Class.extend({
254
255
  * Toggle chart data on legend click
255
256
  */
256
257
  _initLegend: function() {
257
- this._container.on('legend_clicked', (e) => {
258
- let { path, legend, name, enabled } = e.detail;
259
-
260
- if (!path) return;
261
-
262
- let label = _.select('text', legend);
263
- let rect = _.select('rect', legend);
264
-
265
- _.toggleStyle(label, 'text-decoration-line', 'line-through', enabled);
266
- _.toggleStyle(rect, 'fill-opacity', '0', enabled);
267
- _.toggleClass(path, 'leaflet-hidden', enabled);
268
-
269
- this._updateArea();
270
-
271
- this.fire("elepath_toggle", { path, name, legend, enabled })
258
+ this._container.on('legend_clicked', ({detail}) => {
259
+ let { path, legend, name, enabled } = detail;
260
+ if (path) {
261
+ let label = _.select('text', legend);
262
+ let rect = _.select('rect', legend);
263
+ _.toggleStyle(label, 'text-decoration-line', 'line-through', enabled);
264
+ _.toggleStyle(rect, 'fill-opacity', '0', enabled);
265
+ _.toggleClass(path, 'leaflet-hidden', enabled);
266
+ this._updateArea();
267
+ this.fire("elepath_toggle", { path, name, legend, enabled })
268
+ }
272
269
  });
273
270
  },
274
271
 
@@ -290,26 +287,25 @@ export var Chart = L.Class.extend({
290
287
  };
291
288
 
292
289
  const position = (e, d) => {
293
- let yMax = this._height();
294
290
  let yCoord = d3.pointers(e, this._area.node())[0][1];
295
- let y = yCoord > 0 ? (yCoord < yMax ? yCoord : yMax) : 0;
296
- let z = this._y.invert(y);
297
- let data = L.extend(this._ruler.data()[0], { y: y });
291
+ let yMax = this._height();
292
+ let y = _.clamp(yCoord, [0, yMax]);
298
293
 
299
294
  this._ruler
300
- .data([data])
295
+ .data([L.extend(this._ruler.data()[0], { y: y })])
301
296
  .attr("transform", d => "translate(" + d.x + "," + d.y + ")")
302
297
  .classed('active', y < yMax);
303
298
 
304
- this._container.select(".horizontal-drag-label")
305
- .text(formatNum(z) + " " + (this.options.imperial ? 'ft' : 'm'));
299
+ this._container
300
+ .select(".horizontal-drag-label")
301
+ .text(formatNum(this._y.invert(y)) + " " + (this.options.imperial ? 'ft' : 'm'));
306
302
 
307
303
  this.fire('ruler_filter', { coords: yCoord < yMax && yCoord > 0 ? this._findCoordsForY(yCoord) : [] });
308
304
  }
309
305
 
310
306
  drag
311
- .on("start end", label)
312
- .on("drag", position);
307
+ .on("start end", label)
308
+ .on("drag", position);
313
309
 
314
310
  this._ruler.call(drag);
315
311
 
@@ -353,18 +349,17 @@ export var Chart = L.Class.extend({
353
349
  if (!props.yAttr) props.yAttr = opts.yAttr;
354
350
  if (typeof props.preferCanvas === "undefined") props.preferCanvas = opts.preferCanvas;
355
351
 
356
- let path = D3.Path(props);
357
-
358
352
  // Save paths in memory for latter usage
359
- this._paths[props.name] = path;
353
+ this._paths[props.name] = D3.Path(props);;
360
354
  this._props.areas[props.name] = props;
361
355
 
362
356
  if (opts.legend) {
363
357
  this._props.legendItems[props.name] = {
364
- name : props.name,
365
- label : props.label,
366
- color : props.color,
367
- path : path
358
+ name : props.name,
359
+ label : props.label,
360
+ color : props.color,
361
+ className: props.className,
362
+ path : this._paths[props.name]
368
363
  };
369
364
  }
370
365
 
@@ -405,12 +400,15 @@ export var Chart = L.Class.extend({
405
400
  }
406
401
 
407
402
  if (!props.ticks) {
408
- if (props.axis == 'x') props.ticks = opts.xTicks;
409
- else if (props.axis == 'y') props.ticks = opts.yTicks;
403
+ if (props.axis == 'x') props.ticks = this._xTicks.bind(this);
404
+ else if (props.axis == 'y') props.ticks = this._yTicks.bind(this);
410
405
  }
411
406
 
412
407
  this._props.axes[props.name] = props;
413
408
 
409
+ if (props.name == this.options.yScale) this._y = scale;
410
+ if (props.name == this.options.xScale) this._x = scale;
411
+
414
412
  return scale;
415
413
  },
416
414
 
@@ -420,16 +418,17 @@ export var Chart = L.Class.extend({
420
418
  _registerCheckPoint: function(point) {
421
419
  if (!this._data.length) return;
422
420
 
421
+ const {xAttr, yAttr} = this.options;
423
422
  let item, x, y;
424
423
 
425
424
  if (point.latlng) {
426
425
  item = this._data[this._findIndexForLatLng(point.latlng)];
427
- x = this._x(item.dist);
428
- y = this._y(item.z);
429
- } else if (!isNaN(point.dist)) {
430
- x = this._x(point.dist);
426
+ x = this._x(item[xAttr]);
427
+ y = this._y(item[yAttr]);
428
+ } else if (!isNaN(point[xAttr])) {
429
+ x = this._x(point[xAttr]);
431
430
  item = this._data[this._findIndexForXCoord(x)]
432
- y = this._y(item.z);
431
+ y = this._y(item[yAttr]);
433
432
  }
434
433
 
435
434
  this._point.call(D3.CheckPoint({
@@ -442,57 +441,46 @@ export var Chart = L.Class.extend({
442
441
  },
443
442
 
444
443
  _registerTooltip: function(props) {
445
- props.order = props.order ?? 100;
444
+ props.order = props.order ?? 1000;
446
445
  this._props.tooltipItems[props.name] = props;
447
446
  },
448
447
 
449
448
  _updateArea: function() {
450
- let paths = this._paths;
451
449
  // Reset and update chart profiles
452
450
  this._context.clearRect(0, 0, this._width(), this._height());
453
- for (var i in paths) {
454
- if (!paths[i].classed('leaflet-hidden')) {
455
- this._drawPath(i);
456
- }
457
- }
451
+ _.each(this._paths, (path, i) => !path.classed('leaflet-hidden') && this._drawPath(i));
458
452
  },
459
453
 
460
454
  _updateAxis: function() {
461
455
 
462
456
  let opts = this.options;
463
457
 
464
- // Reset chart axis.
465
- this._grid.selectAll('g').remove();
466
- this._axis.selectAll('g').remove();
467
-
468
- let grids = this._props.grids;
469
- let axes = this._props.axes;
470
- let props, axis, grid;
471
-
472
- let gridOpts = {
458
+ const gridOpts = {
473
459
  width : this._width(),
474
460
  height : this._height(),
475
461
  tickFormat: "",
476
462
  };
477
- let axesOpts = {
463
+
464
+ const axesOpts = {
478
465
  width : this._width(),
479
466
  height : this._height(),
480
467
  };
481
468
 
482
- // Render grids
483
- for (let i in grids) {
484
- props = L.extend({}, gridOpts, grids[i]);
485
- grid = D3.Grid(props);
486
- this._grid.call(grid);
487
- }
469
+ // Reset grids
470
+ this._grid.selectAll('g').remove();
471
+ _.each(this._props.grids, (grid, i) => {
472
+ if (opts[i] !== false && opts[i] !== 'summary') {
473
+ this._grid.call(D3.Grid(L.extend({}, gridOpts, grid)))
474
+ }
475
+ });
488
476
 
489
- // Render axis
490
- for (let i in axes) {
491
- if (opts[i] === false || opts[i] === 'summary') continue;
492
- props = L.extend({}, axesOpts, axes[i]);
493
- axis = D3.Axis(props);
494
- this._axis.call(axis);
495
- }
477
+ // Rest axis
478
+ this._axis.selectAll('g').remove();
479
+ _.each(this._props.axes, (axis, i) => {
480
+ if (opts[i] !== false && opts[i] !== 'summary') {
481
+ this._axis.call(D3.Axis(L.extend({}, axesOpts, axis)));
482
+ }
483
+ });
496
484
 
497
485
  // Adjust axis scale positions
498
486
  this._axis
@@ -515,27 +503,26 @@ export var Chart = L.Class.extend({
515
503
  },
516
504
 
517
505
  _updateClipper: function() {
518
- let margin = this.options.margins;
506
+ const { xAttr, margins } = this.options;
507
+ const data = this._data;
519
508
 
520
509
  this._zoom
521
510
  .scaleExtent([1, 10])
522
511
  .extent([
523
- [margin.left, 0],
524
- [this._width() - margin.right, this._height()]
512
+ [margins.left, 0],
513
+ [this._width() - margins.right, this._height()]
525
514
  ])
526
515
  .translateExtent([
527
- [margin.left, -Infinity],
528
- [this._width() - margin.right, Infinity]
516
+ [margins.left, -Infinity],
517
+ [this._width() - margins.right, Infinity]
529
518
  ]);
530
519
 
531
- // Apply svg mask on multi-track segments (BETA)
520
+ // Apply svg mask on multi-track segments
532
521
  this._mask.selectAll(".gap").remove()
533
522
  this._maskGaps.forEach((d, i) => {
534
523
  if(i >= this._maskGaps.length - 2) return;
535
- let d1 = this._data[this._maskGaps[i]];
536
- let d2 = this._data[this._maskGaps[i + 1]];
537
- let x1 = this._x(this._data[this._findIndexForLatLng(d1.latlng)].dist);
538
- let x2 = this._x(this._data[this._findIndexForLatLng(d2.latlng)].dist);
524
+ let x1 = this._x(data[this._findIndexForLatLng(data[this._maskGaps[i]].latlng)][xAttr]);
525
+ let x2 = this._x(data[this._findIndexForLatLng(data[this._maskGaps[i + 1]].latlng)][xAttr]);
539
526
  this._mask
540
527
  .append("rect")
541
528
  .attr("x", x1)
@@ -544,7 +531,7 @@ export var Chart = L.Class.extend({
544
531
  .attr("height", this._height())
545
532
  .attr('class', 'gap')
546
533
  .attr('fill-opacity', '0.8')
547
- .attr("fill", 'black'); // black = hide
534
+ .attr("fill", 'black'); // hide = black (mask)
548
535
  });
549
536
  },
550
537
 
@@ -552,27 +539,23 @@ export var Chart = L.Class.extend({
552
539
 
553
540
  if (this.options.legend === false) return;
554
541
 
555
- let legends = this._props.legendItems;
556
- let legend;
542
+ const legendOpts = {
543
+ width : this._width(),
544
+ height : this._height(),
545
+ margins: this.options.margins,
546
+ };
557
547
 
558
548
  // Reset legend items
559
549
  this._legend.selectAll('g').remove();
560
- for (var i in legends) {
561
- legend = D3.LegendItem(
562
- L.extend({
563
- width : this._width(),
564
- height : this._height(),
565
- margins: this.options.margins,
566
- }, legends[i])
567
- )
568
- this._legend.append("g").call(legend);
569
- }
550
+ _.each(this._props.legendItems, (legend) => {
551
+ this._legend.append("g").call(D3.LegendItem(L.extend(legendOpts, legend)));
552
+ });
570
553
 
571
554
  // Get legend items
572
555
  let items = this._legend.selectAll('.legend-item');
573
556
 
574
557
  // Calculate legend item positions
575
- let n = items.nodes().length;
558
+ let n = items.nodes().length;
576
559
  let v = Array(Math.floor(n / 2)).fill(null).map((d, i) => (i + 1) * 2 - (1 - Math.sign(n % 2)));
577
560
  let rev = v.slice().reverse().map((d) => -(d));
578
561
 
@@ -645,14 +628,18 @@ export var Chart = L.Class.extend({
645
628
  * Calculates chart width.
646
629
  */
647
630
  _width: function() {
648
- return this._chart._width;
631
+ if (this._chart) this._chart._width;
632
+ const { width, margins } = this.options;
633
+ return width - margins.left - margins.right;
649
634
  },
650
635
 
651
636
  /**
652
637
  * Calculates chart height.
653
638
  */
654
639
  _height: function() {
655
- return this._chart._height;
640
+ if (this._chart) return this._chart._height;
641
+ const { height, margins } = this.options;
642
+ return height - margins.top - margins.bottom;
656
643
  },
657
644
 
658
645
  /*
@@ -664,7 +651,7 @@ export var Chart = L.Class.extend({
664
651
 
665
652
  // save indexes of elevation values above the horizontal line
666
653
  const list = data.reduce((array, item, index) => {
667
- if (item.z >= z) array.push(index);
654
+ if (item[this.options.yAttr] >= z) array.push(index);
668
655
  return array;
669
656
  }, []);
670
657
 
@@ -749,4 +736,20 @@ export var Chart = L.Class.extend({
749
736
  _hideDiagramIndicator: function() {
750
737
  this._tooltip.attr("display", 'none');
751
738
  },
739
+
740
+ /**
741
+ * Calculate chart xTicks
742
+ */
743
+ _xTicks: function() {
744
+ if (this.__xTicks) this.__xTicks = this.options.xTicks;
745
+ return this.__xTicks || Math.round(this._width() / 75);
746
+ },
747
+
748
+ /**
749
+ * Calculate chart yTicks
750
+ */
751
+ _yTicks: function() {
752
+ if (this.__yTicks) this.__yTicks = this.options.yTicks;
753
+ return this.__yTicks || Math.round(this._height() / 30);
754
+ }
752
755
  });