-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chart waypoint names goes beyond the edge #211
Comments
Hi hupe, leaflet-elevation/src/components/chart.js Lines 416 to 442 in 3ee745d
leaflet-elevation/src/components/d3.js Lines 430 to 487 in 3ee745d
Honestly, if you don't have a clever solution, i don't think i'll get into it. Have a nice day, |
Hi @hupe13, just to give you a starting point: CSS only solution (-25deg).point > text {
text-anchor: middle;
transform: translateY(-5px) rotate(-25deg);
} JS only solution (+90deg)controlElevation.on('elechart_init elechart_axis', function(e) {
d3
.selectAll('.point > text')
.attr('dy', '-8px')
.attr("dx", (d, i, el) => (this._height() - d3.select(el[i].parentElement).datum().y /*- el[i].getComputedTextLength()*/ - 10) + 'px')
.attr('text-anchor', 'end')
.attr('transform', 'rotate(90)');
}); JS only solution (-90deg)I think this kind of skew might be more readable, Anyway, if you manage to produce something interesting we can also evaluate whether to merge it 👋 Raruto |
@hupe13 and here is a more readable solution than #211 (comment) A lot depends on the type of data you're showing (text lengths, waypoints density, chart height, ...), also for this reason I think it's not that easy to code an all-in-one (and simple) solution that can work for everyone. JS only solution (-90deg)/**
* Tested with leaflet-elevation v2.2.8:
*
* - apply -90 deg rotation (waypoint labels)
* - thinner circles style (waypoint dots)
*/
controlElevation.on('elechart_init elechart_axis', function(e) {
const pointG = this._chart._chart.pane('point');
pointG.selectAll('text')
.attr('dy', '4px')
.attr("dx", (d, i, el) => (-this._height() + d3.select(el[i].parentElement).datum().y + 5) + 'px')
.attr('text-anchor', 'start')
.attr('transform', 'rotate(-90)')
pointG.selectAll('circle')
.attr('r', '2.5')
.attr('fill', '#fff')
.attr("stroke", '#000')
.attr("stroke-width", '1.1');
}); 👋 Raruto |
Hi Raruto,
please see your example.
The name of the waypoint goes beyond the edge.. Can you please change that?
Thank you very much.
The text was updated successfully, but these errors were encountered: