Skip to content

Commit

Permalink
Merge pull request #4783 from camptocamp/GSGMF-865
Browse files Browse the repository at this point in the history
Better handling of no value in profile
  • Loading branch information
fredj committed Mar 29, 2019
2 parents 1d19c5c + 4b26eda commit feeb5d1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/profile/d3Elevation.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,16 +557,15 @@ function d3Elevation(options) {
.style('text-anchor', right ? 'end' : 'start')
.attr('transform', `translate(${xtranslate},${height - 10})`);

const yUnits = 'm';
// Display altitude on guides only if there is one line.
if (numberOfLines === 1) {
const text = elevations[0] === null ? 'no value' : formatter.yhover(elevations[0], 'm');
const hasValue = Number.isFinite(elevations[0]);
g.select('.y.grid-hover text')
.text(text)
.text(hasValue ? formatter.yhover(elevations[0], 'm') : 'no value')
.style('text-anchor', right ? 'end' : 'start')
.attr('transform', `translate(${xtranslate},${y(elevations[0]) - 10})`);
.attr('transform', `translate(${xtranslate},${hasValue ? y(elevations[0]) - 10 : 0})`);
}
hoverCallback.call(null, point, dist / xFactor, xUnits, elevationsRef, yUnits);
hoverCallback.call(null, point, dist / xFactor, xUnits, elevationsRef, 'm');
};


Expand Down

0 comments on commit feeb5d1

Please sign in to comment.