GIScience / Leaflet.Heightgraph

Leaflet plugin to visualize height information and road attributes.
https://giscience.github.io/Leaflet.Heightgraph
MIT License
100 stars 42 forks source link

Backporting to d3 v3 #101

Closed alexcojocaru closed 4 years ago

alexcojocaru commented 4 years ago

Not an issue, but a "feature" request.

I have been working on embedding the heightchart into http://brouter.de/brouter-web.

Unfortunately, brouter-web is based on d3 v3 (as opposed to v5 which is used by the current version of the heightchart) and does not support ES6 features such as importing modules. Upgrading brouter-web to d3 v5 and adding ES6 transpilation support is out of the question for me.

With some changes to the Heightgraph js file, I got it to work in brouter. https://github.com/GIScience/Leaflet.Heightgraph/compare/master...alexcojocaru:d3-v3_2

Given all that, the next step is to release this as an npm package somehow, so it can be used in brouter. I could do that myself or, if you are interested in owning this fork, I could create a PR to get this into a branch of your repo, and let you manage it from here on. Since I had to understand some your changes when rebasing, merging and solving conflicts, I would prefer that you own it. But, like I said earlier, if that doesn't work for you, I could manage the fork myself.

Let me know what you think.

nrenner commented 4 years ago

Can you please open an issue for brouter-web, so we can discuss what would be needed to switch to Leaflet.Heightgraph without a backport?

boldtrn commented 4 years ago

This repository includes a Babel transpiled version of the JS. This should usually work with most build processes. Have you tried that?

alexcojocaru commented 4 years ago

Thanks for the suggestion, @boldtrn . brouter-web is peculiar in how it references d3 and the Elevation plugin which I want to replace with Heightgraph. It might be possible to use the transpiled Heightgraph from /dist though, I will try that.

alexcojocaru commented 4 years ago

I managed to integrate the transpiled Heightgraph into brouter-web, but only after commenting out some code in the transpiled js, for it was conflicting with the rest of the brouter-web code. Would it be possible to apply an IIFE to the whole code in the transpiled file, so that it does not conflict with the rest of the application?

alexcojocaru commented 4 years ago

I am closing this, as the newer https://github.com/GIScience/Leaflet.Heightgraph/issues/107 covers the same aspect in a more elegant way.