leaflet-hexbin 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/index.es.js +101 -100
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/HexbinLayer.d.ts +5 -0
- package/package.json +3 -3
package/README.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Leaflet hexbin plugin
|
2
|
+
|
3
|
+
[](https://www.npmjs.com/package/leaflet-hexbin)
|
4
|
+
|
5
|
+
A leaflet plugin to create hexagonal heatmaps using [d3-hexbin](https://github.com/d3/d3-hexbin).
|
6
|
+
This visualization is useful for displaying density of points on a map.
|
7
|
+
|
8
|
+
Inspired from [@asymmetrik/leaflet-d3](https://github.com/bluehalo/leaflet-d3)
|
9
|
+
|
10
|
+
**[Documentation and demo](https://lsdch.github.io/leaflet-hexbin/)**
|
package/dist/index.es.js
CHANGED
@@ -1,53 +1,53 @@
|
|
1
|
-
import * as
|
2
|
-
import { scaleLinear as y, dispatch as
|
3
|
-
import { hexbin as
|
4
|
-
import * as
|
5
|
-
var
|
1
|
+
import * as f from "d3";
|
2
|
+
import { scaleLinear as y, dispatch as R, select as L, extent as T } from "d3";
|
3
|
+
import { hexbin as w } from "d3-hexbin";
|
4
|
+
import * as c from "leaflet";
|
5
|
+
var v;
|
6
6
|
((r) => {
|
7
7
|
function t() {
|
8
8
|
return {
|
9
|
-
mouseover: function(
|
10
|
-
|
11
|
-
return
|
9
|
+
mouseover: function(u, n, s, p) {
|
10
|
+
f.select(u.parentElement).select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("d", function(h) {
|
11
|
+
return n._hexLayout.hexagon(n.options.radius);
|
12
12
|
});
|
13
13
|
},
|
14
|
-
mouseout: function(
|
15
|
-
|
16
|
-
return
|
14
|
+
mouseout: function(u, n, s, p) {
|
15
|
+
f.select(u.parentElement).select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("d", function(h) {
|
16
|
+
return n._hexLayout.hexagon(n._scale.radius(n._fn.radiusValue.call(n, h)));
|
17
17
|
});
|
18
18
|
}
|
19
19
|
};
|
20
20
|
}
|
21
21
|
r.resizeFill = t;
|
22
|
-
function
|
22
|
+
function i(u = 1.5) {
|
23
23
|
return {
|
24
|
-
mouseover: function(
|
25
|
-
|
26
|
-
return s._hexLayout.hexagon(s._scale.radius.range()[1] *
|
24
|
+
mouseover: function(n, s, p, d) {
|
25
|
+
f.select(n.parentElement).select("path.hexbin-hexagon").transition().duration(s.options.duration).attr("d", function() {
|
26
|
+
return s._hexLayout.hexagon(s._scale.radius.range()[1] * u);
|
27
27
|
});
|
28
28
|
},
|
29
|
-
mouseout: function(
|
30
|
-
|
29
|
+
mouseout: function(n, s, p, d) {
|
30
|
+
f.select(n.parentElement).select("path.hexbin-hexagon").transition().duration(s.options.duration).attr("d", (g) => s._hexLayout.hexagon(s._scale.radius(s._fn.radiusValue.call(s, g))));
|
31
31
|
}
|
32
32
|
};
|
33
33
|
}
|
34
|
-
r.resizeScale =
|
35
|
-
function
|
34
|
+
r.resizeScale = i;
|
35
|
+
function o(u = [l()]) {
|
36
36
|
return {
|
37
|
-
mouseover: function(
|
38
|
-
|
39
|
-
h.mouseover(
|
37
|
+
mouseover: function(n, s, p, d) {
|
38
|
+
u.forEach((h) => {
|
39
|
+
h.mouseover(n, s, p, d);
|
40
40
|
});
|
41
41
|
},
|
42
|
-
mouseout: function(
|
43
|
-
|
44
|
-
h.mouseout(
|
42
|
+
mouseout: function(n, s, p, d) {
|
43
|
+
u.forEach((h) => {
|
44
|
+
h.mouseout(n, s, p, d);
|
45
45
|
});
|
46
46
|
}
|
47
47
|
};
|
48
48
|
}
|
49
|
-
r.compound =
|
50
|
-
function
|
49
|
+
r.compound = o;
|
50
|
+
function l() {
|
51
51
|
return {
|
52
52
|
mouseover: function() {
|
53
53
|
},
|
@@ -55,13 +55,13 @@ var b;
|
|
55
55
|
}
|
56
56
|
};
|
57
57
|
}
|
58
|
-
r.none =
|
59
|
-
})(
|
60
|
-
const
|
61
|
-
function
|
62
|
-
return r instanceof
|
58
|
+
r.none = l;
|
59
|
+
})(v || (v = {}));
|
60
|
+
const V = v;
|
61
|
+
function O(r) {
|
62
|
+
return r instanceof c.LatLng || typeof r == "object" && "lat" in r && "lng" in r || Array.isArray(r) && r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number";
|
63
63
|
}
|
64
|
-
class
|
64
|
+
class C extends c.SVG {
|
65
65
|
constructor(t) {
|
66
66
|
super(), this.options = {
|
67
67
|
radius: 12,
|
@@ -75,25 +75,26 @@ class H extends l.SVG {
|
|
75
75
|
colorRange: ["#f7fbff", "#08306b"],
|
76
76
|
radiusRange: null,
|
77
77
|
pointerEvents: "all",
|
78
|
+
noRedraw: !1,
|
78
79
|
// Handle parent default options
|
79
80
|
// ...L.SVG.prototype.options,
|
80
|
-
...
|
81
|
-
...
|
81
|
+
...c.Renderer.prototype.options,
|
82
|
+
...c.Layer.prototype.options
|
82
83
|
}, this._fn = {
|
83
|
-
lng: (
|
84
|
-
lat: (
|
85
|
-
colorValue: (
|
86
|
-
radiusValue: (
|
87
|
-
opacityValue: (
|
88
|
-
fill: (
|
89
|
-
const
|
90
|
-
return
|
84
|
+
lng: (i) => c.latLng(this._accessor(i)).lng,
|
85
|
+
lat: (i) => c.latLng(this._accessor(i)).lat,
|
86
|
+
colorValue: (i) => i.length,
|
87
|
+
radiusValue: (i) => i.length,
|
88
|
+
opacityValue: (i) => i.length,
|
89
|
+
fill: (i) => {
|
90
|
+
const o = this._fn.colorValue(i);
|
91
|
+
return o != null ? this._scale.color(o) : "none";
|
91
92
|
}
|
92
93
|
}, this._scale = {
|
93
94
|
color: y(),
|
94
95
|
radius: y(),
|
95
96
|
opacity: y()
|
96
|
-
}, this._dispatch =
|
97
|
+
}, this._dispatch = R("mouseover", "mouseout", "click"), this._hoverHandler = V.none(), this._hexLayout = w().radius(this.options.radius).x(({ point: [i, o] }) => i).y(({ point: [i, o] }) => o), this._data = Array(), this._tooltipOptions = {}, this.options = { ...this.options, ...t }, this._scale.color.range(this.options.colorRange).clamp(!0), this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(!0), this._scale.opacity.range(
|
97
98
|
typeof this.options.opacity == "number" ? [this.options.opacity, this.options.opacity] : this.options.opacity
|
98
99
|
).clamp(!0);
|
99
100
|
}
|
@@ -112,12 +113,12 @@ class H extends l.SVG {
|
|
112
113
|
* @param map Reference to the map to which this layer has been added
|
113
114
|
*/
|
114
115
|
onAdd(t) {
|
115
|
-
var
|
116
|
-
return super.onAdd(t), this._map = t, (
|
116
|
+
var i;
|
117
|
+
return super.onAdd(t), this._map = t, (i = this._tooltip) == null || i.setLatLng([0, 0]).addTo(t), t.on("moveend", this.redraw, this), this.redraw(), this;
|
117
118
|
}
|
118
119
|
_project(t) {
|
119
|
-
const { x:
|
120
|
-
return [
|
120
|
+
const { x: i, y: o } = this._map.latLngToLayerPoint(t);
|
121
|
+
return [i, o];
|
121
122
|
}
|
122
123
|
/**
|
123
124
|
* Callback made by Leaflet when the layer is removed from the map
|
@@ -140,54 +141,54 @@ class H extends l.SVG {
|
|
140
141
|
redraw() {
|
141
142
|
const t = this;
|
142
143
|
if (!t._map) return;
|
143
|
-
const
|
144
|
-
const s = t._accessor(
|
145
|
-
return { coord: s, point: p, data:
|
146
|
-
}),
|
147
|
-
return "hexbin zoom-" +
|
148
|
-
}).merge(
|
149
|
-
|
150
|
-
}
|
151
|
-
_linearlySpace(t,
|
152
|
-
const
|
153
|
-
return Array.from({ length:
|
154
|
-
}
|
155
|
-
_createHexagons(t,
|
156
|
-
const
|
157
|
-
({ x: e, y: a }) =>
|
158
|
-
), s =
|
144
|
+
const i = t._data.map((n) => {
|
145
|
+
const s = t._accessor(n), p = t._project(s);
|
146
|
+
return { coord: s, point: p, data: n };
|
147
|
+
}), o = this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()], (n) => n), u = o.enter().append("g").attr("class", function(n) {
|
148
|
+
return "hexbin zoom-" + n;
|
149
|
+
}).merge(o);
|
150
|
+
o.exit().remove(), this._createHexagons(u, i);
|
151
|
+
}
|
152
|
+
_linearlySpace(t, i, o) {
|
153
|
+
const l = (i - t) / Math.max(o - 1, 1);
|
154
|
+
return Array.from({ length: o }, (u, n) => t + n * l);
|
155
|
+
}
|
156
|
+
_createHexagons(t, i) {
|
157
|
+
const o = this, l = o._map.getSize(), u = o._map.getBounds().pad(o.options.radius * 2 / Math.max(l.x, l.y)), n = o._hexLayout(i).filter(
|
158
|
+
({ x: e, y: a }) => u.contains(o._map.layerPointToLatLng(c.point(e, a)))
|
159
|
+
), s = o._getExtent(n, o._fn.colorValue, o.options.colorScaleExtent), p = o._getExtent(n, o._fn.radiusValue, o.options.radiusScaleExtent), d = o._getExtent(n, o._fn.opacityValue, o.options.opacityScaleExtent), h = this.options.colorDomain ?? o._linearlySpace(
|
159
160
|
s[0],
|
160
161
|
s[1],
|
161
|
-
|
162
|
+
o._scale.color.range().length
|
162
163
|
), g = this.options.radiusDomain || p;
|
163
|
-
|
164
|
-
const m = t.selectAll("g.hexbin-container").data(
|
165
|
-
m.select("path.hexbin-hexagon").transition().duration(
|
166
|
-
const x = m.enter().append("g").attr("class", "hexbin-container").style("pointer-events",
|
164
|
+
o._scale.color.domain(h), o._scale.radius.domain(g), o._scale.opacity.domain(d);
|
165
|
+
const m = t.selectAll("g.hexbin-container").data(n, ({ x: e, y: a }) => `${e}:${a}`);
|
166
|
+
m.select("path.hexbin-hexagon").transition().duration(o.options.duration).attr("fill", o._fn.fill.bind(o)).attr("fill-opacity", (e) => o._scale.opacity(o._fn.opacityValue.call(o, e))).attr("stroke-opacity", (e) => o._scale.opacity(o._fn.opacityValue.call(o, e))).attr("d", (e) => o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o, e))));
|
167
|
+
const x = m.enter().append("g").attr("class", "hexbin-container").style("pointer-events", o.options.pointerEvents);
|
167
168
|
x.on("mouseover", function(e, a) {
|
168
169
|
L(this).raise();
|
169
170
|
});
|
170
|
-
const
|
171
|
-
|
172
|
-
var
|
173
|
-
(
|
174
|
-
typeof
|
171
|
+
const b = x.append("path").attr("class", "hexbin-hexagon").attr("transform", ({ x: e, y: a }) => `translate(${e},${a})`).attr("d", () => o._hexLayout.hexagon(o._scale.radius.range()[0])).attr("fill", o._fn.fill.bind(o)).attr("fill-opacity", 0.01).attr("stroke-opacity", 0.01).style("pointer-events", "all");
|
172
|
+
b.transition().duration(o.options.duration).attr("fill-opacity", (e) => o._scale.opacity(o._fn.opacityValue.call(o, e))).attr("stroke-opacity", (e) => o._scale.opacity(o._fn.opacityValue.call(o, e))).attr("d", (e) => o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o, e)))).style("pointer-events", "all"), x.append("path").attr("class", "hexbin-grid").attr("transform", ({ x: e, y: a }) => `translate(${e},${a})`).attr("d", () => o._hexLayout.hexagon(o.options.radius)).attr("fill", "none").attr("stroke", "none"), b.on("mouseover", function(e, a) {
|
173
|
+
var _, S;
|
174
|
+
(_ = o._tooltipOptions) != null && _.content && ((S = o._tooltip) == null || S.setContent(
|
175
|
+
typeof o._tooltipOptions.content == "function" ? o._tooltipOptions.content(a) : o._tooltipOptions.content
|
175
176
|
).setLatLng(
|
176
|
-
|
177
|
-
).openOn(
|
177
|
+
o._map.layerPointToLatLng(c.point(a.x, a.y))
|
178
|
+
).openOn(o._map)), o._hoverHandler.mouseover(this, o, e, a), o._dispatch.call("mouseover", this, a, o, e), this.classList.add("hover");
|
178
179
|
}).on("mouseout", function(e, a) {
|
179
|
-
var
|
180
|
-
(
|
180
|
+
var _;
|
181
|
+
(_ = o._tooltip) == null || _.close(), o._hoverHandler.mouseout(this, o, e, a), o._dispatch.call("mouseout", this, a, o, e), this.classList.remove("hover");
|
181
182
|
}).on("click", function(e, a) {
|
182
|
-
const
|
183
|
-
|
183
|
+
const _ = o._map.layerPointToLatLng(c.point(a.x, a.y));
|
184
|
+
o._dispatch.call("click", this, a, _, o, e), e.stopPropagation();
|
184
185
|
});
|
185
|
-
const
|
186
|
-
|
186
|
+
const E = m.exit();
|
187
|
+
E.select("path.hexbin-hexagon").transition().duration(o.options.duration).attr("fill-opacity", 0).attr("stroke-opacity", 0).attr("d", (e) => o._hexLayout.hexagon(0)), E.transition().duration(o.options.duration).remove();
|
187
188
|
}
|
188
|
-
_getExtent(t,
|
189
|
-
let
|
190
|
-
return (
|
189
|
+
_getExtent(t, i, o) {
|
190
|
+
let l = T(t, i.bind(this));
|
191
|
+
return (l[0] === void 0 || l[1] === void 0) && (l = [0, 0]), o[0] != null && (l[0] = o[0]), o[1] != null && (l[1] = o[1]), l;
|
191
192
|
}
|
192
193
|
radius(t) {
|
193
194
|
return t === void 0 ? this.options.radius : (this.options.radius = t, this._hexLayout.radius(t), this.options.radiusRange == null && this._scale.radius.range([this.options.radius, this.options.radius]).clamp(!0), this);
|
@@ -235,8 +236,8 @@ class H extends l.SVG {
|
|
235
236
|
return t === void 0 ? this._fn.fill : (this._fn.fill = t, this);
|
236
237
|
}
|
237
238
|
// Implementation
|
238
|
-
data(t,
|
239
|
-
return t === void 0 ? this._data : (!
|
239
|
+
data(t, i) {
|
240
|
+
return t === void 0 ? this._data : (!O(t[0]) && !i && console.error("Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression"), this._data = t ?? [], this._accessor = i ?? ((o) => o), this.options.noRedraw || this.redraw(), this);
|
240
241
|
}
|
241
242
|
/*
|
242
243
|
* Getter for the event dispatcher
|
@@ -245,17 +246,17 @@ class H extends l.SVG {
|
|
245
246
|
return this._dispatch;
|
246
247
|
}
|
247
248
|
hoverHandler(t) {
|
248
|
-
return t === void 0 ? this._hoverHandler : (this._hoverHandler = t ??
|
249
|
+
return t === void 0 ? this._hoverHandler : (this._hoverHandler = t ?? V.none(), this.options.noRedraw || this.redraw(), this);
|
249
250
|
}
|
250
251
|
// Cannot overload bindTooltip() with data dependant content
|
251
252
|
tooltip(t) {
|
252
|
-
return this._tooltipOptions = t, this._tooltip ? this._tooltip.options = t.options ?? {} : this._tooltip =
|
253
|
+
return this._tooltipOptions = t, this._tooltip ? this._tooltip.options = t.options ?? {} : this._tooltip = c.tooltip(t.options), this;
|
253
254
|
}
|
254
255
|
getTooltip() {
|
255
256
|
return this._tooltip;
|
256
257
|
}
|
257
|
-
bindTooltip(t,
|
258
|
-
return t instanceof
|
258
|
+
bindTooltip(t, i) {
|
259
|
+
return t instanceof c.Tooltip ? (this._tooltip = t, this._map && this._tooltip.setLatLng([0, 0]).addTo(this._map)) : this._tooltip = c.tooltip(i).setContent(t), this;
|
259
260
|
}
|
260
261
|
unbindTooltip() {
|
261
262
|
var t;
|
@@ -266,26 +267,26 @@ class H extends l.SVG {
|
|
266
267
|
*/
|
267
268
|
getLatLngs() {
|
268
269
|
const t = this;
|
269
|
-
return this._data.map(function(
|
270
|
-
return
|
270
|
+
return this._data.map(function(i) {
|
271
|
+
return c.latLng(t._fn.lat(i), t._fn.lng(i));
|
271
272
|
});
|
272
273
|
}
|
273
274
|
/*
|
274
275
|
* Get path geometry as GeoJSON
|
275
276
|
*/
|
276
277
|
toGeoJSON() {
|
277
|
-
return
|
278
|
+
return c.GeoJSON.getFeature(this, {
|
278
279
|
type: "MultiPoint",
|
279
|
-
coordinates:
|
280
|
+
coordinates: c.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)
|
280
281
|
});
|
281
282
|
}
|
282
283
|
}
|
283
|
-
function
|
284
|
-
return new
|
284
|
+
function A(r) {
|
285
|
+
return new C(r);
|
285
286
|
}
|
286
287
|
export {
|
287
|
-
|
288
|
-
|
289
|
-
|
288
|
+
V as HexbinHoverHandler,
|
289
|
+
C as HexbinLayer,
|
290
|
+
A as hexbinLayer
|
290
291
|
};
|
291
292
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/HexbinHoverHandler.ts","../src/HexbinLayer.ts"],"sourcesContent":["import * as d3 from 'd3';\nimport type { HexbinData } from './HexbinLayer';\nimport { type HexbinLayer } from './HexbinLayer';\n\nexport interface HexbinHoverHandler<Data> {\n mouseover(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n mouseout(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n}\n\nexport namespace HexbinHoverHandler {\n\n export function resizeFill(): HexbinHoverHandler<any> {\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.options.radius);\n });\n },\n mouseout: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n\n }\n\n export interface ResizeScaleOptions {\n radiusScale?: number;\n duration?: number;\n }\n\n export function resizeScale(radiusScale: number = 1.5): HexbinHoverHandler<any> {\n\n // return the handler instance\n return {\n mouseover: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function () {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius.range()[1] * (radiusScale));\n });\n },\n mouseout: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement!);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', (d) => {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n }\n\n\n export function compound<Data>(handlers: HexbinHoverHandler<Data>[] = [none()]): HexbinHoverHandler<Data> {\n return {\n mouseover: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseover(svg, hexLayer, event, data); });\n },\n mouseout: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseout(svg, hexLayer, event, data); });\n }\n };\n }\n\n export function none(): HexbinHoverHandler<any> {\n return {\n mouseover: function () { },\n mouseout: function () { }\n };\n }\n\n}\nexport default HexbinHoverHandler\n","import { scaleLinear, dispatch, select, extent } from 'd3';\nimport { hexbin, type HexbinBin } from 'd3-hexbin';\nimport * as L from 'leaflet';\nimport HexbinHoverHandler from './HexbinHoverHandler';\n\n// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\n\ntype TooltipOptions<Data> = {\n options?: L.TooltipOptions,\n content?: L.Content | ((d: HexbinData<Data>[]) => L.Content)\n}\n\nexport interface HexbinLayerConfig {\n /**\n * Hex grid cell radius in pixels.\n * This value should be a positive number.\n * This radius controls the radius of the hexagons used to bin the data\n * but not necessarily to draw each individual hexbin.\n * @default 12\n */\n radius?: number,\n /**\n * Sets the opacity on the hexbin layer.\n * This value should be a number between 0 and 1.\n * If an array is provided, the first element is the minimum opacity and the second is the maximum.\n * @default 0.6\n */\n opacity?: number | [number, number],\n /**\n * Opacity scale extent: [min, max] domain for opacity interpolation.\n * @default [1, undefined]\n */\n opacityScaleExtent?: [number, number | undefined],\n /**\n * Duration of transition in milliseconds.\n * @default 200\n */\n duration?: number,\n\n /**\n * Color scale extent: [min, max] domain for color interpolation.\n * @default [1, undefined]\n */\n colorScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the color domain from the data.\n * Normally, you can tweak the generation of the color domain using the colorScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the color scale before rendering.\n * @default null\n */\n colorDomain?: number[] | null\n /**\n * Color range used to fill the hexbins.\n * @default ['#f7fbff', '#08306b']\n */\n colorRange?: string[],\n\n /**\n * Radius scale extent: [min, max] domain for radius interpolation.\n * @default [1, undefined]\n */\n radiusScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the radius domain from the data.\n * Normally, you can tweak the generation of the radius domain using the radiusScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the radius scale before rendering.\n * @default null\n */\n radiusDomain?: number[] | null\n /**\n * Sets the range of the radius scale used to size the hexbins.\n * @default hex grid cell radius\n */\n radiusRange?: [number, number] | null,\n\n /**\n * You should only modify this config option if you want to change the mouse event behavior on hexbins. This will modify when the events are propagated based on the visibility state and/or part of the hexbin being hovered.\n * @default 'all'\n */\n pointerEvents?: string\n}\n\n/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData<Data> = {\n data: Data;\n coord: L.LatLngExpression;\n point: Readonly<[number, number]>;\n}\n\n\nfunction isLatLngExpression(d: any): d is L.LatLngExpression {\n return (\n d instanceof L.LatLng ||\n (typeof d === 'object' && \"lat\" in d && \"lng\" in d) ||\n (Array.isArray(d) && d.length === 2 && typeof d[0] === 'number' && typeof d[1] === 'number')\n )\n}\n\n/**\n * Instantiate a hexbin layer.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {\n options: Required<HexbinLayerConfig> & L.RendererOptions = {\n radius: 12,\n opacity: 0.6,\n duration: 200,\n\n colorScaleExtent: [1, undefined],\n radiusScaleExtent: [1, undefined],\n opacityScaleExtent: [1, undefined],\n colorDomain: null,\n radiusDomain: null,\n colorRange: ['#f7fbff', '#08306b'],\n radiusRange: null,\n\n pointerEvents: 'all',\n // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n _fn = {\n lng: (d: Data) => L.latLng(this._accessor(d)).lng,\n lat: (d: Data) => L.latLng(this._accessor(d)).lat,\n colorValue: (d: HexbinData<Data>[]) => d.length,\n radiusValue: (d: HexbinData<Data>[]) => d.length,\n opacityValue: (d: HexbinData<Data>[]) => d.length,\n fill: (d: HexbinData<Data>[]) => {\n const val = this._fn.colorValue(d);\n return (null != val) ? this._scale.color(val) : 'none';\n }\n }\n // Set up the customizable scale\n _scale = {\n color: scaleLinear<string, string>(),\n radius: scaleLinear(),\n opacity: scaleLinear()\n };\n\n // Set up the Dispatcher for managing events and callbacks\n _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n _hoverHandler: HexbinHoverHandler<Data> = HexbinHoverHandler.none();\n\n // Create the hex layout\n _hexLayout = hexbin<HexbinData<Data>>()\n .radius(this.options.radius)\n .x(({ point: [x, _] }) => x)\n .y(({ point: [_, y] }) => y);\n\n // Initialize the data array to be empty\n _data = Array<Data>()\n\n\n declare _map: L.Map;\n\n _tooltipOptions: TooltipOptions<Data> = {};\n declare _tooltip: L.Tooltip | undefined;\n\n declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare _d3Container: d3.Selection<SVGGElement, unknown, null, undefined>;\n\n public constructor(options?: HexbinLayerConfig) {\n super()\n // L.SVG.prototype.initialize.call(this, options);\n this.options = { ...this.options, ...options };\n this._scale.color\n .range(this.options.colorRange)\n .clamp(true);\n\n this._scale.radius\n .range(this.options.radiusRange ?? [this.options.radius, this.options.radius])\n .clamp(true);\n\n this._scale.opacity\n .range(\n typeof this.options.opacity === 'number'\n ? [this.options.opacity, this.options.opacity]\n : this.options.opacity\n ).clamp(true);\n\n };\n\n _accessor(d: Data) {\n return d as L.LatLngExpression;\n }\n\n /**\n * Create the SVG container for the hexbins\n * @private\n */\n _initContainer() {\n super._initContainer();\n this._d3Container = select(this._container).select<SVGElementTagNameMap['g']>('g');\n }\n /**\n * Callback made by Leaflet when the layer is added to the map\n * @param map Reference to the map to which this layer has been added\n */\n onAdd(map: L.Map): this {\n // Call super.onAdd to properly initialize the SVG pane\n super.onAdd(map)\n\n // Store a reference to the map for later use\n this._map = map;\n this._tooltip?.setLatLng([0, 0]).addTo(map);\n // Redraw on moveend\n map.on('moveend', this.redraw, this);\n // Initial draw\n this.redraw();\n return this\n }\n\n _project(latlng: L.LatLngExpression) {\n const { x, y } = this._map.latLngToLayerPoint(latlng);\n return [x, y] as const;\n }\n\n /**\n * Callback made by Leaflet when the layer is removed from the map\n * @param map Reference to the map from which this layer is being removed\n */\n onRemove(map: L.Map): this {\n // Destroy the svg container\n this._destroyContainer();\n // Remove events\n map.off('moveend', this.redraw, this);\n return this\n }\n\n /**\n * Clean up the svg container\n * @private\n */\n _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n * @private\n */\n redraw() {\n const that = this;\n\n if (!that._map) return\n\n // Generate the mapped version of the data\n const data = that._data.map<HexbinData<Data>>((d: Data) => {\n const coord = that._accessor(d)\n const point = that._project(coord);\n return { coord: coord, point, data: d };\n });\n\n // Select the hex group for the current zoom level. This has\n // the effect of recreating the group if the zoom level has changed\n const join = this._d3Container.selectAll<SVGGElement, number>('g.hexbin')\n .data<number>([this._map.getZoom()], (d) => d);\n\n // enter\n const enter = join.enter().append('g')\n .attr('class', function (d) { return 'hexbin zoom-' + d; });\n\n // enter + update\n const enterUpdate = enter.merge(join);\n\n // exit\n join.exit().remove();\n\n // add the hexagons to the select\n this._createHexagons(enterUpdate, data);\n\n }\n\n _linearlySpace(from: number, to: number, length: number): number[] {\n const step = (to - from) / Math.max(length - 1, 1);\n return Array.from({ length }, (_, i) => from + (i * step));\n }\n\n _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData<Data>[]) {\n const thisLayer = this;\n\n // Create the bins using the hexbin layout\n\n // Generate the map bounds (to be used to filter the hexes to what is visible)\n const size = thisLayer._map.getSize();\n const bounds = thisLayer._map.getBounds().pad(thisLayer.options.radius * 2 / Math.max(size.x, size.y));\n\n const bins = thisLayer._hexLayout(data).filter(\n ({ x, y }) => bounds.contains(thisLayer._map.layerPointToLatLng(L.point(x, y)))\n );\n\n // Derive the extents of the data values for each dimension\n const colorExtent = thisLayer._getExtent(bins, thisLayer._fn.colorValue, thisLayer.options.colorScaleExtent);\n const radiusExtent = thisLayer._getExtent(bins, thisLayer._fn.radiusValue, thisLayer.options.radiusScaleExtent);\n const opacityExtent = thisLayer._getExtent(bins, thisLayer._fn.opacityValue, thisLayer.options.opacityScaleExtent);\n\n // Match the domain cardinality to that of the color range, to allow for a polylinear scale\n const colorDomain = this.options.colorDomain\n ?? thisLayer._linearlySpace(\n colorExtent[0],\n colorExtent[1],\n thisLayer._scale.color.range().length\n );\n const radiusDomain = this.options.radiusDomain || radiusExtent;\n\n // Set the scale domains\n thisLayer._scale.color.domain(colorDomain);\n thisLayer._scale.radius.domain(radiusDomain);\n thisLayer._scale.opacity.domain(opacityExtent);\n\n\n /*\n * Join\n * Join the Hexagons to the data\n * Use a deterministic id for tracking bins based on position\n */\n const join = g.selectAll<SVGGElement, HexbinBin<HexbinData<Data>>>('g.hexbin-container')\n .data(bins, ({ x, y }) => `${x}:${y}`);\n\n\n /*\n * Update\n * Set the fill and opacity on a transition\n * opacity is re-applied in case the enter transition was cancelled\n * the path is applied as well to resize the bins\n */\n join.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => {\n return thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d)));\n });\n\n\n /*\n * Enter\n * Establish the path, size, fill, and the initial opacity\n * Transition to the final opacity and size\n */\n const container = join.enter().append('g').attr('class', 'hexbin-container')\n .style('pointer-events', thisLayer.options.pointerEvents);\n\n\n container.on('mouseover', function (this: SVGGElement, d: MouseEvent, i) {\n // Bring container to foreground by re-appending it to the DOM\n select<SVGGElement, HexbinBin<HexbinData<Data>>>(this).raise();\n })\n\n const hexagons = container.append('path').attr('class', 'hexbin-hexagon')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer._scale.radius.range()[0]))\n // .attr('d', (data, length) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(data.length)))\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', 0.01)\n .attr('stroke-opacity', 0.01)\n .style('pointer-events', 'all');\n\n hexagons.transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d))))\n .style('pointer-events', 'all');\n\n // Grid\n const gridEnter = container.append('path').attr('class', 'hexbin-grid')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer.options.radius))\n .attr('fill', 'none')\n .attr('stroke', 'none')\n\n\n // Grid enter-update\n hexagons.on('mouseover', function (this: SVGPathElement, ev: MouseEvent, data) {\n if (thisLayer._tooltipOptions?.content) {\n thisLayer._tooltip\n ?.setContent(\n typeof thisLayer._tooltipOptions.content === \"function\"\n ? thisLayer._tooltipOptions.content(data)\n : thisLayer._tooltipOptions.content\n )\n .setLatLng(\n thisLayer._map.layerPointToLatLng(L.point(data.x, data.y))\n )\n .openOn(thisLayer._map);\n }\n thisLayer._hoverHandler.mouseover(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseover', this, data, thisLayer, ev);\n this.classList.add('hover')\n })\n .on('mouseout', function (this: SVGPathElement, ev: MouseEvent, data) {\n thisLayer._tooltip?.close()\n thisLayer._hoverHandler.mouseout(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseout', this, data, thisLayer, ev);\n this.classList.remove('hover')\n })\n .on('click', function (this, ev: MouseEvent, data) {\n const latLng = thisLayer._map.layerPointToLatLng(L.point(data.x, data.y));\n thisLayer._dispatch.call('click', this, data, latLng, thisLayer, ev);\n ev.stopPropagation()\n });\n\n\n // Exit\n const exit = join.exit();\n\n exit.select('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', 0)\n .attr('stroke-opacity', 0)\n .attr('d', (d) => thisLayer._hexLayout.hexagon(0));\n\n exit.transition().duration(thisLayer.options.duration).remove();\n\n }\n\n _getExtent(\n bins: HexbinBin<HexbinData<Data>>[],\n valueFn: (d: HexbinBin<HexbinData<Data>>) => number,\n scaleExtent: [number, number | undefined]\n ): [number, number] {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData<Data>>, number>(bins, valueFn.bind(this));\n // If either's null, initialize them to 0\n if (ext[0] === undefined || ext[1] === undefined) {\n ext = [0, 0]\n }\n\n // Now apply the optional clipping of the extent\n if (undefined != scaleExtent[0]) ext[0] = scaleExtent[0];\n if (undefined != scaleExtent[1]) ext[1] = scaleExtent[1];\n\n return ext as [number, number]\n }\n\n // ------------------------------------\n // Public API\n // ------------------------------------\n\n radius(): number;\n radius(v: number): this;\n radius(v?: number): this | number {\n if (v === undefined) return this.options.radius;\n\n this.options.radius = v;\n this._hexLayout.radius(v);\n\n if (null == this.options.radiusRange) {\n this._scale.radius.range([this.options.radius, this.options.radius]).clamp(true);\n }\n\n return this;\n }\n\n opacity(): number | [number, number];\n opacity(v: number | [number, number]): this;\n opacity(v?: number | [number, number]): this | number | [number, number] {\n if (v === undefined) return this.options.opacity\n this.options.opacity = v;\n this._scale.opacity.range(typeof v === 'number' ? [v, v] : v).clamp(true);\n\n return this;\n }\n\n duration(): number;\n duration(v: number): this;\n duration(v?: number): this | number {\n if (v === undefined) return this.options.duration\n this.options.duration = v\n\n return this;\n }\n\n colorScaleExtent(): [number, number | undefined];\n colorScaleExtent(v: [number, number | undefined]): this;\n colorScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.colorScaleExtent; }\n this.options.colorScaleExtent = v;\n\n return this;\n }\n\n radiusScaleExtent(): [number, number | undefined];\n radiusScaleExtent(v: [number, number | undefined]): this;\n radiusScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.radiusScaleExtent; }\n this.options.radiusScaleExtent = v;\n\n return this;\n }\n\n opacityScaleExtent(): [number, number | undefined];\n opacityScaleExtent(v: [number, number | undefined]): this;\n opacityScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.opacityScaleExtent; }\n this.options.opacityScaleExtent = v;\n\n return this;\n }\n\n\n colorRange(): string[];\n colorRange(v: string[]): this;\n colorRange(v?: string[]): this | string[] {\n if (v === undefined) { return this.options.colorRange; }\n this.options.colorRange = v;\n this._scale.color.range(v);\n\n return this;\n }\n\n radiusRange(): [number, number] | null;\n radiusRange(v: [number, number] | null): this;\n radiusRange(v?: [number, number] | null): this | [number, number] | null {\n if (v === undefined) { return this.options.radiusRange; }\n this.options.radiusRange = v;\n this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(true);\n\n return this;\n }\n\n colorScale(): d3.ScaleLinear<string, string>;\n colorScale(v: d3.ScaleLinear<string, string>): this;\n colorScale(v?: d3.ScaleLinear<string, string>) {\n if (v === undefined) return this._scale.color;\n this._scale.color = v;\n return this;\n }\n\n radiusScale(): d3.ScaleLinear<number, number>;\n radiusScale(v: d3.ScaleLinear<number, number>): this;\n radiusScale(v?: d3.ScaleLinear<number, number>): this | d3.ScaleLinear<number, number> {\n if (v === undefined) return this._scale.radius\n this._scale.radius = v;\n return this;\n }\n\n lng(): (d: Data) => number;\n lng(v: (d: Data) => number): this;\n lng(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lng; }\n this._fn.lng = v;\n\n return this;\n }\n\n lat(): (d: Data) => number;\n lat(v: (d: Data) => number): this;\n lat(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lat; }\n this._fn.lat = v;\n\n return this;\n }\n\n colorValue(): (d: HexbinData<Data>[]) => number;\n colorValue(v: (d: HexbinData<Data>[]) => number): this;\n colorValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.colorValue; }\n this._fn.colorValue = v;\n\n return this;\n }\n\n radiusValue(): (d: HexbinData<Data>[]) => number;\n radiusValue(v: (d: HexbinData<Data>[]) => number): this;\n radiusValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.radiusValue; }\n this._fn.radiusValue = v;\n\n return this;\n }\n\n fill(): (d: HexbinData<Data>[]) => string;\n fill(v: (d: HexbinData<Data>[]) => string): this;\n fill(v?: (d: HexbinData<Data>[]) => string) {\n if (v === undefined) { return this._fn.fill; }\n this._fn.fill = v;\n\n return this;\n }\n\n data(): Data[];\n data(v: Data extends L.LatLngExpression ? Data[] : never): this;\n data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;\n\n // Implementation\n data(v?: Data[] | L.LatLngExpression[], accessor?: (d: Data) => L.LatLngExpression): this | Data[] {\n if (v === undefined) {\n return this._data;\n }\n\n if (!isLatLngExpression(v[0]) && !accessor) {\n console.error(\"Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression\");\n }\n\n this._data = v as Data[] ?? []\n this._accessor = accessor ?? ((d: Data) => d as L.LatLngExpression)\n\n this.redraw();\n return this;\n }\n\n /*\n * Getter for the event dispatcher\n */\n dispatch() { return this._dispatch }\n\n hoverHandler(): HexbinHoverHandler<Data>;\n hoverHandler(v: HexbinHoverHandler<Data>): this;\n hoverHandler(v?: HexbinHoverHandler<Data>): this | HexbinHoverHandler<Data> {\n if (v === undefined) { return this._hoverHandler; }\n this._hoverHandler = (null != v) ? v : HexbinHoverHandler.none();\n\n this.redraw();\n\n return this;\n }\n\n // Cannot overload bindTooltip() with data dependant content\n tooltip(tooltip: TooltipOptions<Data>): this {\n this._tooltipOptions = tooltip;\n if (this._tooltip)\n this._tooltip.options = tooltip.options ?? {};\n else {\n this._tooltip = L.tooltip(tooltip.options)\n }\n return this\n }\n\n getTooltip(): L.Tooltip | undefined {\n return this._tooltip\n }\n\n bindTooltip(content: L.Tooltip | L.Content, options?: L.TooltipOptions): this {\n if (content instanceof L.Tooltip) {\n this._tooltip = content;\n // FIXME: weird bug likely coming from vue-leaflet were tooltip is not properly positioned\n // this._tooltip.options.offset[0] -= 5;\n if (this._map) {\n this._tooltip.setLatLng([0, 0]).addTo(this._map)\n }\n } else {\n this._tooltip = L.tooltip(options).setContent(content);\n }\n return this\n }\n\n unbindTooltip(): this {\n this._tooltip?.remove();\n this._tooltip = undefined;\n return this\n }\n\n /*\n * Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.\n */\n getLatLngs() {\n const that = this;\n\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map(function (d) {\n return L.latLng(that._fn.lat(d), that._fn.lng(d));\n });\n }\n /*\n * Get path geometry as GeoJSON\n */\n toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPoint, L.LatLng> {\n return L.GeoJSON.getFeature<L.LatLng, GeoJSON.MultiPoint>(this, {\n type: 'MultiPoint',\n coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)\n });\n }\n}\n\n/**\n * Factory function to instanciate a new hexbin layer\n */\nexport function hexbinLayer<Data = L.LatLngExpression>(options?: HexbinLayerConfig) {\n return new HexbinLayer<Data>(options);\n}\n\n\n"],"names":["HexbinHoverHandler","resizeFill","svg","hexLayer","event","data","d3","d","resizeScale","radiusScale","compound","handlers","none","HexbinHoverHandler$1","isLatLngExpression","L","HexbinLayer","options","val","scaleLinear","dispatch","hexbin","x","_","y","select","map","_a","latlng","that","coord","point","join","enterUpdate","from","to","length","step","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","i","hexagons","ev","_b","latLng","exit","valueFn","scaleExtent","ext","extent","v","accessor","tooltip","content","hexbinLayer"],"mappings":";;;;AASiB,IAAAA;AAAA,CAAV,CAAUA,MAAV;AAEE,WAASC,IAAsC;AAC7C,WAAA;AAAA,MACL,WAAW,SAAUC,GAAqBC,GAA4BC,GAAmBC,GAAyB;AAEhH,QADUC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAO,qBAAqB,EAC3B,WAAa,EAAA,SAASC,EAAS,QAAQ,QAAQ,EAC/C,KAAK,KAAK,SAAUI,GAAG;AACtB,iBAAOJ,EAAS,WAAW,QAAQA,EAAS,QAAQ,MAAM;AAAA,QAAA,CAC3D;AAAA,MACL;AAAA,MACA,UAAU,SAAUD,GAAqBC,GAA4BC,GAAmBC,GAAyB;AAE/G,QADUC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAuB,qBAAqB,EAC3C,WAAa,EAAA,SAASC,EAAS,QAAQ,QAAQ,EAC/C,KAAK,KAAK,SAAUI,GAAG;AACtB,iBAAOJ,EAAS,WAAW,QAAQA,EAAS,OAAO,OAAOA,EAAS,IAAI,YAAY,KAAKA,GAAUI,CAAC,CAAC,CAAC;AAAA,QAAA,CACtG;AAAA,MAAA;AAAA,IAEP;AAAA,EAAA;AAlBKP,EAAAA,EAAS,aAAAC;AA2BA,WAAAO,EAAYC,IAAsB,KAA8B;AAGvE,WAAA;AAAA,MACL,WAAW,SAAUP,GAAKC,GAAUC,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AAK,WAAW+C,GAGZ,KAAK,QACF,KAAA,SAAS,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,KAGjD,KAAK,WAAW/C,EAAE,QAAQE,CAAO,EAAE,WAAW6C,CAAO,GAEhD;AAAA,EAAA;AAAA,EAGT,gBAAsB;;AACpB,YAAAnC,IAAA,KAAK,aAAL,QAAAA,EAAe,UACf,KAAK,WAAW,QACT;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMT,aAAa;AACX,UAAME,IAAO;AAGb,WAAO,KAAK,MAAM,IAAI,SAAUtB,GAAG;AAC1B,aAAAQ,EAAE,OAAOc,EAAK,IAAI,IAAItB,CAAC,GAAGsB,EAAK,IAAI,IAAItB,CAAC,CAAC;AAAA,IAAA,CACjD;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAKH,YAA2D;AAClD,WAAAQ,EAAE,QAAQ,WAAyC,MAAM;AAAA,MAC9D,MAAM;AAAA,MACN,aAAaA,EAAE,QAAQ,gBAAgB,KAAK,WAAA,GAAc,CAAC;AAAA,IAAA,CAC5D;AAAA,EAAA;AAEL;AAKO,SAASgD,EAAuC9C,GAA6B;AAC3E,SAAA,IAAID,EAAkBC,CAAO;AACtC;"}
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/HexbinHoverHandler.ts","../src/HexbinLayer.ts"],"sourcesContent":["import * as d3 from 'd3';\nimport type { HexbinData } from './HexbinLayer';\nimport { type HexbinLayer } from './HexbinLayer';\n\nexport interface HexbinHoverHandler<Data> {\n mouseover(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n mouseout(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n}\n\nexport namespace HexbinHoverHandler {\n\n export function resizeFill(): HexbinHoverHandler<any> {\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.options.radius);\n });\n },\n mouseout: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n\n }\n\n export interface ResizeScaleOptions {\n radiusScale?: number;\n duration?: number;\n }\n\n export function resizeScale(radiusScale: number = 1.5): HexbinHoverHandler<any> {\n\n // return the handler instance\n return {\n mouseover: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function () {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius.range()[1] * (radiusScale));\n });\n },\n mouseout: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement!);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', (d) => {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n }\n\n\n export function compound<Data>(handlers: HexbinHoverHandler<Data>[] = [none()]): HexbinHoverHandler<Data> {\n return {\n mouseover: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseover(svg, hexLayer, event, data); });\n },\n mouseout: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseout(svg, hexLayer, event, data); });\n }\n };\n }\n\n export function none(): HexbinHoverHandler<any> {\n return {\n mouseover: function () { },\n mouseout: function () { }\n };\n }\n\n}\nexport default HexbinHoverHandler\n","import { scaleLinear, dispatch, select, extent } from 'd3';\nimport { hexbin, type HexbinBin } from 'd3-hexbin';\nimport * as L from 'leaflet';\nimport HexbinHoverHandler from './HexbinHoverHandler';\n\n// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\n\ntype TooltipOptions<Data> = {\n options?: L.TooltipOptions,\n content?: L.Content | ((d: HexbinData<Data>[]) => L.Content)\n}\n\nexport interface HexbinLayerConfig {\n /**\n * Hex grid cell radius in pixels.\n * This value should be a positive number.\n * This radius controls the radius of the hexagons used to bin the data\n * but not necessarily to draw each individual hexbin.\n * @default 12\n */\n radius?: number,\n /**\n * Sets the opacity on the hexbin layer.\n * This value should be a number between 0 and 1.\n * If an array is provided, the first element is the minimum opacity and the second is the maximum.\n * @default 0.6\n */\n opacity?: number | [number, number],\n /**\n * Opacity scale extent: [min, max] domain for opacity interpolation.\n * @default [1, undefined]\n */\n opacityScaleExtent?: [number, number | undefined],\n /**\n * Duration of transition in milliseconds.\n * @default 200\n */\n duration?: number,\n\n /**\n * Color scale extent: [min, max] domain for color interpolation.\n * @default [1, undefined]\n */\n colorScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the color domain from the data.\n * Normally, you can tweak the generation of the color domain using the colorScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the color scale before rendering.\n * @default null\n */\n colorDomain?: number[] | null\n /**\n * Color range used to fill the hexbins.\n * @default ['#f7fbff', '#08306b']\n */\n colorRange?: string[],\n\n /**\n * Radius scale extent: [min, max] domain for radius interpolation.\n * @default [1, undefined]\n */\n radiusScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the radius domain from the data.\n * Normally, you can tweak the generation of the radius domain using the radiusScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the radius scale before rendering.\n * @default null\n */\n radiusDomain?: number[] | null\n /**\n * Sets the range of the radius scale used to size the hexbins.\n * @default hex grid cell radius\n */\n radiusRange?: [number, number] | null,\n\n /**\n * You should only modify this config option if you want to change the mouse event behavior on hexbins. This will modify when the events are propagated based on the visibility state and/or part of the hexbin being hovered.\n * @default 'all'\n */\n pointerEvents?: string\n\n /**\n * If true, the layer will not be redrawn after data changes and hover handler binding.\n * @default false\n */\n noRedraw?: boolean\n}\n\n/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData<Data> = {\n data: Data;\n coord: L.LatLngExpression;\n point: Readonly<[number, number]>;\n}\n\n\nfunction isLatLngExpression(d: any): d is L.LatLngExpression {\n return (\n d instanceof L.LatLng ||\n (typeof d === 'object' && \"lat\" in d && \"lng\" in d) ||\n (Array.isArray(d) && d.length === 2 && typeof d[0] === 'number' && typeof d[1] === 'number')\n )\n}\n\n/**\n * Instantiate a hexbin layer.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {\n options: Required<HexbinLayerConfig> & L.RendererOptions = {\n radius: 12,\n opacity: 0.6,\n duration: 200,\n\n colorScaleExtent: [1, undefined],\n radiusScaleExtent: [1, undefined],\n opacityScaleExtent: [1, undefined],\n colorDomain: null,\n radiusDomain: null,\n colorRange: ['#f7fbff', '#08306b'],\n radiusRange: null,\n\n pointerEvents: 'all',\n noRedraw: false,\n // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n _fn = {\n lng: (d: Data) => L.latLng(this._accessor(d)).lng,\n lat: (d: Data) => L.latLng(this._accessor(d)).lat,\n colorValue: (d: HexbinData<Data>[]) => d.length,\n radiusValue: (d: HexbinData<Data>[]) => d.length,\n opacityValue: (d: HexbinData<Data>[]) => d.length,\n fill: (d: HexbinData<Data>[]) => {\n const val = this._fn.colorValue(d);\n return (null != val) ? this._scale.color(val) : 'none';\n }\n }\n // Set up the customizable scale\n _scale = {\n color: scaleLinear<string, string>(),\n radius: scaleLinear(),\n opacity: scaleLinear()\n };\n\n // Set up the Dispatcher for managing events and callbacks\n _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n _hoverHandler: HexbinHoverHandler<Data> = HexbinHoverHandler.none();\n\n // Create the hex layout\n _hexLayout = hexbin<HexbinData<Data>>()\n .radius(this.options.radius)\n .x(({ point: [x, _] }) => x)\n .y(({ point: [_, y] }) => y);\n\n // Initialize the data array to be empty\n _data = Array<Data>()\n\n\n declare _map: L.Map;\n\n _tooltipOptions: TooltipOptions<Data> = {};\n declare _tooltip: L.Tooltip | undefined;\n\n declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare _d3Container: d3.Selection<SVGGElement, unknown, null, undefined>;\n\n public constructor(options?: HexbinLayerConfig) {\n super()\n // L.SVG.prototype.initialize.call(this, options);\n this.options = { ...this.options, ...options };\n this._scale.color\n .range(this.options.colorRange)\n .clamp(true);\n\n this._scale.radius\n .range(this.options.radiusRange ?? [this.options.radius, this.options.radius])\n .clamp(true);\n\n this._scale.opacity\n .range(\n typeof this.options.opacity === 'number'\n ? [this.options.opacity, this.options.opacity]\n : this.options.opacity\n ).clamp(true);\n\n };\n\n _accessor(d: Data) {\n return d as L.LatLngExpression;\n }\n\n /**\n * Create the SVG container for the hexbins\n * @private\n */\n _initContainer() {\n super._initContainer();\n this._d3Container = select(this._container).select<SVGElementTagNameMap['g']>('g');\n }\n /**\n * Callback made by Leaflet when the layer is added to the map\n * @param map Reference to the map to which this layer has been added\n */\n onAdd(map: L.Map): this {\n // Call super.onAdd to properly initialize the SVG pane\n super.onAdd(map)\n\n // Store a reference to the map for later use\n this._map = map;\n this._tooltip?.setLatLng([0, 0]).addTo(map);\n // Redraw on moveend\n map.on('moveend', this.redraw, this);\n // Initial draw\n this.redraw();\n return this\n }\n\n _project(latlng: L.LatLngExpression) {\n const { x, y } = this._map.latLngToLayerPoint(latlng);\n return [x, y] as const;\n }\n\n /**\n * Callback made by Leaflet when the layer is removed from the map\n * @param map Reference to the map from which this layer is being removed\n */\n onRemove(map: L.Map): this {\n // Destroy the svg container\n this._destroyContainer();\n // Remove events\n map.off('moveend', this.redraw, this);\n return this\n }\n\n /**\n * Clean up the svg container\n * @private\n */\n _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n * @private\n */\n redraw() {\n const that = this;\n\n if (!that._map) return\n\n // Generate the mapped version of the data\n const data = that._data.map<HexbinData<Data>>((d: Data) => {\n const coord = that._accessor(d)\n const point = that._project(coord);\n return { coord: coord, point, data: d };\n });\n\n // Select the hex group for the current zoom level. This has\n // the effect of recreating the group if the zoom level has changed\n const join = this._d3Container.selectAll<SVGGElement, number>('g.hexbin')\n .data<number>([this._map.getZoom()], (d) => d);\n\n // enter\n const enter = join.enter().append('g')\n .attr('class', function (d) { return 'hexbin zoom-' + d; });\n\n // enter + update\n const enterUpdate = enter.merge(join);\n\n // exit\n join.exit().remove();\n\n // add the hexagons to the select\n this._createHexagons(enterUpdate, data);\n\n }\n\n _linearlySpace(from: number, to: number, length: number): number[] {\n const step = (to - from) / Math.max(length - 1, 1);\n return Array.from({ length }, (_, i) => from + (i * step));\n }\n\n _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData<Data>[]) {\n const thisLayer = this;\n\n // Create the bins using the hexbin layout\n\n // Generate the map bounds (to be used to filter the hexes to what is visible)\n const size = thisLayer._map.getSize();\n const bounds = thisLayer._map.getBounds().pad(thisLayer.options.radius * 2 / Math.max(size.x, size.y));\n\n const bins = thisLayer._hexLayout(data).filter(\n ({ x, y }) => bounds.contains(thisLayer._map.layerPointToLatLng(L.point(x, y)))\n );\n\n // Derive the extents of the data values for each dimension\n const colorExtent = thisLayer._getExtent(bins, thisLayer._fn.colorValue, thisLayer.options.colorScaleExtent);\n const radiusExtent = thisLayer._getExtent(bins, thisLayer._fn.radiusValue, thisLayer.options.radiusScaleExtent);\n const opacityExtent = thisLayer._getExtent(bins, thisLayer._fn.opacityValue, thisLayer.options.opacityScaleExtent);\n\n // Match the domain cardinality to that of the color range, to allow for a polylinear scale\n const colorDomain = this.options.colorDomain\n ?? thisLayer._linearlySpace(\n colorExtent[0],\n colorExtent[1],\n thisLayer._scale.color.range().length\n );\n const radiusDomain = this.options.radiusDomain || radiusExtent;\n\n // Set the scale domains\n thisLayer._scale.color.domain(colorDomain);\n thisLayer._scale.radius.domain(radiusDomain);\n thisLayer._scale.opacity.domain(opacityExtent);\n\n\n /*\n * Join\n * Join the Hexagons to the data\n * Use a deterministic id for tracking bins based on position\n */\n const join = g.selectAll<SVGGElement, HexbinBin<HexbinData<Data>>>('g.hexbin-container')\n .data(bins, ({ x, y }) => `${x}:${y}`);\n\n\n /*\n * Update\n * Set the fill and opacity on a transition\n * opacity is re-applied in case the enter transition was cancelled\n * the path is applied as well to resize the bins\n */\n join.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => {\n return thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d)));\n });\n\n\n /*\n * Enter\n * Establish the path, size, fill, and the initial opacity\n * Transition to the final opacity and size\n */\n const container = join.enter().append('g').attr('class', 'hexbin-container')\n .style('pointer-events', thisLayer.options.pointerEvents);\n\n\n container.on('mouseover', function (this: SVGGElement, d: MouseEvent, i) {\n // Bring container to foreground by re-appending it to the DOM\n select<SVGGElement, HexbinBin<HexbinData<Data>>>(this).raise();\n })\n\n const hexagons = container.append('path').attr('class', 'hexbin-hexagon')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer._scale.radius.range()[0]))\n // .attr('d', (data, length) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(data.length)))\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', 0.01)\n .attr('stroke-opacity', 0.01)\n .style('pointer-events', 'all');\n\n hexagons.transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d))))\n .style('pointer-events', 'all');\n\n // Grid\n const gridEnter = container.append('path').attr('class', 'hexbin-grid')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer.options.radius))\n .attr('fill', 'none')\n .attr('stroke', 'none')\n\n\n // Grid enter-update\n hexagons.on('mouseover', function (this: SVGPathElement, ev: MouseEvent, data) {\n if (thisLayer._tooltipOptions?.content) {\n thisLayer._tooltip\n ?.setContent(\n typeof thisLayer._tooltipOptions.content === \"function\"\n ? thisLayer._tooltipOptions.content(data)\n : thisLayer._tooltipOptions.content\n )\n .setLatLng(\n thisLayer._map.layerPointToLatLng(L.point(data.x, data.y))\n )\n .openOn(thisLayer._map);\n }\n thisLayer._hoverHandler.mouseover(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseover', this, data, thisLayer, ev);\n this.classList.add('hover')\n })\n .on('mouseout', function (this: SVGPathElement, ev: MouseEvent, data) {\n thisLayer._tooltip?.close()\n thisLayer._hoverHandler.mouseout(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseout', this, data, thisLayer, ev);\n this.classList.remove('hover')\n })\n .on('click', function (this, ev: MouseEvent, data) {\n const latLng = thisLayer._map.layerPointToLatLng(L.point(data.x, data.y));\n thisLayer._dispatch.call('click', this, data, latLng, thisLayer, ev);\n ev.stopPropagation()\n });\n\n\n // Exit\n const exit = join.exit();\n\n exit.select('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', 0)\n .attr('stroke-opacity', 0)\n .attr('d', (d) => thisLayer._hexLayout.hexagon(0));\n\n exit.transition().duration(thisLayer.options.duration).remove();\n\n }\n\n _getExtent(\n bins: HexbinBin<HexbinData<Data>>[],\n valueFn: (d: HexbinBin<HexbinData<Data>>) => number,\n scaleExtent: [number, number | undefined]\n ): [number, number] {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData<Data>>, number>(bins, valueFn.bind(this));\n // If either's null, initialize them to 0\n if (ext[0] === undefined || ext[1] === undefined) {\n ext = [0, 0]\n }\n\n // Now apply the optional clipping of the extent\n if (undefined != scaleExtent[0]) ext[0] = scaleExtent[0];\n if (undefined != scaleExtent[1]) ext[1] = scaleExtent[1];\n\n return ext as [number, number]\n }\n\n // ------------------------------------\n // Public API\n // ------------------------------------\n\n radius(): number;\n radius(v: number): this;\n radius(v?: number): this | number {\n if (v === undefined) return this.options.radius;\n\n this.options.radius = v;\n this._hexLayout.radius(v);\n\n if (null == this.options.radiusRange) {\n this._scale.radius.range([this.options.radius, this.options.radius]).clamp(true);\n }\n\n return this;\n }\n\n opacity(): number | [number, number];\n opacity(v: number | [number, number]): this;\n opacity(v?: number | [number, number]): this | number | [number, number] {\n if (v === undefined) return this.options.opacity\n this.options.opacity = v;\n this._scale.opacity.range(typeof v === 'number' ? [v, v] : v).clamp(true);\n\n return this;\n }\n\n duration(): number;\n duration(v: number): this;\n duration(v?: number): this | number {\n if (v === undefined) return this.options.duration\n this.options.duration = v\n\n return this;\n }\n\n colorScaleExtent(): [number, number | undefined];\n colorScaleExtent(v: [number, number | undefined]): this;\n colorScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.colorScaleExtent; }\n this.options.colorScaleExtent = v;\n\n return this;\n }\n\n radiusScaleExtent(): [number, number | undefined];\n radiusScaleExtent(v: [number, number | undefined]): this;\n radiusScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.radiusScaleExtent; }\n this.options.radiusScaleExtent = v;\n\n return this;\n }\n\n opacityScaleExtent(): [number, number | undefined];\n opacityScaleExtent(v: [number, number | undefined]): this;\n opacityScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.opacityScaleExtent; }\n this.options.opacityScaleExtent = v;\n\n return this;\n }\n\n\n colorRange(): string[];\n colorRange(v: string[]): this;\n colorRange(v?: string[]): this | string[] {\n if (v === undefined) { return this.options.colorRange; }\n this.options.colorRange = v;\n this._scale.color.range(v);\n\n return this;\n }\n\n radiusRange(): [number, number] | null;\n radiusRange(v: [number, number] | null): this;\n radiusRange(v?: [number, number] | null): this | [number, number] | null {\n if (v === undefined) { return this.options.radiusRange; }\n this.options.radiusRange = v;\n this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(true);\n\n return this;\n }\n\n colorScale(): d3.ScaleLinear<string, string>;\n colorScale(v: d3.ScaleLinear<string, string>): this;\n colorScale(v?: d3.ScaleLinear<string, string>) {\n if (v === undefined) return this._scale.color;\n this._scale.color = v;\n return this;\n }\n\n radiusScale(): d3.ScaleLinear<number, number>;\n radiusScale(v: d3.ScaleLinear<number, number>): this;\n radiusScale(v?: d3.ScaleLinear<number, number>): this | d3.ScaleLinear<number, number> {\n if (v === undefined) return this._scale.radius\n this._scale.radius = v;\n return this;\n }\n\n lng(): (d: Data) => number;\n lng(v: (d: Data) => number): this;\n lng(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lng; }\n this._fn.lng = v;\n\n return this;\n }\n\n lat(): (d: Data) => number;\n lat(v: (d: Data) => number): this;\n lat(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lat; }\n this._fn.lat = v;\n\n return this;\n }\n\n colorValue(): (d: HexbinData<Data>[]) => number;\n colorValue(v: (d: HexbinData<Data>[]) => number): this;\n colorValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.colorValue; }\n this._fn.colorValue = v;\n\n return this;\n }\n\n radiusValue(): (d: HexbinData<Data>[]) => number;\n radiusValue(v: (d: HexbinData<Data>[]) => number): this;\n radiusValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.radiusValue; }\n this._fn.radiusValue = v;\n\n return this;\n }\n\n fill(): (d: HexbinData<Data>[]) => string;\n fill(v: (d: HexbinData<Data>[]) => string): this;\n fill(v?: (d: HexbinData<Data>[]) => string) {\n if (v === undefined) { return this._fn.fill; }\n this._fn.fill = v;\n\n return this;\n }\n\n data(): Data[];\n data(v: Data extends L.LatLngExpression ? Data[] : never): this;\n data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;\n\n // Implementation\n data(v?: Data[] | L.LatLngExpression[], accessor?: (d: Data) => L.LatLngExpression): this | Data[] {\n if (v === undefined) {\n return this._data;\n }\n\n if (!isLatLngExpression(v[0]) && !accessor) {\n console.error(\"Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression\");\n }\n\n this._data = v as Data[] ?? []\n this._accessor = accessor ?? ((d: Data) => d as L.LatLngExpression)\n\n if (!this.options.noRedraw) this.redraw();\n return this;\n }\n\n /*\n * Getter for the event dispatcher\n */\n dispatch() { return this._dispatch }\n\n hoverHandler(): HexbinHoverHandler<Data>;\n hoverHandler(v: HexbinHoverHandler<Data>): this;\n hoverHandler(v?: HexbinHoverHandler<Data>): this | HexbinHoverHandler<Data> {\n if (v === undefined) { return this._hoverHandler; }\n this._hoverHandler = (null != v) ? v : HexbinHoverHandler.none();\n\n if (!this.options.noRedraw) this.redraw();\n\n return this;\n }\n\n // Cannot overload bindTooltip() with data dependant content\n tooltip(tooltip: TooltipOptions<Data>): this {\n this._tooltipOptions = tooltip;\n if (this._tooltip)\n this._tooltip.options = tooltip.options ?? {};\n else {\n this._tooltip = L.tooltip(tooltip.options)\n }\n return this\n }\n\n getTooltip(): L.Tooltip | undefined {\n return this._tooltip\n }\n\n bindTooltip(content: L.Tooltip | L.Content, options?: L.TooltipOptions): this {\n if (content instanceof L.Tooltip) {\n this._tooltip = content;\n // FIXME: weird bug likely coming from vue-leaflet were tooltip is not properly positioned\n // this._tooltip.options.offset[0] -= 5;\n if (this._map) {\n this._tooltip.setLatLng([0, 0]).addTo(this._map)\n }\n } else {\n this._tooltip = L.tooltip(options).setContent(content);\n }\n return this\n }\n\n unbindTooltip(): this {\n this._tooltip?.remove();\n this._tooltip = undefined;\n return this\n }\n\n /*\n * Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.\n */\n getLatLngs() {\n const that = this;\n\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map(function (d) {\n return L.latLng(that._fn.lat(d), that._fn.lng(d));\n });\n }\n /*\n * Get path geometry as GeoJSON\n */\n toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPoint, L.LatLng> {\n return L.GeoJSON.getFeature<L.LatLng, GeoJSON.MultiPoint>(this, {\n type: 'MultiPoint',\n coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)\n });\n }\n}\n\n/**\n * Factory function to instanciate a new hexbin layer\n */\nexport function hexbinLayer<Data = L.LatLngExpression>(options?: HexbinLayerConfig) {\n return new HexbinLayer<Data>(options);\n}\n\n\n"],"names":["HexbinHoverHandler","resizeFill","svg","hexLayer","event","data","d3","d","resizeScale","radiusScale","compound","handlers","none","HexbinHoverHandler$1","isLatLngExpression","L","HexbinLayer","options","val","scaleLinear","dispatch","hexbin","x","_","y","select","map","_a","latlng","that","coord","point","join","enterUpdate","from","to","length","step","i","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","hexagons","ev","_b","latLng","ex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AAAA;AAAA,EAMT,aAAa;AACX,UAAME,IAAO;AAGb,WAAO,KAAK,MAAM,IAAI,SAAUtB,GAAG;AAC1B,aAAAQ,EAAE,OAAOc,EAAK,IAAI,IAAItB,CAAC,GAAGsB,EAAK,IAAI,IAAItB,CAAC,CAAC;AAAA,IAAA,CACjD;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAKH,YAA2D;AAClD,WAAAQ,EAAE,QAAQ,WAAyC,MAAM;AAAA,MAC9D,MAAM;AAAA,MACN,aAAaA,EAAE,QAAQ,gBAAgB,KAAK,WAAA,GAAc,CAAC;AAAA,IAAA,CAC5D;AAAA,EAAA;AAEL;AAKO,SAASgD,EAAuC9C,GAA6B;AAC3E,SAAA,IAAID,EAAkBC,CAAO;AACtC;"}
|
package/dist/index.umd.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
(function(h,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("d3"),require("d3-hexbin"),require("leaflet")):typeof define=="function"&&define.amd?define(["exports","d3","d3-hexbin","leaflet"],c):(h=typeof globalThis<"u"?globalThis:h||self,c(h["leaflet-hexbin"]={},h.d3,h["d3-hexbin"],h.L))})(this,function(h,c,v,j){"use strict";function S(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const e in s)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(s,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>s[e]})}}return t.default=s,Object.freeze(t)}const m=S(c),u=S(j);var y;(s=>{function t(){return{mouseover:function(p,o,a,d){m.select(p.parentElement).select("path.hexbin-hexagon").transition().duration(o.options.duration).attr("d",function(f){return o._hexLayout.hexagon(o.options.radius)})},mouseout:function(p,o,a,d){m.select(p.parentElement).select("path.hexbin-hexagon").transition().duration(o.options.duration).attr("d",function(f){return o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o,f)))})}}}s.resizeFill=t;function e(p=1.5){return{mouseover:function(o,a,d,_){m.select(o.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d",function(){return a._hexLayout.hexagon(a._scale.radius.range()[1]*p)})},mouseout:function(o,a,d,_){m.select(o.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d",L=>a._hexLayout.hexagon(a._scale.radius(a._fn.radiusValue.call(a,L))))}}}s.resizeScale=e;function n(p=[l()]){return{mouseover:function(o,a,d,_){p.forEach(f=>{f.mouseover(o,a,d,_)})},mouseout:function(o,a,d,_){p.forEach(f=>{f.mouseout(o,a,d,_)})}}}s.compound=n;function l(){return{mouseover:function(){},mouseout:function(){}}}s.none=l})(y||(y={}));const x=y;function H(s){return s instanceof u.LatLng||typeof s=="object"&&"lat"in s&&"lng"in s||Array.isArray(s)&&s.length===2&&typeof s[0]=="number"&&typeof s[1]=="number"}class V extends u.SVG{constructor(t){super(),this.options={radius:12,opacity:.6,duration:200,colorScaleExtent:[1,void 0],radiusScaleExtent:[1,void 0],opacityScaleExtent:[1,void 0],colorDomain:null,radiusDomain:null,colorRange:["#f7fbff","#08306b"],radiusRange:null,pointerEvents:"all",...u.Renderer.prototype.options,...u.Layer.prototype.options},this._fn={lng:e=>u.latLng(this._accessor(e)).lng,lat:e=>u.latLng(this._accessor(e)).lat,colorValue:e=>e.length,radiusValue:e=>e.length,opacityValue:e=>e.length,fill:e=>{const n=this._fn.colorValue(e);return n!=null?this._scale.color(n):"none"}},this._scale={color:c.scaleLinear(),radius:c.scaleLinear(),opacity:c.scaleLinear()},this._dispatch=c.dispatch("mouseover","mouseout","click"),this._hoverHandler=x.none(),this._hexLayout=v.hexbin().radius(this.options.radius).x(({point:[e,n]})=>e).y(({point:[e,n]})=>n),this._data=Array(),this._tooltipOptions={},this.options={...this.options,...t},this._scale.color.range(this.options.colorRange).clamp(!0),this._scale.radius.range(this.options.radiusRange??[this.options.radius,this.options.radius]).clamp(!0),this._scale.opacity.range(typeof this.options.opacity=="number"?[this.options.opacity,this.options.opacity]:this.options.opacity).clamp(!0)}_accessor(t){return t}_initContainer(){super._initContainer(),this._d3Container=c.select(this._container).select("g")}onAdd(t){var e;return super.onAdd(t),this._map=t,(e=this._tooltip)==null||e.setLatLng([0,0]).addTo(t),t.on("moveend",this.redraw,this),this.redraw(),this}_project(t){const{x:e,y:n}=this._map.latLngToLayerPoint(t);return[e,n]}onRemove(t){return this._destroyContainer(),t.off("moveend",this.redraw,this),this}_destroyContainer(){c.select(this._container).remove()}redraw(){const t=this;if(!t._map)return;const e=t._data.map(o=>{const a=t._accessor(o),d=t._project(a);return{coord:a,point:d,data:o}}),n=this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()],o=>o),p=n.enter().append("g").attr("class",function(o){return"hexbin zoom-"+o}).merge(n);n.exit().remove(),this._createHexagons(p,e)}_linearlySpace(t,e,n){const l=(e-t)/Math.max(n-1,1);return Array.from({length:n},(p,o)=>t+o*l)}_createHexagons(t,e){const n=this,l=n._map.getSize(),p=n._map.getBounds().pad(n.options.radius*2/Math.max(l.x,l.y)),o=n._hexLayout(e).filter(({x:i,y:r})=>p.contains(n._map.layerPointToLatLng(u.point(i,r)))),a=n._getExtent(o,n._fn.colorValue,n.options.colorScaleExtent),d=n._getExtent(o,n._fn.radiusValue,n.options.radiusScaleExtent),_=n._getExtent(o,n._fn.opacityValue,n.options.opacityScaleExtent),f=this.options.colorDomain??n._linearlySpace(a[0],a[1],n._scale.color.range().length),L=this.options.radiusDomain||d;n._scale.color.domain(f),n._scale.radius.domain(L),n._scale.opacity.domain(_);const b=t.selectAll("g.hexbin-container").data(o,({x:i,y:r})=>`${i}:${r}`);b.select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("fill",n._fn.fill.bind(n)).attr("fill-opacity",i=>n._scale.opacity(n._fn.opacityValue.call(n,i))).attr("stroke-opacity",i=>n._scale.opacity(n._fn.opacityValue.call(n,i))).attr("d",i=>n._hexLayout.hexagon(n._scale.radius(n._fn.radiusValue.call(n,i))));const E=b.enter().append("g").attr("class","hexbin-container").style("pointer-events",n.options.pointerEvents);E.on("mouseover",function(i,r){c.select(this).raise()});const O=E.append("path").attr("class","hexbin-hexagon").attr("transform",({x:i,y:r})=>`translate(${i},${r})`).attr("d",()=>n._hexLayout.hexagon(n._scale.radius.range()[0])).attr("fill",n._fn.fill.bind(n)).attr("fill-opacity",.01).attr("stroke-opacity",.01).style("pointer-events","all");O.transition().duration(n.options.duration).attr("fill-opacity",i=>n._scale.opacity(n._fn.opacityValue.call(n,i))).attr("stroke-opacity",i=>n._scale.opacity(n._fn.opacityValue.call(n,i))).attr("d",i=>n._hexLayout.hexagon(n._scale.radius(n._fn.radiusValue.call(n,i)))).style("pointer-events","all"),E.append("path").attr("class","hexbin-grid").attr("transform",({x:i,y:r})=>`translate(${i},${r})`).attr("d",()=>n._hexLayout.hexagon(n.options.radius)).attr("fill","none").attr("stroke","none"),O.on("mouseover",function(i,r){var g,R;(g=n._tooltipOptions)!=null&&g.content&&((R=n._tooltip)==null||R.setContent(typeof n._tooltipOptions.content=="function"?n._tooltipOptions.content(r):n._tooltipOptions.content).setLatLng(n._map.layerPointToLatLng(u.point(r.x,r.y))).openOn(n._map)),n._hoverHandler.mouseover(this,n,i,r),n._dispatch.call("mouseover",this,r,n,i),this.classList.add("hover")}).on("mouseout",function(i,r){var g;(g=n._tooltip)==null||g.close(),n._hoverHandler.mouseout(this,n,i,r),n._dispatch.call("mouseout",this,r,n,i),this.classList.remove("hover")}).on("click",function(i,r){const g=n._map.layerPointToLatLng(u.point(r.x,r.y));n._dispatch.call("click",this,r,g,n,i),i.stopPropagation()});const T=b.exit();T.select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("fill-opacity",0).attr("stroke-opacity",0).attr("d",i=>n._hexLayout.hexagon(0)),T.transition().duration(n.options.duration).remove()}_getExtent(t,e,n){let l=c.extent(t,e.bind(this));return(l[0]===void 0||l[1]===void 0)&&(l=[0,0]),n[0]!=null&&(l[0]=n[0]),n[1]!=null&&(l[1]=n[1]),l}radius(t){return t===void 0?this.options.radius:(this.options.radius=t,this._hexLayout.radius(t),this.options.radiusRange==null&&this._scale.radius.range([this.options.radius,this.options.radius]).clamp(!0),this)}opacity(t){return t===void 0?this.options.opacity:(this.options.opacity=t,this._scale.opacity.range(typeof t=="number"?[t,t]:t).clamp(!0),this)}duration(t){return t===void 0?this.options.duration:(this.options.duration=t,this)}colorScaleExtent(t){return t===void 0?this.options.colorScaleExtent:(this.options.colorScaleExtent=t,this)}radiusScaleExtent(t){return t===void 0?this.options.radiusScaleExtent:(this.options.radiusScaleExtent=t,this)}opacityScaleExtent(t){return t===void 0?this.options.opacityScaleExtent:(this.options.opacityScaleExtent=t,this)}colorRange(t){return t===void 0?this.options.colorRange:(this.options.colorRange=t,this._scale.color.range(t),this)}radiusRange(t){return t===void 0?this.options.radiusRange:(this.options.radiusRange=t,this._scale.radius.range(this.options.radiusRange??[this.options.radius,this.options.radius]).clamp(!0),this)}colorScale(t){return t===void 0?this._scale.color:(this._scale.color=t,this)}radiusScale(t){return t===void 0?this._scale.radius:(this._scale.radius=t,this)}lng(t){return t===void 0?this._fn.lng:(this._fn.lng=t,this)}lat(t){return t===void 0?this._fn.lat:(this._fn.lat=t,this)}colorValue(t){return t===void 0?this._fn.colorValue:(this._fn.colorValue=t,this)}radiusValue(t){return t===void 0?this._fn.radiusValue:(this._fn.radiusValue=t,this)}fill(t){return t===void 0?this._fn.fill:(this._fn.fill=t,this)}data(t,e){return t===void 0?this._data:(!H(t[0])&&!e&&console.error("Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression"),this._data=t??[],this._accessor=e??(n=>n),this.redraw(),this)}dispatch(){return this._dispatch}hoverHandler(t){return t===void 0?this._hoverHandler:(this._hoverHandler=t??x.none(),this.redraw(),this)}tooltip(t){return this._tooltipOptions=t,this._tooltip?this._tooltip.options=t.options??{}:this._tooltip=u.tooltip(t.options),this}getTooltip(){return this._tooltip}bindTooltip(t,e){return t instanceof u.Tooltip?(this._tooltip=t,this._map&&this._tooltip.setLatLng([0,0]).addTo(this._map)):this._tooltip=u.tooltip(e).setContent(t),this}unbindTooltip(){var t;return(t=this._tooltip)==null||t.remove(),this._tooltip=void 0,this}getLatLngs(){const t=this;return this._data.map(function(e){return u.latLng(t._fn.lat(e),t._fn.lng(e))})}toGeoJSON(){return u.GeoJSON.getFeature(this,{type:"MultiPoint",coordinates:u.GeoJSON.latLngsToCoords(this.getLatLngs(),0)})}}function k(s){return new V(s)}h.HexbinHoverHandler=x,h.HexbinLayer=V,h.hexbinLayer=k,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
1
|
+
(function(h,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("d3"),require("d3-hexbin"),require("leaflet")):typeof define=="function"&&define.amd?define(["exports","d3","d3-hexbin","leaflet"],u):(h=typeof globalThis<"u"?globalThis:h||self,u(h["leaflet-hexbin"]={},h.d3,h["d3-hexbin"],h.L))})(this,function(h,u,T,j){"use strict";function E(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const i in s)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>s[i]})}}return t.default=s,Object.freeze(t)}const m=E(u),l=E(j);var y;(s=>{function t(){return{mouseover:function(p,n,a,d){m.select(p.parentElement).select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("d",function(_){return n._hexLayout.hexagon(n.options.radius)})},mouseout:function(p,n,a,d){m.select(p.parentElement).select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("d",function(_){return n._hexLayout.hexagon(n._scale.radius(n._fn.radiusValue.call(n,_)))})}}}s.resizeFill=t;function i(p=1.5){return{mouseover:function(n,a,d,f){m.select(n.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d",function(){return a._hexLayout.hexagon(a._scale.radius.range()[1]*p)})},mouseout:function(n,a,d,f){m.select(n.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d",L=>a._hexLayout.hexagon(a._scale.radius(a._fn.radiusValue.call(a,L))))}}}s.resizeScale=i;function o(p=[c()]){return{mouseover:function(n,a,d,f){p.forEach(_=>{_.mouseover(n,a,d,f)})},mouseout:function(n,a,d,f){p.forEach(_=>{_.mouseout(n,a,d,f)})}}}s.compound=o;function c(){return{mouseover:function(){},mouseout:function(){}}}s.none=c})(y||(y={}));const x=y;function w(s){return s instanceof l.LatLng||typeof s=="object"&&"lat"in s&&"lng"in s||Array.isArray(s)&&s.length===2&&typeof s[0]=="number"&&typeof s[1]=="number"}class S extends l.SVG{constructor(t){super(),this.options={radius:12,opacity:.6,duration:200,colorScaleExtent:[1,void 0],radiusScaleExtent:[1,void 0],opacityScaleExtent:[1,void 0],colorDomain:null,radiusDomain:null,colorRange:["#f7fbff","#08306b"],radiusRange:null,pointerEvents:"all",noRedraw:!1,...l.Renderer.prototype.options,...l.Layer.prototype.options},this._fn={lng:i=>l.latLng(this._accessor(i)).lng,lat:i=>l.latLng(this._accessor(i)).lat,colorValue:i=>i.length,radiusValue:i=>i.length,opacityValue:i=>i.length,fill:i=>{const o=this._fn.colorValue(i);return o!=null?this._scale.color(o):"none"}},this._scale={color:u.scaleLinear(),radius:u.scaleLinear(),opacity:u.scaleLinear()},this._dispatch=u.dispatch("mouseover","mouseout","click"),this._hoverHandler=x.none(),this._hexLayout=T.hexbin().radius(this.options.radius).x(({point:[i,o]})=>i).y(({point:[i,o]})=>o),this._data=Array(),this._tooltipOptions={},this.options={...this.options,...t},this._scale.color.range(this.options.colorRange).clamp(!0),this._scale.radius.range(this.options.radiusRange??[this.options.radius,this.options.radius]).clamp(!0),this._scale.opacity.range(typeof this.options.opacity=="number"?[this.options.opacity,this.options.opacity]:this.options.opacity).clamp(!0)}_accessor(t){return t}_initContainer(){super._initContainer(),this._d3Container=u.select(this._container).select("g")}onAdd(t){var i;return super.onAdd(t),this._map=t,(i=this._tooltip)==null||i.setLatLng([0,0]).addTo(t),t.on("moveend",this.redraw,this),this.redraw(),this}_project(t){const{x:i,y:o}=this._map.latLngToLayerPoint(t);return[i,o]}onRemove(t){return this._destroyContainer(),t.off("moveend",this.redraw,this),this}_destroyContainer(){u.select(this._container).remove()}redraw(){const t=this;if(!t._map)return;const i=t._data.map(n=>{const a=t._accessor(n),d=t._project(a);return{coord:a,point:d,data:n}}),o=this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()],n=>n),p=o.enter().append("g").attr("class",function(n){return"hexbin zoom-"+n}).merge(o);o.exit().remove(),this._createHexagons(p,i)}_linearlySpace(t,i,o){const c=(i-t)/Math.max(o-1,1);return Array.from({length:o},(p,n)=>t+n*c)}_createHexagons(t,i){const o=this,c=o._map.getSize(),p=o._map.getBounds().pad(o.options.radius*2/Math.max(c.x,c.y)),n=o._hexLayout(i).filter(({x:e,y:r})=>p.contains(o._map.layerPointToLatLng(l.point(e,r)))),a=o._getExtent(n,o._fn.colorValue,o.options.colorScaleExtent),d=o._getExtent(n,o._fn.radiusValue,o.options.radiusScaleExtent),f=o._getExtent(n,o._fn.opacityValue,o.options.opacityScaleExtent),_=this.options.colorDomain??o._linearlySpace(a[0],a[1],o._scale.color.range().length),L=this.options.radiusDomain||d;o._scale.color.domain(_),o._scale.radius.domain(L),o._scale.opacity.domain(f);const b=t.selectAll("g.hexbin-container").data(n,({x:e,y:r})=>`${e}:${r}`);b.select("path.hexbin-hexagon").transition().duration(o.options.duration).attr("fill",o._fn.fill.bind(o)).attr("fill-opacity",e=>o._scale.opacity(o._fn.opacityValue.call(o,e))).attr("stroke-opacity",e=>o._scale.opacity(o._fn.opacityValue.call(o,e))).attr("d",e=>o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o,e))));const v=b.enter().append("g").attr("class","hexbin-container").style("pointer-events",o.options.pointerEvents);v.on("mouseover",function(e,r){u.select(this).raise()});const V=v.append("path").attr("class","hexbin-hexagon").attr("transform",({x:e,y:r})=>`translate(${e},${r})`).attr("d",()=>o._hexLayout.hexagon(o._scale.radius.range()[0])).attr("fill",o._fn.fill.bind(o)).attr("fill-opacity",.01).attr("stroke-opacity",.01).style("pointer-events","all");V.transition().duration(o.options.duration).attr("fill-opacity",e=>o._scale.opacity(o._fn.opacityValue.call(o,e))).attr("stroke-opacity",e=>o._scale.opacity(o._fn.opacityValue.call(o,e))).attr("d",e=>o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o,e)))).style("pointer-events","all"),v.append("path").attr("class","hexbin-grid").attr("transform",({x:e,y:r})=>`translate(${e},${r})`).attr("d",()=>o._hexLayout.hexagon(o.options.radius)).attr("fill","none").attr("stroke","none"),V.on("mouseover",function(e,r){var g,O;(g=o._tooltipOptions)!=null&&g.content&&((O=o._tooltip)==null||O.setContent(typeof o._tooltipOptions.content=="function"?o._tooltipOptions.content(r):o._tooltipOptions.content).setLatLng(o._map.layerPointToLatLng(l.point(r.x,r.y))).openOn(o._map)),o._hoverHandler.mouseover(this,o,e,r),o._dispatch.call("mouseover",this,r,o,e),this.classList.add("hover")}).on("mouseout",function(e,r){var g;(g=o._tooltip)==null||g.close(),o._hoverHandler.mouseout(this,o,e,r),o._dispatch.call("mouseout",this,r,o,e),this.classList.remove("hover")}).on("click",function(e,r){const g=o._map.layerPointToLatLng(l.point(r.x,r.y));o._dispatch.call("click",this,r,g,o,e),e.stopPropagation()});const R=b.exit();R.select("path.hexbin-hexagon").transition().duration(o.options.duration).attr("fill-opacity",0).attr("stroke-opacity",0).attr("d",e=>o._hexLayout.hexagon(0)),R.transition().duration(o.options.duration).remove()}_getExtent(t,i,o){let c=u.extent(t,i.bind(this));return(c[0]===void 0||c[1]===void 0)&&(c=[0,0]),o[0]!=null&&(c[0]=o[0]),o[1]!=null&&(c[1]=o[1]),c}radius(t){return t===void 0?this.options.radius:(this.options.radius=t,this._hexLayout.radius(t),this.options.radiusRange==null&&this._scale.radius.range([this.options.radius,this.options.radius]).clamp(!0),this)}opacity(t){return t===void 0?this.options.opacity:(this.options.opacity=t,this._scale.opacity.range(typeof t=="number"?[t,t]:t).clamp(!0),this)}duration(t){return t===void 0?this.options.duration:(this.options.duration=t,this)}colorScaleExtent(t){return t===void 0?this.options.colorScaleExtent:(this.options.colorScaleExtent=t,this)}radiusScaleExtent(t){return t===void 0?this.options.radiusScaleExtent:(this.options.radiusScaleExtent=t,this)}opacityScaleExtent(t){return t===void 0?this.options.opacityScaleExtent:(this.options.opacityScaleExtent=t,this)}colorRange(t){return t===void 0?this.options.colorRange:(this.options.colorRange=t,this._scale.color.range(t),this)}radiusRange(t){return t===void 0?this.options.radiusRange:(this.options.radiusRange=t,this._scale.radius.range(this.options.radiusRange??[this.options.radius,this.options.radius]).clamp(!0),this)}colorScale(t){return t===void 0?this._scale.color:(this._scale.color=t,this)}radiusScale(t){return t===void 0?this._scale.radius:(this._scale.radius=t,this)}lng(t){return t===void 0?this._fn.lng:(this._fn.lng=t,this)}lat(t){return t===void 0?this._fn.lat:(this._fn.lat=t,this)}colorValue(t){return t===void 0?this._fn.colorValue:(this._fn.colorValue=t,this)}radiusValue(t){return t===void 0?this._fn.radiusValue:(this._fn.radiusValue=t,this)}fill(t){return t===void 0?this._fn.fill:(this._fn.fill=t,this)}data(t,i){return t===void 0?this._data:(!w(t[0])&&!i&&console.error("Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression"),this._data=t??[],this._accessor=i??(o=>o),this.options.noRedraw||this.redraw(),this)}dispatch(){return this._dispatch}hoverHandler(t){return t===void 0?this._hoverHandler:(this._hoverHandler=t??x.none(),this.options.noRedraw||this.redraw(),this)}tooltip(t){return this._tooltipOptions=t,this._tooltip?this._tooltip.options=t.options??{}:this._tooltip=l.tooltip(t.options),this}getTooltip(){return this._tooltip}bindTooltip(t,i){return t instanceof l.Tooltip?(this._tooltip=t,this._map&&this._tooltip.setLatLng([0,0]).addTo(this._map)):this._tooltip=l.tooltip(i).setContent(t),this}unbindTooltip(){var t;return(t=this._tooltip)==null||t.remove(),this._tooltip=void 0,this}getLatLngs(){const t=this;return this._data.map(function(i){return l.latLng(t._fn.lat(i),t._fn.lng(i))})}toGeoJSON(){return l.GeoJSON.getFeature(this,{type:"MultiPoint",coordinates:l.GeoJSON.latLngsToCoords(this.getLatLngs(),0)})}}function H(s){return new S(s)}h.HexbinHoverHandler=x,h.HexbinLayer=S,h.hexbinLayer=H,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/HexbinHoverHandler.ts","../src/HexbinLayer.ts"],"sourcesContent":["import * as d3 from 'd3';\nimport type { HexbinData } from './HexbinLayer';\nimport { type HexbinLayer } from './HexbinLayer';\n\nexport interface HexbinHoverHandler<Data> {\n mouseover(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n mouseout(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n}\n\nexport namespace HexbinHoverHandler {\n\n export function resizeFill(): HexbinHoverHandler<any> {\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.options.radius);\n });\n },\n mouseout: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n\n }\n\n export interface ResizeScaleOptions {\n radiusScale?: number;\n duration?: number;\n }\n\n export function resizeScale(radiusScale: number = 1.5): HexbinHoverHandler<any> {\n\n // return the handler instance\n return {\n mouseover: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function () {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius.range()[1] * (radiusScale));\n });\n },\n mouseout: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement!);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', (d) => {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n }\n\n\n export function compound<Data>(handlers: HexbinHoverHandler<Data>[] = [none()]): HexbinHoverHandler<Data> {\n return {\n mouseover: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseover(svg, hexLayer, event, data); });\n },\n mouseout: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseout(svg, hexLayer, event, data); });\n }\n };\n }\n\n export function none(): HexbinHoverHandler<any> {\n return {\n mouseover: function () { },\n mouseout: function () { }\n };\n }\n\n}\nexport default HexbinHoverHandler\n","import { scaleLinear, dispatch, select, extent } from 'd3';\nimport { hexbin, type HexbinBin } from 'd3-hexbin';\nimport * as L from 'leaflet';\nimport HexbinHoverHandler from './HexbinHoverHandler';\n\n// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\n\ntype TooltipOptions<Data> = {\n options?: L.TooltipOptions,\n content?: L.Content | ((d: HexbinData<Data>[]) => L.Content)\n}\n\nexport interface HexbinLayerConfig {\n /**\n * Hex grid cell radius in pixels.\n * This value should be a positive number.\n * This radius controls the radius of the hexagons used to bin the data\n * but not necessarily to draw each individual hexbin.\n * @default 12\n */\n radius?: number,\n /**\n * Sets the opacity on the hexbin layer.\n * This value should be a number between 0 and 1.\n * If an array is provided, the first element is the minimum opacity and the second is the maximum.\n * @default 0.6\n */\n opacity?: number | [number, number],\n /**\n * Opacity scale extent: [min, max] domain for opacity interpolation.\n * @default [1, undefined]\n */\n opacityScaleExtent?: [number, number | undefined],\n /**\n * Duration of transition in milliseconds.\n * @default 200\n */\n duration?: number,\n\n /**\n * Color scale extent: [min, max] domain for color interpolation.\n * @default [1, undefined]\n */\n colorScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the color domain from the data.\n * Normally, you can tweak the generation of the color domain using the colorScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the color scale before rendering.\n * @default null\n */\n colorDomain?: number[] | null\n /**\n * Color range used to fill the hexbins.\n * @default ['#f7fbff', '#08306b']\n */\n colorRange?: string[],\n\n /**\n * Radius scale extent: [min, max] domain for radius interpolation.\n * @default [1, undefined]\n */\n radiusScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the radius domain from the data.\n * Normally, you can tweak the generation of the radius domain using the radiusScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the radius scale before rendering.\n * @default null\n */\n radiusDomain?: number[] | null\n /**\n * Sets the range of the radius scale used to size the hexbins.\n * @default hex grid cell radius\n */\n radiusRange?: [number, number] | null,\n\n /**\n * You should only modify this config option if you want to change the mouse event behavior on hexbins. This will modify when the events are propagated based on the visibility state and/or part of the hexbin being hovered.\n * @default 'all'\n */\n pointerEvents?: string\n}\n\n/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData<Data> = {\n data: Data;\n coord: L.LatLngExpression;\n point: Readonly<[number, number]>;\n}\n\n\nfunction isLatLngExpression(d: any): d is L.LatLngExpression {\n return (\n d instanceof L.LatLng ||\n (typeof d === 'object' && \"lat\" in d && \"lng\" in d) ||\n (Array.isArray(d) && d.length === 2 && typeof d[0] === 'number' && typeof d[1] === 'number')\n )\n}\n\n/**\n * Instantiate a hexbin layer.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {\n options: Required<HexbinLayerConfig> & L.RendererOptions = {\n radius: 12,\n opacity: 0.6,\n duration: 200,\n\n colorScaleExtent: [1, undefined],\n radiusScaleExtent: [1, undefined],\n opacityScaleExtent: [1, undefined],\n colorDomain: null,\n radiusDomain: null,\n colorRange: ['#f7fbff', '#08306b'],\n radiusRange: null,\n\n pointerEvents: 'all',\n // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n _fn = {\n lng: (d: Data) => L.latLng(this._accessor(d)).lng,\n lat: (d: Data) => L.latLng(this._accessor(d)).lat,\n colorValue: (d: HexbinData<Data>[]) => d.length,\n radiusValue: (d: HexbinData<Data>[]) => d.length,\n opacityValue: (d: HexbinData<Data>[]) => d.length,\n fill: (d: HexbinData<Data>[]) => {\n const val = this._fn.colorValue(d);\n return (null != val) ? this._scale.color(val) : 'none';\n }\n }\n // Set up the customizable scale\n _scale = {\n color: scaleLinear<string, string>(),\n radius: scaleLinear(),\n opacity: scaleLinear()\n };\n\n // Set up the Dispatcher for managing events and callbacks\n _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n _hoverHandler: HexbinHoverHandler<Data> = HexbinHoverHandler.none();\n\n // Create the hex layout\n _hexLayout = hexbin<HexbinData<Data>>()\n .radius(this.options.radius)\n .x(({ point: [x, _] }) => x)\n .y(({ point: [_, y] }) => y);\n\n // Initialize the data array to be empty\n _data = Array<Data>()\n\n\n declare _map: L.Map;\n\n _tooltipOptions: TooltipOptions<Data> = {};\n declare _tooltip: L.Tooltip | undefined;\n\n declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare _d3Container: d3.Selection<SVGGElement, unknown, null, undefined>;\n\n public constructor(options?: HexbinLayerConfig) {\n super()\n // L.SVG.prototype.initialize.call(this, options);\n this.options = { ...this.options, ...options };\n this._scale.color\n .range(this.options.colorRange)\n .clamp(true);\n\n this._scale.radius\n .range(this.options.radiusRange ?? [this.options.radius, this.options.radius])\n .clamp(true);\n\n this._scale.opacity\n .range(\n typeof this.options.opacity === 'number'\n ? [this.options.opacity, this.options.opacity]\n : this.options.opacity\n ).clamp(true);\n\n };\n\n _accessor(d: Data) {\n return d as L.LatLngExpression;\n }\n\n /**\n * Create the SVG container for the hexbins\n * @private\n */\n _initContainer() {\n super._initContainer();\n this._d3Container = select(this._container).select<SVGElementTagNameMap['g']>('g');\n }\n /**\n * Callback made by Leaflet when the layer is added to the map\n * @param map Reference to the map to which this layer has been added\n */\n onAdd(map: L.Map): this {\n // Call super.onAdd to properly initialize the SVG pane\n super.onAdd(map)\n\n // Store a reference to the map for later use\n this._map = map;\n this._tooltip?.setLatLng([0, 0]).addTo(map);\n // Redraw on moveend\n map.on('moveend', this.redraw, this);\n // Initial draw\n this.redraw();\n return this\n }\n\n _project(latlng: L.LatLngExpression) {\n const { x, y } = this._map.latLngToLayerPoint(latlng);\n return [x, y] as const;\n }\n\n /**\n * Callback made by Leaflet when the layer is removed from the map\n * @param map Reference to the map from which this layer is being removed\n */\n onRemove(map: L.Map): this {\n // Destroy the svg container\n this._destroyContainer();\n // Remove events\n map.off('moveend', this.redraw, this);\n return this\n }\n\n /**\n * Clean up the svg container\n * @private\n */\n _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n * @private\n */\n redraw() {\n const that = this;\n\n if (!that._map) return\n\n // Generate the mapped version of the data\n const data = that._data.map<HexbinData<Data>>((d: Data) => {\n const coord = that._accessor(d)\n const point = that._project(coord);\n return { coord: coord, point, data: d };\n });\n\n // Select the hex group for the current zoom level. This has\n // the effect of recreating the group if the zoom level has changed\n const join = this._d3Container.selectAll<SVGGElement, number>('g.hexbin')\n .data<number>([this._map.getZoom()], (d) => d);\n\n // enter\n const enter = join.enter().append('g')\n .attr('class', function (d) { return 'hexbin zoom-' + d; });\n\n // enter + update\n const enterUpdate = enter.merge(join);\n\n // exit\n join.exit().remove();\n\n // add the hexagons to the select\n this._createHexagons(enterUpdate, data);\n\n }\n\n _linearlySpace(from: number, to: number, length: number): number[] {\n const step = (to - from) / Math.max(length - 1, 1);\n return Array.from({ length }, (_, i) => from + (i * step));\n }\n\n _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData<Data>[]) {\n const thisLayer = this;\n\n // Create the bins using the hexbin layout\n\n // Generate the map bounds (to be used to filter the hexes to what is visible)\n const size = thisLayer._map.getSize();\n const bounds = thisLayer._map.getBounds().pad(thisLayer.options.radius * 2 / Math.max(size.x, size.y));\n\n const bins = thisLayer._hexLayout(data).filter(\n ({ x, y }) => bounds.contains(thisLayer._map.layerPointToLatLng(L.point(x, y)))\n );\n\n // Derive the extents of the data values for each dimension\n const colorExtent = thisLayer._getExtent(bins, thisLayer._fn.colorValue, thisLayer.options.colorScaleExtent);\n const radiusExtent = thisLayer._getExtent(bins, thisLayer._fn.radiusValue, thisLayer.options.radiusScaleExtent);\n const opacityExtent = thisLayer._getExtent(bins, thisLayer._fn.opacityValue, thisLayer.options.opacityScaleExtent);\n\n // Match the domain cardinality to that of the color range, to allow for a polylinear scale\n const colorDomain = this.options.colorDomain\n ?? thisLayer._linearlySpace(\n colorExtent[0],\n colorExtent[1],\n thisLayer._scale.color.range().length\n );\n const radiusDomain = this.options.radiusDomain || radiusExtent;\n\n // Set the scale domains\n thisLayer._scale.color.domain(colorDomain);\n thisLayer._scale.radius.domain(radiusDomain);\n thisLayer._scale.opacity.domain(opacityExtent);\n\n\n /*\n * Join\n * Join the Hexagons to the data\n * Use a deterministic id for tracking bins based on position\n */\n const join = g.selectAll<SVGGElement, HexbinBin<HexbinData<Data>>>('g.hexbin-container')\n .data(bins, ({ x, y }) => `${x}:${y}`);\n\n\n /*\n * Update\n * Set the fill and opacity on a transition\n * opacity is re-applied in case the enter transition was cancelled\n * the path is applied as well to resize the bins\n */\n join.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => {\n return thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d)));\n });\n\n\n /*\n * Enter\n * Establish the path, size, fill, and the initial opacity\n * Transition to the final opacity and size\n */\n const container = join.enter().append('g').attr('class', 'hexbin-container')\n .style('pointer-events', thisLayer.options.pointerEvents);\n\n\n container.on('mouseover', function (this: SVGGElement, d: MouseEvent, i) {\n // Bring container to foreground by re-appending it to the DOM\n select<SVGGElement, HexbinBin<HexbinData<Data>>>(this).raise();\n })\n\n const hexagons = container.append('path').attr('class', 'hexbin-hexagon')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer._scale.radius.range()[0]))\n // .attr('d', (data, length) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(data.length)))\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', 0.01)\n .attr('stroke-opacity', 0.01)\n .style('pointer-events', 'all');\n\n hexagons.transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d))))\n .style('pointer-events', 'all');\n\n // Grid\n const gridEnter = container.append('path').attr('class', 'hexbin-grid')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer.options.radius))\n .attr('fill', 'none')\n .attr('stroke', 'none')\n\n\n // Grid enter-update\n hexagons.on('mouseover', function (this: SVGPathElement, ev: MouseEvent, data) {\n if (thisLayer._tooltipOptions?.content) {\n thisLayer._tooltip\n ?.setContent(\n typeof thisLayer._tooltipOptions.content === \"function\"\n ? thisLayer._tooltipOptions.content(data)\n : thisLayer._tooltipOptions.content\n )\n .setLatLng(\n thisLayer._map.layerPointToLatLng(L.point(data.x, data.y))\n )\n .openOn(thisLayer._map);\n }\n thisLayer._hoverHandler.mouseover(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseover', this, data, thisLayer, ev);\n this.classList.add('hover')\n })\n .on('mouseout', function (this: SVGPathElement, ev: MouseEvent, data) {\n thisLayer._tooltip?.close()\n thisLayer._hoverHandler.mouseout(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseout', this, data, thisLayer, ev);\n this.classList.remove('hover')\n })\n .on('click', function (this, ev: MouseEvent, data) {\n const latLng = thisLayer._map.layerPointToLatLng(L.point(data.x, data.y));\n thisLayer._dispatch.call('click', this, data, latLng, thisLayer, ev);\n ev.stopPropagation()\n });\n\n\n // Exit\n const exit = join.exit();\n\n exit.select('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', 0)\n .attr('stroke-opacity', 0)\n .attr('d', (d) => thisLayer._hexLayout.hexagon(0));\n\n exit.transition().duration(thisLayer.options.duration).remove();\n\n }\n\n _getExtent(\n bins: HexbinBin<HexbinData<Data>>[],\n valueFn: (d: HexbinBin<HexbinData<Data>>) => number,\n scaleExtent: [number, number | undefined]\n ): [number, number] {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData<Data>>, number>(bins, valueFn.bind(this));\n // If either's null, initialize them to 0\n if (ext[0] === undefined || ext[1] === undefined) {\n ext = [0, 0]\n }\n\n // Now apply the optional clipping of the extent\n if (undefined != scaleExtent[0]) ext[0] = scaleExtent[0];\n if (undefined != scaleExtent[1]) ext[1] = scaleExtent[1];\n\n return ext as [number, number]\n }\n\n // ------------------------------------\n // Public API\n // ------------------------------------\n\n radius(): number;\n radius(v: number): this;\n radius(v?: number): this | number {\n if (v === undefined) return this.options.radius;\n\n this.options.radius = v;\n this._hexLayout.radius(v);\n\n if (null == this.options.radiusRange) {\n this._scale.radius.range([this.options.radius, this.options.radius]).clamp(true);\n }\n\n return this;\n }\n\n opacity(): number | [number, number];\n opacity(v: number | [number, number]): this;\n opacity(v?: number | [number, number]): this | number | [number, number] {\n if (v === undefined) return this.options.opacity\n this.options.opacity = v;\n this._scale.opacity.range(typeof v === 'number' ? [v, v] : v).clamp(true);\n\n return this;\n }\n\n duration(): number;\n duration(v: number): this;\n duration(v?: number): this | number {\n if (v === undefined) return this.options.duration\n this.options.duration = v\n\n return this;\n }\n\n colorScaleExtent(): [number, number | undefined];\n colorScaleExtent(v: [number, number | undefined]): this;\n colorScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.colorScaleExtent; }\n this.options.colorScaleExtent = v;\n\n return this;\n }\n\n radiusScaleExtent(): [number, number | undefined];\n radiusScaleExtent(v: [number, number | undefined]): this;\n radiusScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.radiusScaleExtent; }\n this.options.radiusScaleExtent = v;\n\n return this;\n }\n\n opacityScaleExtent(): [number, number | undefined];\n opacityScaleExtent(v: [number, number | undefined]): this;\n opacityScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.opacityScaleExtent; }\n this.options.opacityScaleExtent = v;\n\n return this;\n }\n\n\n colorRange(): string[];\n colorRange(v: string[]): this;\n colorRange(v?: string[]): this | string[] {\n if (v === undefined) { return this.options.colorRange; }\n this.options.colorRange = v;\n this._scale.color.range(v);\n\n return this;\n }\n\n radiusRange(): [number, number] | null;\n radiusRange(v: [number, number] | null): this;\n radiusRange(v?: [number, number] | null): this | [number, number] | null {\n if (v === undefined) { return this.options.radiusRange; }\n this.options.radiusRange = v;\n this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(true);\n\n return this;\n }\n\n colorScale(): d3.ScaleLinear<string, string>;\n colorScale(v: d3.ScaleLinear<string, string>): this;\n colorScale(v?: d3.ScaleLinear<string, string>) {\n if (v === undefined) return this._scale.color;\n this._scale.color = v;\n return this;\n }\n\n radiusScale(): d3.ScaleLinear<number, number>;\n radiusScale(v: d3.ScaleLinear<number, number>): this;\n radiusScale(v?: d3.ScaleLinear<number, number>): this | d3.ScaleLinear<number, number> {\n if (v === undefined) return this._scale.radius\n this._scale.radius = v;\n return this;\n }\n\n lng(): (d: Data) => number;\n lng(v: (d: Data) => number): this;\n lng(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lng; }\n this._fn.lng = v;\n\n return this;\n }\n\n lat(): (d: Data) => number;\n lat(v: (d: Data) => number): this;\n lat(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lat; }\n this._fn.lat = v;\n\n return this;\n }\n\n colorValue(): (d: HexbinData<Data>[]) => number;\n colorValue(v: (d: HexbinData<Data>[]) => number): this;\n colorValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.colorValue; }\n this._fn.colorValue = v;\n\n return this;\n }\n\n radiusValue(): (d: HexbinData<Data>[]) => number;\n radiusValue(v: (d: HexbinData<Data>[]) => number): this;\n radiusValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.radiusValue; }\n this._fn.radiusValue = v;\n\n return this;\n }\n\n fill(): (d: HexbinData<Data>[]) => string;\n fill(v: (d: HexbinData<Data>[]) => string): this;\n fill(v?: (d: HexbinData<Data>[]) => string) {\n if (v === undefined) { return this._fn.fill; }\n this._fn.fill = v;\n\n return this;\n }\n\n data(): Data[];\n data(v: Data extends L.LatLngExpression ? Data[] : never): this;\n data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;\n\n // Implementation\n data(v?: Data[] | L.LatLngExpression[], accessor?: (d: Data) => L.LatLngExpression): this | Data[] {\n if (v === undefined) {\n return this._data;\n }\n\n if (!isLatLngExpression(v[0]) && !accessor) {\n console.error(\"Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression\");\n }\n\n this._data = v as Data[] ?? []\n this._accessor = accessor ?? ((d: Data) => d as L.LatLngExpression)\n\n this.redraw();\n return this;\n }\n\n /*\n * Getter for the event dispatcher\n */\n dispatch() { return this._dispatch }\n\n hoverHandler(): HexbinHoverHandler<Data>;\n hoverHandler(v: HexbinHoverHandler<Data>): this;\n hoverHandler(v?: HexbinHoverHandler<Data>): this | HexbinHoverHandler<Data> {\n if (v === undefined) { return this._hoverHandler; }\n this._hoverHandler = (null != v) ? v : HexbinHoverHandler.none();\n\n this.redraw();\n\n return this;\n }\n\n // Cannot overload bindTooltip() with data dependant content\n tooltip(tooltip: TooltipOptions<Data>): this {\n this._tooltipOptions = tooltip;\n if (this._tooltip)\n this._tooltip.options = tooltip.options ?? {};\n else {\n this._tooltip = L.tooltip(tooltip.options)\n }\n return this\n }\n\n getTooltip(): L.Tooltip | undefined {\n return this._tooltip\n }\n\n bindTooltip(content: L.Tooltip | L.Content, options?: L.TooltipOptions): this {\n if (content instanceof L.Tooltip) {\n this._tooltip = content;\n // FIXME: weird bug likely coming from vue-leaflet were tooltip is not properly positioned\n // this._tooltip.options.offset[0] -= 5;\n if (this._map) {\n this._tooltip.setLatLng([0, 0]).addTo(this._map)\n }\n } else {\n this._tooltip = L.tooltip(options).setContent(content);\n }\n return this\n }\n\n unbindTooltip(): this {\n this._tooltip?.remove();\n this._tooltip = undefined;\n return this\n }\n\n /*\n * Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.\n */\n getLatLngs() {\n const that = this;\n\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map(function (d) {\n return L.latLng(that._fn.lat(d), that._fn.lng(d));\n });\n }\n /*\n * Get path geometry as GeoJSON\n */\n toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPoint, L.LatLng> {\n return L.GeoJSON.getFeature<L.LatLng, GeoJSON.MultiPoint>(this, {\n type: 'MultiPoint',\n coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)\n });\n }\n}\n\n/**\n * Factory function to instanciate a new hexbin layer\n */\nexport function hexbinLayer<Data = L.LatLngExpression>(options?: HexbinLayerConfig) {\n return new HexbinLayer<Data>(options);\n}\n\n\n"],"names":["HexbinHoverHandler","resizeFill","svg","hexLayer","event","data","d3","d","resizeScale","radiusScale","compound","handlers","none","h","HexbinHoverHandler$1","isLatLngExpression","L","HexbinLayer","options","val","scaleLinear","dispatch","hexbin","x","_","y","select","map","_a","latlng","that","coord","point","join","enterUpdate","from","to","length","step","i","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","hexagons","ev","_b","latLng","exit","valueFn","scaleExtent","ext","extent","v","accessor","tooltip","content","hexbinLayer"],"mappings":"ynBASiB,IAAAA,GAAAA,GAAV,CAEE,SAASC,GAAsC,CAC7C,MAAA,CACL,UAAW,SAAUC,EAAqBC,EAA4BC,EAAmBC,EAAyB,CACtGC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAO,qBAAqB,EAC3B,WAAa,EAAA,SAASC,EAAS,QAAQ,QAAQ,EAC/C,KAAK,IAAK,SAAUI,EAAG,CACtB,OAAOJ,EAAS,WAAW,QAAQA,EAAS,QAAQ,MAAM,CAAA,CAC3D,CACL,EACA,SAAU,SAAUD,EAAqBC,EAA4BC,EAAmBC,EAAyB,CACrGC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAuB,qBAAqB,EAC3C,WAAa,EAAA,SAASC,EAAS,QAAQ,QAAQ,EAC/C,KAAK,IAAK,SAAUI,EAAG,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OAAoB,KAAK,eACnC,KAAK,cAAyBA,GAAS5D,EAAmB,KAAK,EAE/D,KAAK,OAAO,EAEL,KAAA,CAIT,QAAQ8D,EAAqC,CAC3C,YAAK,gBAAkBA,EACnB,KAAK,SACP,KAAK,SAAS,QAAUA,EAAQ,SAAW,CAAC,EAE5C,KAAK,SAAW9C,EAAE,QAAQ8C,EAAQ,OAAO,EAEpC,IAAA,CAGT,YAAoC,CAClC,OAAO,KAAK,QAAA,CAGd,YAAYC,EAAgC7C,EAAkC,CACxE,OAAA6C,aAAmB/C,EAAE,SACvB,KAAK,SAAW+C,EAGZ,KAAK,MACF,KAAA,SAAS,UAAU,CAAC,EAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GAGjD,KAAK,SAAW/C,EAAE,QAAQE,CAAO,EAAE,WAAW6C,CAAO,EAEhD,IAAA,CAGT,eAAsB,OACpB,OAAAnC,EAAA,KAAK,WAAL,MAAAA,EAAe,SACf,KAAK,SAAW,OACT,IAAA,CAMT,YAAa,CACX,MAAME,EAAO,KAGb,OAAO,KAAK,MAAM,IAAI,SAAUvB,EAAG,CAC1B,OAAAS,EAAE,OAAOc,EAAK,IAAI,IAAIvB,CAAC,EAAGuB,EAAK,IAAI,IAAIvB,CAAC,CAAC,CAAA,CACjD,CAAA,CAKH,WAA2D,CAClD,OAAAS,EAAE,QAAQ,WAAyC,KAAM,CAC9D,KAAM,aACN,YAAaA,EAAE,QAAQ,gBAAgB,KAAK,WAAA,EAAc,CAAC,CAAA,CAC5D,CAAA,CAEL,CAKO,SAASgD,EAAuC9C,EAA6B,CAC3E,OAAA,IAAID,EAAkBC,CAAO,CACtC"}
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/HexbinHoverHandler.ts","../src/HexbinLayer.ts"],"sourcesContent":["import * as d3 from 'd3';\nimport type { HexbinData } from './HexbinLayer';\nimport { type HexbinLayer } from './HexbinLayer';\n\nexport interface HexbinHoverHandler<Data> {\n mouseover(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n mouseout(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n}\n\nexport namespace HexbinHoverHandler {\n\n export function resizeFill(): HexbinHoverHandler<any> {\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.options.radius);\n });\n },\n mouseout: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n\n }\n\n export interface ResizeScaleOptions {\n radiusScale?: number;\n duration?: number;\n }\n\n export function resizeScale(radiusScale: number = 1.5): HexbinHoverHandler<any> {\n\n // return the handler instance\n return {\n mouseover: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function () {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius.range()[1] * (radiusScale));\n });\n },\n mouseout: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement!);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', (d) => {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n }\n\n\n export function compound<Data>(handlers: HexbinHoverHandler<Data>[] = [none()]): HexbinHoverHandler<Data> {\n return {\n mouseover: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseover(svg, hexLayer, event, data); });\n },\n mouseout: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseout(svg, hexLayer, event, data); });\n }\n };\n }\n\n export function none(): HexbinHoverHandler<any> {\n return {\n mouseover: function () { },\n mouseout: function () { }\n };\n }\n\n}\nexport default HexbinHoverHandler\n","import { scaleLinear, dispatch, select, extent } from 'd3';\nimport { hexbin, type HexbinBin } from 'd3-hexbin';\nimport * as L from 'leaflet';\nimport HexbinHoverHandler from './HexbinHoverHandler';\n\n// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\n\ntype TooltipOptions<Data> = {\n options?: L.TooltipOptions,\n content?: L.Content | ((d: HexbinData<Data>[]) => L.Content)\n}\n\nexport interface HexbinLayerConfig {\n /**\n * Hex grid cell radius in pixels.\n * This value should be a positive number.\n * This radius controls the radius of the hexagons used to bin the data\n * but not necessarily to draw each individual hexbin.\n * @default 12\n */\n radius?: number,\n /**\n * Sets the opacity on the hexbin layer.\n * This value should be a number between 0 and 1.\n * If an array is provided, the first element is the minimum opacity and the second is the maximum.\n * @default 0.6\n */\n opacity?: number | [number, number],\n /**\n * Opacity scale extent: [min, max] domain for opacity interpolation.\n * @default [1, undefined]\n */\n opacityScaleExtent?: [number, number | undefined],\n /**\n * Duration of transition in milliseconds.\n * @default 200\n */\n duration?: number,\n\n /**\n * Color scale extent: [min, max] domain for color interpolation.\n * @default [1, undefined]\n */\n colorScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the color domain from the data.\n * Normally, you can tweak the generation of the color domain using the colorScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the color scale before rendering.\n * @default null\n */\n colorDomain?: number[] | null\n /**\n * Color range used to fill the hexbins.\n * @default ['#f7fbff', '#08306b']\n */\n colorRange?: string[],\n\n /**\n * Radius scale extent: [min, max] domain for radius interpolation.\n * @default [1, undefined]\n */\n radiusScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the radius domain from the data.\n * Normally, you can tweak the generation of the radius domain using the radiusScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the radius scale before rendering.\n * @default null\n */\n radiusDomain?: number[] | null\n /**\n * Sets the range of the radius scale used to size the hexbins.\n * @default hex grid cell radius\n */\n radiusRange?: [number, number] | null,\n\n /**\n * You should only modify this config option if you want to change the mouse event behavior on hexbins. This will modify when the events are propagated based on the visibility state and/or part of the hexbin being hovered.\n * @default 'all'\n */\n pointerEvents?: string\n\n /**\n * If true, the layer will not be redrawn after data changes and hover handler binding.\n * @default false\n */\n noRedraw?: boolean\n}\n\n/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData<Data> = {\n data: Data;\n coord: L.LatLngExpression;\n point: Readonly<[number, number]>;\n}\n\n\nfunction isLatLngExpression(d: any): d is L.LatLngExpression {\n return (\n d instanceof L.LatLng ||\n (typeof d === 'object' && \"lat\" in d && \"lng\" in d) ||\n (Array.isArray(d) && d.length === 2 && typeof d[0] === 'number' && typeof d[1] === 'number')\n )\n}\n\n/**\n * Instantiate a hexbin layer.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {\n options: Required<HexbinLayerConfig> & L.RendererOptions = {\n radius: 12,\n opacity: 0.6,\n duration: 200,\n\n colorScaleExtent: [1, undefined],\n radiusScaleExtent: [1, undefined],\n opacityScaleExtent: [1, undefined],\n colorDomain: null,\n radiusDomain: null,\n colorRange: ['#f7fbff', '#08306b'],\n radiusRange: null,\n\n pointerEvents: 'all',\n noRedraw: false,\n // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n _fn = {\n lng: (d: Data) => L.latLng(this._accessor(d)).lng,\n lat: (d: Data) => L.latLng(this._accessor(d)).lat,\n colorValue: (d: HexbinData<Data>[]) => d.length,\n radiusValue: (d: HexbinData<Data>[]) => d.length,\n opacityValue: (d: HexbinData<Data>[]) => d.length,\n fill: (d: HexbinData<Data>[]) => {\n const val = this._fn.colorValue(d);\n return (null != val) ? this._scale.color(val) : 'none';\n }\n }\n // Set up the customizable scale\n _scale = {\n color: scaleLinear<string, string>(),\n radius: scaleLinear(),\n opacity: scaleLinear()\n };\n\n // Set up the Dispatcher for managing events and callbacks\n _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n _hoverHandler: HexbinHoverHandler<Data> = HexbinHoverHandler.none();\n\n // Create the hex layout\n _hexLayout = hexbin<HexbinData<Data>>()\n .radius(this.options.radius)\n .x(({ point: [x, _] }) => x)\n .y(({ point: [_, y] }) => y);\n\n // Initialize the data array to be empty\n _data = Array<Data>()\n\n\n declare _map: L.Map;\n\n _tooltipOptions: TooltipOptions<Data> = {};\n declare _tooltip: L.Tooltip | undefined;\n\n declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare _d3Container: d3.Selection<SVGGElement, unknown, null, undefined>;\n\n public constructor(options?: HexbinLayerConfig) {\n super()\n // L.SVG.prototype.initialize.call(this, options);\n this.options = { ...this.options, ...options };\n this._scale.color\n .range(this.options.colorRange)\n .clamp(true);\n\n this._scale.radius\n .range(this.options.radiusRange ?? [this.options.radius, this.options.radius])\n .clamp(true);\n\n this._scale.opacity\n .range(\n typeof this.options.opacity === 'number'\n ? [this.options.opacity, this.options.opacity]\n : this.options.opacity\n ).clamp(true);\n\n };\n\n _accessor(d: Data) {\n return d as L.LatLngExpression;\n }\n\n /**\n * Create the SVG container for the hexbins\n * @private\n */\n _initContainer() {\n super._initContainer();\n this._d3Container = select(this._container).select<SVGElementTagNameMap['g']>('g');\n }\n /**\n * Callback made by Leaflet when the layer is added to the map\n * @param map Reference to the map to which this layer has been added\n */\n onAdd(map: L.Map): this {\n // Call super.onAdd to properly initialize the SVG pane\n super.onAdd(map)\n\n // Store a reference to the map for later use\n this._map = map;\n this._tooltip?.setLatLng([0, 0]).addTo(map);\n // Redraw on moveend\n map.on('moveend', this.redraw, this);\n // Initial draw\n this.redraw();\n return this\n }\n\n _project(latlng: L.LatLngExpression) {\n const { x, y } = this._map.latLngToLayerPoint(latlng);\n return [x, y] as const;\n }\n\n /**\n * Callback made by Leaflet when the layer is removed from the map\n * @param map Reference to the map from which this layer is being removed\n */\n onRemove(map: L.Map): this {\n // Destroy the svg container\n this._destroyContainer();\n // Remove events\n map.off('moveend', this.redraw, this);\n return this\n }\n\n /**\n * Clean up the svg container\n * @private\n */\n _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n * @private\n */\n redraw() {\n const that = this;\n\n if (!that._map) return\n\n // Generate the mapped version of the data\n const data = that._data.map<HexbinData<Data>>((d: Data) => {\n const coord = that._accessor(d)\n const point = that._project(coord);\n return { coord: coord, point, data: d };\n });\n\n // Select the hex group for the current zoom level. This has\n // the effect of recreating the group if the zoom level has changed\n const join = this._d3Container.selectAll<SVGGElement, number>('g.hexbin')\n .data<number>([this._map.getZoom()], (d) => d);\n\n // enter\n const enter = join.enter().append('g')\n .attr('class', function (d) { return 'hexbin zoom-' + d; });\n\n // enter + update\n const enterUpdate = enter.merge(join);\n\n // exit\n join.exit().remove();\n\n // add the hexagons to the select\n this._createHexagons(enterUpdate, data);\n\n }\n\n _linearlySpace(from: number, to: number, length: number): number[] {\n const step = (to - from) / Math.max(length - 1, 1);\n return Array.from({ length }, (_, i) => from + (i * step));\n }\n\n _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData<Data>[]) {\n const thisLayer = this;\n\n // Create the bins using the hexbin layout\n\n // Generate the map bounds (to be used to filter the hexes to what is visible)\n const size = thisLayer._map.getSize();\n const bounds = thisLayer._map.getBounds().pad(thisLayer.options.radius * 2 / Math.max(size.x, size.y));\n\n const bins = thisLayer._hexLayout(data).filter(\n ({ x, y }) => bounds.contains(thisLayer._map.layerPointToLatLng(L.point(x, y)))\n );\n\n // Derive the extents of the data values for each dimension\n const colorExtent = thisLayer._getExtent(bins, thisLayer._fn.colorValue, thisLayer.options.colorScaleExtent);\n const radiusExtent = thisLayer._getExtent(bins, thisLayer._fn.radiusValue, thisLayer.options.radiusScaleExtent);\n const opacityExtent = thisLayer._getExtent(bins, thisLayer._fn.opacityValue, thisLayer.options.opacityScaleExtent);\n\n // Match the domain cardinality to that of the color range, to allow for a polylinear scale\n const colorDomain = this.options.colorDomain\n ?? thisLayer._linearlySpace(\n colorExtent[0],\n colorExtent[1],\n thisLayer._scale.color.range().length\n );\n const radiusDomain = this.options.radiusDomain || radiusExtent;\n\n // Set the scale domains\n thisLayer._scale.color.domain(colorDomain);\n thisLayer._scale.radius.domain(radiusDomain);\n thisLayer._scale.opacity.domain(opacityExtent);\n\n\n /*\n * Join\n * Join the Hexagons to the data\n * Use a deterministic id for tracking bins based on position\n */\n const join = g.selectAll<SVGGElement, HexbinBin<HexbinData<Data>>>('g.hexbin-container')\n .data(bins, ({ x, y }) => `${x}:${y}`);\n\n\n /*\n * Update\n * Set the fill and opacity on a transition\n * opacity is re-applied in case the enter transition was cancelled\n * the path is applied as well to resize the bins\n */\n join.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => {\n return thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d)));\n });\n\n\n /*\n * Enter\n * Establish the path, size, fill, and the initial opacity\n * Transition to the final opacity and size\n */\n const container = join.enter().append('g').attr('class', 'hexbin-container')\n .style('pointer-events', thisLayer.options.pointerEvents);\n\n\n container.on('mouseover', function (this: SVGGElement, d: MouseEvent, i) {\n // Bring container to foreground by re-appending it to the DOM\n select<SVGGElement, HexbinBin<HexbinData<Data>>>(this).raise();\n })\n\n const hexagons = container.append('path').attr('class', 'hexbin-hexagon')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer._scale.radius.range()[0]))\n // .attr('d', (data, length) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(data.length)))\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', 0.01)\n .attr('stroke-opacity', 0.01)\n .style('pointer-events', 'all');\n\n hexagons.transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d))))\n .style('pointer-events', 'all');\n\n // Grid\n const gridEnter = container.append('path').attr('class', 'hexbin-grid')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer.options.radius))\n .attr('fill', 'none')\n .attr('stroke', 'none')\n\n\n // Grid enter-update\n hexagons.on('mouseover', function (this: SVGPathElement, ev: MouseEvent, data) {\n if (thisLayer._tooltipOptions?.content) {\n thisLayer._tooltip\n ?.setContent(\n typeof thisLayer._tooltipOptions.content === \"function\"\n ? thisLayer._tooltipOptions.content(data)\n : thisLayer._tooltipOptions.content\n )\n .setLatLng(\n thisLayer._map.layerPointToLatLng(L.point(data.x, data.y))\n )\n .openOn(thisLayer._map);\n }\n thisLayer._hoverHandler.mouseover(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseover', this, data, thisLayer, ev);\n this.classList.add('hover')\n })\n .on('mouseout', function (this: SVGPathElement, ev: MouseEvent, data) {\n thisLayer._tooltip?.close()\n thisLayer._hoverHandler.mouseout(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseout', this, data, thisLayer, ev);\n this.classList.remove('hover')\n })\n .on('click', function (this, ev: MouseEvent, data) {\n const latLng = thisLayer._map.layerPointToLatLng(L.point(data.x, data.y));\n thisLayer._dispatch.call('click', this, data, latLng, thisLayer, ev);\n ev.stopPropagation()\n });\n\n\n // Exit\n const exit = join.exit();\n\n exit.select('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', 0)\n .attr('stroke-opacity', 0)\n .attr('d', (d) => thisLayer._hexLayout.hexagon(0));\n\n exit.transition().duration(thisLayer.options.duration).remove();\n\n }\n\n _getExtent(\n bins: HexbinBin<HexbinData<Data>>[],\n valueFn: (d: HexbinBin<HexbinData<Data>>) => number,\n scaleExtent: [number, number | undefined]\n ): [number, number] {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData<Data>>, number>(bins, valueFn.bind(this));\n // If either's null, initialize them to 0\n if (ext[0] === undefined || ext[1] === undefined) {\n ext = [0, 0]\n }\n\n // Now apply the optional clipping of the extent\n if (undefined != scaleExtent[0]) ext[0] = scaleExtent[0];\n if (undefined != scaleExtent[1]) ext[1] = scaleExtent[1];\n\n return ext as [number, number]\n }\n\n // ------------------------------------\n // Public API\n // ------------------------------------\n\n radius(): number;\n radius(v: number): this;\n radius(v?: number): this | number {\n if (v === undefined) return this.options.radius;\n\n this.options.radius = v;\n this._hexLayout.radius(v);\n\n if (null == this.options.radiusRange) {\n this._scale.radius.range([this.options.radius, this.options.radius]).clamp(true);\n }\n\n return this;\n }\n\n opacity(): number | [number, number];\n opacity(v: number | [number, number]): this;\n opacity(v?: number | [number, number]): this | number | [number, number] {\n if (v === undefined) return this.options.opacity\n this.options.opacity = v;\n this._scale.opacity.range(typeof v === 'number' ? [v, v] : v).clamp(true);\n\n return this;\n }\n\n duration(): number;\n duration(v: number): this;\n duration(v?: number): this | number {\n if (v === undefined) return this.options.duration\n this.options.duration = v\n\n return this;\n }\n\n colorScaleExtent(): [number, number | undefined];\n colorScaleExtent(v: [number, number | undefined]): this;\n colorScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.colorScaleExtent; }\n this.options.colorScaleExtent = v;\n\n return this;\n }\n\n radiusScaleExtent(): [number, number | undefined];\n radiusScaleExtent(v: [number, number | undefined]): this;\n radiusScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.radiusScaleExtent; }\n this.options.radiusScaleExtent = v;\n\n return this;\n }\n\n opacityScaleExtent(): [number, number | undefined];\n opacityScaleExtent(v: [number, number | undefined]): this;\n opacityScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.opacityScaleExtent; }\n this.options.opacityScaleExtent = v;\n\n return this;\n }\n\n\n colorRange(): string[];\n colorRange(v: string[]): this;\n colorRange(v?: string[]): this | string[] {\n if (v === undefined) { return this.options.colorRange; }\n this.options.colorRange = v;\n this._scale.color.range(v);\n\n return this;\n }\n\n radiusRange(): [number, number] | null;\n radiusRange(v: [number, number] | null): this;\n radiusRange(v?: [number, number] | null): this | [number, number] | null {\n if (v === undefined) { return this.options.radiusRange; }\n this.options.radiusRange = v;\n this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(true);\n\n return this;\n }\n\n colorScale(): d3.ScaleLinear<string, string>;\n colorScale(v: d3.ScaleLinear<string, string>): this;\n colorScale(v?: d3.ScaleLinear<string, string>) {\n if (v === undefined) return this._scale.color;\n this._scale.color = v;\n return this;\n }\n\n radiusScale(): d3.ScaleLinear<number, number>;\n radiusScale(v: d3.ScaleLinear<number, number>): this;\n radiusScale(v?: d3.ScaleLinear<number, number>): this | d3.ScaleLinear<number, number> {\n if (v === undefined) return this._scale.radius\n this._scale.radius = v;\n return this;\n }\n\n lng(): (d: Data) => number;\n lng(v: (d: Data) => number): this;\n lng(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lng; }\n this._fn.lng = v;\n\n return this;\n }\n\n lat(): (d: Data) => number;\n lat(v: (d: Data) => number): this;\n lat(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lat; }\n this._fn.lat = v;\n\n return this;\n }\n\n colorValue(): (d: HexbinData<Data>[]) => number;\n colorValue(v: (d: HexbinData<Data>[]) => number): this;\n colorValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.colorValue; }\n this._fn.colorValue = v;\n\n return this;\n }\n\n radiusValue(): (d: HexbinData<Data>[]) => number;\n radiusValue(v: (d: HexbinData<Data>[]) => number): this;\n radiusValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.radiusValue; }\n this._fn.radiusValue = v;\n\n return this;\n }\n\n fill(): (d: HexbinData<Data>[]) => string;\n fill(v: (d: HexbinData<Data>[]) => string): this;\n fill(v?: (d: HexbinData<Data>[]) => string) {\n if (v === undefined) { return this._fn.fill; }\n this._fn.fill = v;\n\n return this;\n }\n\n data(): Data[];\n data(v: Data extends L.LatLngExpression ? Data[] : never): this;\n data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;\n\n // Implementation\n data(v?: Data[] | L.LatLngExpression[], accessor?: (d: Data) => L.LatLngExpression): this | Data[] {\n if (v === undefined) {\n return this._data;\n }\n\n if (!isLatLngExpression(v[0]) && !accessor) {\n console.error(\"Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression\");\n }\n\n this._data = v as Data[] ?? []\n this._accessor = accessor ?? ((d: Data) => d as L.LatLngExpression)\n\n if (!this.options.noRedraw) this.redraw();\n return this;\n }\n\n /*\n * Getter for the event dispatcher\n */\n dispatch() { return this._dispatch }\n\n hoverHandler(): HexbinHoverHandler<Data>;\n hoverHandler(v: HexbinHoverHandler<Data>): this;\n hoverHandler(v?: HexbinHoverHandler<Data>): this | HexbinHoverHandler<Data> {\n if (v === undefined) { return this._hoverHandler; }\n this._hoverHandler = (null != v) ? v : HexbinHoverHandler.none();\n\n if (!this.options.noRedraw) this.redraw();\n\n return this;\n }\n\n // Cannot overload bindTooltip() with data dependant content\n tooltip(tooltip: TooltipOptions<Data>): this {\n this._tooltipOptions = tooltip;\n if (this._tooltip)\n this._tooltip.options = tooltip.options ?? {};\n else {\n this._tooltip = L.tooltip(tooltip.options)\n }\n return this\n }\n\n getTooltip(): L.Tooltip | undefined {\n return this._tooltip\n }\n\n bindTooltip(content: L.Tooltip | L.Content, options?: L.TooltipOptions): this {\n if (content instanceof L.Tooltip) {\n this._tooltip = content;\n // FIXME: weird bug likely coming from vue-leaflet were tooltip is not properly positioned\n // this._tooltip.options.offset[0] -= 5;\n if (this._map) {\n this._tooltip.setLatLng([0, 0]).addTo(this._map)\n }\n } else {\n this._tooltip = L.tooltip(options).setContent(content);\n }\n return this\n }\n\n unbindTooltip(): this {\n this._tooltip?.remove();\n this._tooltip = undefined;\n return this\n }\n\n /*\n * Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.\n */\n getLatLngs() {\n const that = this;\n\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map(function (d) {\n return L.latLng(that._fn.lat(d), that._fn.lng(d));\n });\n }\n /*\n * Get path geometry as GeoJSON\n */\n toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPoint, L.LatLng> {\n return L.GeoJSON.getFeature<L.LatLng, GeoJSON.MultiPoint>(this, {\n type: 'MultiPoint',\n coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)\n });\n }\n}\n\n/**\n * Factory function to instanciate a new hexbin layer\n */\nexport function hexbinLayer<Data = L.LatLngExpression>(options?: HexbinLayerConfig) {\n return new HexbinLayer<Data>(options);\n}\n\n\n"],"names":["HexbinHoverHandler","resizeFill","svg","hexLayer","event","data","d3","d","resizeScale","radiusScale","compound","handlers","none","h","HexbinHoverHandler$1","isLatLngExpression","L","HexbinLayer","options","val","scaleLinear","dispatch","hexbin","x","_","y","select","map","_a","latlng","that","coord","point","join","enterUpdate","from","to","length","step","i","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","hexagons","ev","_b","latLng","exit","valueFn","scaleExtent","ext","extent","v","accessor","tooltip","content","hexbinLayer"],"mappings":"ynBASiB,IAAAA,GAAAA,GAAV,CAEE,SAASC,GAAsC,CAC7C,MAAA,CACL,UAAW,SAAUC,EAAqBC,EAA4BC,EAAmBC,EAAyB,CACtGC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAO,qBAAqB,EAC3B,WAAa,EAAA,SAASC,EAAS,QAAQ,QAAQ,EAC/C,KAAK,IAAK,SAAUI,EAAG,CACtB,OAAOJ,EAAS,WAAW,QAAQA,EAAS,QAAQ,MAAM,CAAA,CAC3D,CACL,EACA,SAAU,SAAUD,EAAqBC,EAA4BC,EAAmBC,EAAyB,CACrGC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAuB,qBAAqB,EAC3C,WAAa,EAAA,SAASC,EAAS,QAAQ,QAAQ,EAC/C,KAAK,IAAK,SAAUI,EAAG,CACtB,OAAOJ,EAAS,WAAW,QAAQA,EAAS,OAAO,OAAOA,EAAS,IAAI,YAAY,KAAKA,EAAUI,CAAC,CAAC,CAAC,CAAA,CACtG,CAAA,CAEP,CAAA,CAlBKP,EAAS,WAAAC,EA2BA,SAAAO,EAAYC,EAAsB,IAA8B,CAGvE,MAAA,CACL,UAAW,SAAUP,EAAKC,EAAUC,EAAOC,EAAM,CACrCC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAO,qBAAqB,EAC3B,WAAA,EAAa,SAASC,EAAS,QAAQ,QAAQ,EAC/C,KAAK,IAAK,UAAY,CACd,OAAAA,EAAS,WAAW,QAAQA,EAAS,O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KAAK,MACF,KAAA,SAAS,UAAU,CAAC,EAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GAGjD,KAAK,SAAW/C,EAAE,QAAQE,CAAO,EAAE,WAAW6C,CAAO,EAEhD,IAAA,CAGT,eAAsB,OACpB,OAAAnC,EAAA,KAAK,WAAL,MAAAA,EAAe,SACf,KAAK,SAAW,OACT,IAAA,CAMT,YAAa,CACX,MAAME,EAAO,KAGb,OAAO,KAAK,MAAM,IAAI,SAAUvB,EAAG,CAC1B,OAAAS,EAAE,OAAOc,EAAK,IAAI,IAAIvB,CAAC,EAAGuB,EAAK,IAAI,IAAIvB,CAAC,CAAC,CAAA,CACjD,CAAA,CAKH,WAA2D,CAClD,OAAAS,EAAE,QAAQ,WAAyC,KAAM,CAC9D,KAAM,aACN,YAAaA,EAAE,QAAQ,gBAAgB,KAAK,WAAA,EAAc,CAAC,CAAA,CAC5D,CAAA,CAEL,CAKO,SAASgD,EAAuC9C,EAA6B,CAC3E,OAAA,IAAID,EAAkBC,CAAO,CACtC"}
|
@@ -78,6 +78,11 @@ export interface HexbinLayerConfig {
|
|
78
78
|
* @default 'all'
|
79
79
|
*/
|
80
80
|
pointerEvents?: string;
|
81
|
+
/**
|
82
|
+
* If true, the layer will not be redrawn after data changes and hover handler binding.
|
83
|
+
* @default false
|
84
|
+
*/
|
85
|
+
noRedraw?: boolean;
|
81
86
|
}
|
82
87
|
/**
|
83
88
|
* Hexbin data attached to each hexagon, once binned.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "leaflet-hexbin",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.2",
|
4
4
|
"private": false,
|
5
5
|
"type": "module",
|
6
6
|
"license": "MIT",
|
@@ -42,9 +42,9 @@
|
|
42
42
|
"@types/d3-hexbin": "^0.2.5",
|
43
43
|
"@types/jsdom": "^21.1.7",
|
44
44
|
"@types/leaflet": "^1.9.16",
|
45
|
-
"@types/node": "^22.
|
45
|
+
"@types/node": "^22.13.1",
|
46
46
|
"@vitest/eslint-plugin": "1.1.25",
|
47
|
-
"eslint": "^9.
|
47
|
+
"eslint": "^9.20.0",
|
48
48
|
"jiti": "^2.4.2",
|
49
49
|
"jsdom": "^26.0.0",
|
50
50
|
"npm-run-all2": "^7.0.2",
|