commit 2987e862540b80b2b1920618e28e6185ca74c146
parent 0cc3dff544e67195d99f557ec1fbba012311258f
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Thu, 3 Aug 2017 00:42:31 +0300
[elevation profile] make voids in graph for no-data points
Diffstat:
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/lib/leaflet.control.elevation-profile/index.js b/src/lib/leaflet.control.elevation-profile/index.js
@@ -790,11 +790,18 @@ const ElevationProfile = L.Class.extend({
return this.svgHeight - y - paddingBottom;
};
+ let startNewSegment = true;
for (i = 0; i < this.values.length; i++) {
- path.push(i ? 'L' : 'M');
+ let value = this.values[i];
+ if (value === null) {
+ startNewSegment = true;
+ continue;
+ }
+ path.push(startNewSegment ? 'M' : 'L');
x = i * horizStep;
- y = valueToSvgCoord(this.values[i]);
+ y = valueToSvgCoord(value);
path.push(x + ' ' + y + ' ');
+ startNewSegment = false;
}
path = path.join('');
createSvg('path', {d: path, 'stroke-width': '1px', stroke: 'brown', fill: 'none'}, svg);
@@ -819,7 +826,7 @@ const ElevationProfile = L.Class.extend({
for (var i = 0; i < s.length; i++) {
if (s[i]) {
if (s[i] === 'NULL') {
- v = 0;
+ v = null;
} else {
v = parseFloat(s[i]);
}