@andyreagan/hedotools 3.0.0 → 4.5.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/README.md +4 -1
- package/bundle.sh +21 -10
- package/js/hedotools.barchart.js +15 -17
- package/js/hedotools.lens.js +43 -48
- package/js/hedotools.map.js +126 -142
- package/js/hedotools.sankey.js +36 -32
- package/js/hedotools.shifter.js +26 -4041
- package/package.json +17 -5
- package/js/hedotools.init.js +0 -59
- package/js/hedotools.shifter.v4.js +0 -3995
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andyreagan/hedotools",
|
|
3
|
-
"version": "
|
|
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 (
|
|
3
|
+
"version": "4.5.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 (4.x = D3 v4).",
|
|
5
5
|
"author": "Andy Reagan",
|
|
6
6
|
"license": "BSD-2-Clause",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"lint": "eslint js",
|
|
9
|
+
"build": "bash bundle.sh",
|
|
10
|
+
"test:unit": "vitest run --passWithNoTests",
|
|
11
|
+
"test:browser": "playwright test",
|
|
12
|
+
"test": "npm run lint && npm run test:unit && npm run test:browser"
|
|
13
|
+
},
|
|
7
14
|
"repository": {
|
|
8
15
|
"type": "git",
|
|
9
16
|
"url": "git+https://github.com/andyreagan/hedotools.git"
|
|
@@ -19,10 +26,15 @@
|
|
|
19
26
|
"bundle.sh",
|
|
20
27
|
"code-versions.md"
|
|
21
28
|
],
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@playwright/test": "1.60.0",
|
|
31
|
+
"eslint": "^10.5.0",
|
|
32
|
+
"vitest": "3.2.6"
|
|
33
|
+
},
|
|
22
34
|
"dependencies": {
|
|
35
|
+
"@andyreagan/d3-shifterator": "^4.1.0",
|
|
23
36
|
"d3": "^4.13.0",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"jquery": "^3.5.1"
|
|
37
|
+
"jquery": "^3.5.1",
|
|
38
|
+
"topojson-client": "^3.1.0"
|
|
27
39
|
}
|
|
28
40
|
}
|
package/js/hedotools.init.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// begin with some helper functions
|
|
2
|
-
// http://stackoverflow.com/a/1026087/3780153
|
|
3
|
-
function capitaliseFirstLetter(string)
|
|
4
|
-
{
|
|
5
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// this works really well, but it's deadly slow (working max 5 elements)
|
|
9
|
-
// and it's coupled to jquery
|
|
10
|
-
// http://stackoverflow.com/a/5047712/3780153
|
|
11
|
-
String.prototype.width = function(font) {
|
|
12
|
-
var f = font || '12px arial',
|
|
13
|
-
o = $('<div>' + this + '</div>')
|
|
14
|
-
.css({'position': 'absolute', 'float': 'left', 'white-space': 'nowrap', 'visibility': 'hidden', 'font': f})
|
|
15
|
-
.appendTo($('body')),
|
|
16
|
-
w = o.width();
|
|
17
|
-
o.remove();
|
|
18
|
-
return w;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
String.prototype.safe = function() {
|
|
22
|
-
var tmp = this.split("/")
|
|
23
|
-
tmp[tmp.length-1] = escape(tmp[tmp.length-1])
|
|
24
|
-
return tmp.join("/");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// yup
|
|
28
|
-
// http://stackoverflow.com/questions/3883342/add-commas-to-a-number-in-jquery
|
|
29
|
-
function commaSeparateNumber(val){
|
|
30
|
-
while (/(\d+)(\d{3})/.test(val.toString())){
|
|
31
|
-
val = val.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');
|
|
32
|
-
}
|
|
33
|
-
return val;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function splitWidth(s,w) {
|
|
37
|
-
// s is the string
|
|
38
|
-
// w is the width that we want to split it to
|
|
39
|
-
var t = s.split(" ");
|
|
40
|
-
var n = [t[0]];
|
|
41
|
-
var i = 1;
|
|
42
|
-
var j = 0;
|
|
43
|
-
while (i<t.length) {
|
|
44
|
-
if ((n[j]+t[i]).width() < w) {
|
|
45
|
-
n[j] += " "+t[i]
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
j++;
|
|
49
|
-
n.push(t[i]);
|
|
50
|
-
}
|
|
51
|
-
i++;
|
|
52
|
-
}
|
|
53
|
-
return n;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// look away
|
|
57
|
-
var intStr0 = ["zero","one","two","three","four","five","six","seven","eight","nine","then"];
|
|
58
|
-
var intStr = intStr0.slice(1,100);
|
|
59
|
-
|