heatmap.js icon indicating copy to clipboard operation
heatmap.js copied to clipboard

Supplements for heatmap.js plugins' usage in AMD, CommonJS/Node.js, ES6 contexts

Open hijiangtao opened this issue 8 years ago • 4 comments

I found the installation guidance of heatmap.js in different context, it's very useful because I am currently using Node.js as my developing back-end context, but the usage in how to include them into these kinds of context is rare. Because CommonJS/Node.js need to load variable from package, and heatmap.js' plugin has specific instance creation approach, I think it's good to include these content into current documents/README.md, such as when I use ES6 as my writting grammar, I should do as follows to make my heatmap display normally with leaflet.js in the front-end browser:

import HeatmapOverlay from 'heatmap.js/plugins/leaflet-heatmap/leaflet-heatmap.js'

let cfg = {...}
let heatmapLayer = new HeatmapOverlay(cfg);

Since the expression above will require('heatmap.js') internally, I don't need to import heatmap from 'heatmap.js' again any more.

I think other plugins should have their own instance creation approach, it would be clear if they can be pointed out. Thanks.

hijiangtao avatar Jan 22 '17 04:01 hijiangtao

hi @hijiangtao did you use the leaflet plugin from npm? ( npm install leaflet-heatmap ) because that was actually the rationale behind putting the plugins on npm, so it would only require a single import and the plugin takes care of its dependencies (in this case heatmap.js & leaflet)

pa7 avatar Jan 26 '17 21:01 pa7

Yes, actually I use import L from 'leaflet' from package manager, and the version is "leaflet": "0.7.7", but it may not have too much impact on heatmap.js, since I saw lines of codes in heatmap.js that is dealing with the compatibility of different leaflet.js' version.

And on the other hand, it's simply a single import that really matters, but I thought if you could put more information in manual(documents) about how to create a new HeatmapOverlay via given cofiguration json format, I think it may be a little difficult for Node.js freshman to do these (they may be confused about the import directory and instance's creation process).

Thanks!

hijiangtao avatar Feb 03 '17 06:02 hijiangtao

@hijiangtao thank you for the feedback, I will add some documentation about that on the heatmap.js website :)

pa7 avatar Mar 15 '17 17:03 pa7

Never mind :smile:

hijiangtao avatar Mar 16 '17 12:03 hijiangtao