@andyreagan/hedotools 4.0.0 → 5.0.0

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/bundle.sh CHANGED
@@ -1,7 +1,11 @@
1
1
  #!/usr/bin/env bash
2
2
  # Concatenate the D3 v4 sources into a single browser bundle for hedonometer.org.
3
3
  # Order matters: init.v4 defines the `hedotools` namespace + helpers first, and
4
- # the dashboard modules (barchart/lens/map/sankey) depend on the shifter.
4
+ # the dashboard modules (barchart/lens/map/sankey) depend on hedotools.shifter.
5
+ #
6
+ # NOTE: hedotools.shifter.js only adapts the @andyreagan/d3-shifterator package
7
+ # into hedotools.shifter — the page must load D3 v4 and the d3-shifterator UMD
8
+ # bundle (global `shifterator`) BEFORE this bundle.
5
9
  set -euo pipefail
6
10
  cd "$(dirname "$0")/js"
7
11
 
@@ -12,7 +16,7 @@ cat \
12
16
  hedotools.lens.js \
13
17
  hedotools.map.js \
14
18
  hedotools.sankey.js \
15
- hedotools.shifter.v4.js \
19
+ hedotools.shifter.js \
16
20
  > hedotools.v4.js
17
21
 
18
22
  echo "built js/hedotools.v4.js"
@@ -343,12 +343,12 @@ hedotools.sankey = function() {
343
343
  console.log(compfile);
344
344
  var refF;
345
345
  var compF;
346
- d3.text(reffile,function(text) {
346
+ d3.text(reffile).then(function(text) {
347
347
  refF = text.split(",");
348
348
  console.log(refF);
349
349
  if (!--csvLoadsRemaining) drawShift();
350
350
  });
351
- d3.text(compfile,function(text) {
351
+ d3.text(compfile).then(function(text) {
352
352
  compF = text.split(",");
353
353
  console.log(compF);
354
354
  if (!--csvLoadsRemaining) drawShift();
@@ -0,0 +1,27 @@
1
+ // hedotools.shifter — the wordshift graph.
2
+ //
3
+ // As of v4.5 this is no longer implemented here; it lives in its own package,
4
+ // @andyreagan/d3-shifterator (extracted from this repo's old shifter.v4.js).
5
+ // We instantiate that package's factory once and expose it as the shared
6
+ // `hedotools.shifter` singleton that the dashboard modules (barchart, lens,
7
+ // map, sankey) drive via .shift(refF, compF, lens, words) and
8
+ // .setfigure(...).setText(...).plot().
9
+ //
10
+ // Load order on the page (and in bundle.sh): D3 v4, then the d3-shifterator
11
+ // UMD bundle (which defines the global `shifterator`), then this file.
12
+ //
13
+ // One compatibility shim: the dashboard modules call
14
+ // setfigure(d3.select('#shift01'))
15
+ // passing a d3 SELECTION (the old hedotools.shifter API). d3-shifterator's
16
+ // setfigure expects a selector string or node (it runs d3.select() on its
17
+ // argument). Normalize a selection down to its node so both styles work.
18
+ hedotools.shifter = (function () {
19
+ var instance = shifterator.shifterator();
20
+ var setfigure = instance.setfigure;
21
+ instance.setfigure = function (_) {
22
+ var arg = (_ && typeof _.node === "function") ? _.node() : _;
23
+ setfigure.call(instance, arg);
24
+ return instance;
25
+ };
26
+ return instance;
27
+ })();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@andyreagan/hedotools",
3
- "version": "4.0.0",
4
- "description": "A collection of D3.js tools in use at hedonometer.org: word shifts, choropleth maps, sankey diagrams, a frequency lens, and bar charts. Version tracks the supported D3 major version (4.x = D3 v4).",
3
+ "version": "5.0.0",
4
+ "description": "A collection of D3.js tools in use at hedonometer.org: word shifts (via @andyreagan/d3-shifterator), choropleth maps, sankey diagrams, a frequency lens, and bar charts. Version tracks the supported D3 major version (5.x = D3 v5).",
5
5
  "author": "Andy Reagan",
6
6
  "license": "BSD-2-Clause",
7
7
  "scripts": {
@@ -32,9 +32,8 @@
32
32
  "vitest": "3.2.6"
33
33
  },
34
34
  "dependencies": {
35
- "d3": "^4.13.0",
36
- "d3-selection": "^1.3.0",
37
- "d3-selection-multi": "^1.0.1",
35
+ "@andyreagan/d3-shifterator": "^5.0.0",
36
+ "d3": "^5.16.0",
38
37
  "jquery": "^3.5.1",
39
38
  "topojson-client": "^3.1.0"
40
39
  }