Comments (4)
Technically, this repository isn’t setup for consumption as an ES module in environments that support ES modules natively because it uses implicit file extensions in import paths. For example, in index.js, it says:
export {default as hexbin} from "./src/hexbin";
But to be valid ES, it should say:
export {default as hexbin} from "./src/hexbin.js";
This will be fixed in a future version (across all of the D3 modules).
I mention this because the ability to consume this library as an ES module therefore currently requires you to use a nonstandard build tool such as Rollup or webpack. You must configure this tool to observe the module
entry point defined in the package.json if you want to be able to import this library using a bare module specifier (and currently that module entry point has an implicit file extension: index
instead of index.js
). Assuming you have configured your build tool to find the intended entry point, there are two valid styles of imports.
The first is to import the library as a namespace:
import * as d3Hexbin from "d3-hexbin";
const hexbin = d3Hexbin.hexbin();
The second is to import individual symbols:
import {hexbin as Hexbin} from "d3-hexbin";
const hexbin = Hexbin();
Since this library only has one export (hexbin
), I’d probably chose the latter, but it’s up to you.
from d3-hexbin.
Hey @mbostock was there ever an update on this, or should we continue with the import * as d3Hexbin from 'd3-hexbin';
as the method of importing?
from d3-hexbin.
Really appreciate the details here. Im not prepared to roll my own D3, but I can see it might be valuable to do so, but I've wasted enough life energy on webpack and yarn etc.... In the meantime, I just copied hexbin.js elsewhere, changed "default" to
export function hex() {...}
then
import { hex } from "../location";
then:
var hexmap = hex()...
This might be bad, but its working. Thanks as always.
from d3-hexbin.
@mbostock @NicholasCanova I second this. Is the above method mentioned still the way to do it?
from d3-hexbin.
Related Issues (17)
- Support Canvas. HOT 2
- "or as part of D3 4.0" statement in the readme does not appear to be true for d3.v4 version 4.2.7
- Inconsistency between README and global namespace
- Rounded Edges HOT 1
- Function .centers() returns only 3 items HOT 1
- bin(point)?
- implicit dependency on d3 HOT 2
- Use d3-hexbin with Angular 8 HOT 1
- Incremental binning (add and remove). HOT 1
- HexBin ordering HOT 2
- Cannot properly fill mesh hexagons HOT 3
- Row vs Column Offset Issues HOT 1
- Forced Label Layout HOT 1
- 1.0 release.
- Take d3.hexbin when available HOT 4
- Hexgrid Rotation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-hexbin.