@internetarchive/histogram-date-range 1.2.1 → 1.2.2-alpha-webdev7377.1
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/.editorconfig +29 -29
- package/.eslintrc.js +14 -14
- package/.github/workflows/ci.yml +30 -30
- package/LICENSE +661 -661
- package/README.md +113 -113
- package/demo/index.css +22 -22
- package/demo/index.html +159 -159
- package/dist/demo/js/app-root.d.ts +19 -19
- package/dist/demo/js/app-root.js +46 -46
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/histogram-date-range.d.ts +170 -159
- package/dist/src/histogram-date-range.js +868 -846
- package/dist/src/histogram-date-range.js.map +1 -1
- package/dist/test/histogram-date-range.test.d.ts +1 -1
- package/dist/test/histogram-date-range.test.js +488 -488
- package/dist/test/histogram-date-range.test.js.map +1 -1
- package/docs/demo/index.css +22 -22
- package/docs/demo/index.html +159 -159
- package/docs/dist/src/histogram-date-range.js +21 -7
- package/index.ts +1 -1
- package/package.json +85 -85
- package/snowpack.config.js +10 -10
- package/src/histogram-date-range.ts +936 -914
- package/test/histogram-date-range.test.ts +684 -684
- package/tsconfig.json +21 -21
- package/web-dev-server.config.mjs +28 -28
- package/web-test-runner.config.mjs +29 -29
- package/dist/demo/app-root.d.ts +0 -19
- package/dist/demo/app-root.js +0 -58
- package/dist/demo/app-root.js.map +0 -1
- package/dist/docs/_snowpack/pkg/@internetarchive/ia-activity-indicator/ia-activity-indicator.d.ts +0 -1
- package/dist/docs/_snowpack/pkg/@internetarchive/ia-activity-indicator/ia-activity-indicator.js +0 -2
- package/dist/docs/_snowpack/pkg/@internetarchive/ia-activity-indicator/ia-activity-indicator.js.map +0 -1
|
@@ -106,7 +106,7 @@ export let HistogramDateRange = class extends LitElement {
|
|
|
106
106
|
this.removeListeners();
|
|
107
107
|
super.disconnectedCallback();
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
willUpdate(changedProps) {
|
|
110
110
|
if (changedProps.has("bins") || changedProps.has("minDate") || changedProps.has("maxDate") || changedProps.has("minSelectedDate") || changedProps.has("maxSelectedDate") || changedProps.has("width") || changedProps.has("height")) {
|
|
111
111
|
this.handleDataUpdate();
|
|
112
112
|
}
|
|
@@ -123,7 +123,13 @@ export let HistogramDateRange = class extends LitElement {
|
|
|
123
123
|
this._histData = this.calculateHistData();
|
|
124
124
|
this.minSelectedDate = this.minSelectedDate ? this.minSelectedDate : this.minDate;
|
|
125
125
|
this.maxSelectedDate = this.maxSelectedDate ? this.maxSelectedDate : this.maxDate;
|
|
126
|
-
|
|
126
|
+
}
|
|
127
|
+
roundToMonth(timestamp) {
|
|
128
|
+
const date = new Date(timestamp);
|
|
129
|
+
const [y, m, d] = [date.getFullYear(), date.getMonth(), date.getDate()];
|
|
130
|
+
if (d < 15)
|
|
131
|
+
return new Date(y, m, 1).getTime();
|
|
132
|
+
return new Date(y, m + 1, 1).getTime();
|
|
127
133
|
}
|
|
128
134
|
calculateHistData() {
|
|
129
135
|
const minValue = Math.min(...this.bins);
|
|
@@ -132,11 +138,13 @@ export let HistogramDateRange = class extends LitElement {
|
|
|
132
138
|
const valueScale = this.height / valueRange;
|
|
133
139
|
const dateScale = this.dateRangeMS / this._numBins;
|
|
134
140
|
return this.bins.map((v, i) => {
|
|
141
|
+
const binStartMS = this.roundToMonth(i * dateScale + this._minDateMS);
|
|
142
|
+
const binEndMS = this.roundToMonth((i + 1) * dateScale + this._minDateMS);
|
|
135
143
|
return {
|
|
136
144
|
value: v,
|
|
137
145
|
height: Math.floor(Math.log1p(v) * valueScale),
|
|
138
|
-
binStart:
|
|
139
|
-
binEnd:
|
|
146
|
+
binStart: this.formatDate(binStartMS, this.resolvedTooltipDateFormat),
|
|
147
|
+
binEnd: this.formatDate(binEndMS, this.resolvedTooltipDateFormat)
|
|
140
148
|
};
|
|
141
149
|
});
|
|
142
150
|
}
|
|
@@ -155,6 +163,9 @@ export let HistogramDateRange = class extends LitElement {
|
|
|
155
163
|
get histogramRightEdgeX() {
|
|
156
164
|
return this.width - this.sliderWidth;
|
|
157
165
|
}
|
|
166
|
+
get resolvedTooltipDateFormat() {
|
|
167
|
+
return this.tooltipDateFormat ?? this.dateFormat ?? DATE_FORMAT;
|
|
168
|
+
}
|
|
158
169
|
get loading() {
|
|
159
170
|
return this._isLoading;
|
|
160
171
|
}
|
|
@@ -431,7 +442,7 @@ export let HistogramDateRange = class extends LitElement {
|
|
|
431
442
|
return bar;
|
|
432
443
|
});
|
|
433
444
|
}
|
|
434
|
-
formatDate(dateMS) {
|
|
445
|
+
formatDate(dateMS, format = this.dateFormat) {
|
|
435
446
|
if (Number.isNaN(dateMS)) {
|
|
436
447
|
return "";
|
|
437
448
|
}
|
|
@@ -439,7 +450,7 @@ export let HistogramDateRange = class extends LitElement {
|
|
|
439
450
|
if (date.year() < 1e3) {
|
|
440
451
|
return String(date.year());
|
|
441
452
|
}
|
|
442
|
-
return date.format(
|
|
453
|
+
return date.format(format);
|
|
443
454
|
}
|
|
444
455
|
get minInputTemplate() {
|
|
445
456
|
return html`
|
|
@@ -676,6 +687,9 @@ __decorate([
|
|
|
676
687
|
__decorate([
|
|
677
688
|
property({type: String})
|
|
678
689
|
], HistogramDateRange.prototype, "dateFormat", 2);
|
|
690
|
+
__decorate([
|
|
691
|
+
property({type: String})
|
|
692
|
+
], HistogramDateRange.prototype, "tooltipDateFormat", 2);
|
|
679
693
|
__decorate([
|
|
680
694
|
property({type: String})
|
|
681
695
|
], HistogramDateRange.prototype, "missingDataMessage", 2);
|
|
@@ -689,7 +703,7 @@ __decorate([
|
|
|
689
703
|
property({type: Boolean})
|
|
690
704
|
], HistogramDateRange.prototype, "disabled", 2);
|
|
691
705
|
__decorate([
|
|
692
|
-
property({type:
|
|
706
|
+
property({type: Array})
|
|
693
707
|
], HistogramDateRange.prototype, "bins", 2);
|
|
694
708
|
__decorate([
|
|
695
709
|
property({type: Boolean})
|
package/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { HistogramDateRange } from './src/histogram-date-range';
|
|
1
|
+
export { HistogramDateRange } from './src/histogram-date-range';
|
package/package.json
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@internetarchive/histogram-date-range",
|
|
3
|
-
"version": "1.2.1",
|
|
4
|
-
"description": "Internet Archive histogram date range picker",
|
|
5
|
-
"license": "AGPL-3.0-only",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
|
-
"publishConfig": {
|
|
10
|
-
"access": "public"
|
|
11
|
-
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
14
|
-
"build": "snowpack build && touch docs/.nojekyll",
|
|
15
|
-
"prepublish": "tsc",
|
|
16
|
-
"prepare": "npm run build",
|
|
17
|
-
"lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
18
|
-
"format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
19
|
-
"test": "tsc && wtr --coverage",
|
|
20
|
-
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
|
|
21
|
-
},
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@internetarchive/ia-activity-indicator": "^0.0.6",
|
|
24
|
-
"dayjs": "^1.11.13",
|
|
25
|
-
"lit": "^2.8.0"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@open-wc/eslint-config": "^7.0.0",
|
|
29
|
-
"@open-wc/testing": "^3.0.3",
|
|
30
|
-
"@types/mocha": "^10.0.10",
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
32
|
-
"@typescript-eslint/parser": "^5.10.0",
|
|
33
|
-
"@web/dev-server": "^0.1.29",
|
|
34
|
-
"@web/test-runner": "^0.19.0",
|
|
35
|
-
"concurrently": "^7.0.0",
|
|
36
|
-
"eslint": "^8.7.0",
|
|
37
|
-
"eslint-config-prettier": "^8.3.0",
|
|
38
|
-
"husky": "^4.3.8",
|
|
39
|
-
"lint-staged": "^12.2.2",
|
|
40
|
-
"lit-html": "^2.1.1",
|
|
41
|
-
"prettier": "^2.5.1",
|
|
42
|
-
"snowpack": "^3.8.8",
|
|
43
|
-
"tslib": "^2.3.1",
|
|
44
|
-
"typescript": "^4.5"
|
|
45
|
-
},
|
|
46
|
-
"eslintConfig": {
|
|
47
|
-
"parser": "@typescript-eslint/parser",
|
|
48
|
-
"extends": [
|
|
49
|
-
"@open-wc/eslint-config",
|
|
50
|
-
"eslint-config-prettier"
|
|
51
|
-
],
|
|
52
|
-
"plugins": [
|
|
53
|
-
"@typescript-eslint"
|
|
54
|
-
],
|
|
55
|
-
"rules": {
|
|
56
|
-
"no-unused-vars": "off",
|
|
57
|
-
"@typescript-eslint/no-unused-vars": [
|
|
58
|
-
"error"
|
|
59
|
-
],
|
|
60
|
-
"import/no-unresolved": "off",
|
|
61
|
-
"import/extensions": [
|
|
62
|
-
"error",
|
|
63
|
-
"always",
|
|
64
|
-
{
|
|
65
|
-
"ignorePackages": true
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"prettier": {
|
|
71
|
-
"singleQuote": true,
|
|
72
|
-
"arrowParens": "avoid"
|
|
73
|
-
},
|
|
74
|
-
"husky": {
|
|
75
|
-
"hooks": {
|
|
76
|
-
"pre-commit": "lint-staged"
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
"lint-staged": {
|
|
80
|
-
"*.ts": [
|
|
81
|
-
"eslint --fix",
|
|
82
|
-
"prettier --write"
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@internetarchive/histogram-date-range",
|
|
3
|
+
"version": "1.2.2-alpha-webdev7377.1",
|
|
4
|
+
"description": "Internet Archive histogram date range picker",
|
|
5
|
+
"license": "AGPL-3.0-only",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
14
|
+
"build": "snowpack build && touch docs/.nojekyll",
|
|
15
|
+
"prepublish": "tsc",
|
|
16
|
+
"prepare": "npm run build",
|
|
17
|
+
"lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
18
|
+
"format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
19
|
+
"test": "tsc && wtr --coverage",
|
|
20
|
+
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@internetarchive/ia-activity-indicator": "^0.0.6",
|
|
24
|
+
"dayjs": "^1.11.13",
|
|
25
|
+
"lit": "^2.8.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@open-wc/eslint-config": "^7.0.0",
|
|
29
|
+
"@open-wc/testing": "^3.0.3",
|
|
30
|
+
"@types/mocha": "^10.0.10",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
32
|
+
"@typescript-eslint/parser": "^5.10.0",
|
|
33
|
+
"@web/dev-server": "^0.1.29",
|
|
34
|
+
"@web/test-runner": "^0.19.0",
|
|
35
|
+
"concurrently": "^7.0.0",
|
|
36
|
+
"eslint": "^8.7.0",
|
|
37
|
+
"eslint-config-prettier": "^8.3.0",
|
|
38
|
+
"husky": "^4.3.8",
|
|
39
|
+
"lint-staged": "^12.2.2",
|
|
40
|
+
"lit-html": "^2.1.1",
|
|
41
|
+
"prettier": "^2.5.1",
|
|
42
|
+
"snowpack": "^3.8.8",
|
|
43
|
+
"tslib": "^2.3.1",
|
|
44
|
+
"typescript": "^4.5"
|
|
45
|
+
},
|
|
46
|
+
"eslintConfig": {
|
|
47
|
+
"parser": "@typescript-eslint/parser",
|
|
48
|
+
"extends": [
|
|
49
|
+
"@open-wc/eslint-config",
|
|
50
|
+
"eslint-config-prettier"
|
|
51
|
+
],
|
|
52
|
+
"plugins": [
|
|
53
|
+
"@typescript-eslint"
|
|
54
|
+
],
|
|
55
|
+
"rules": {
|
|
56
|
+
"no-unused-vars": "off",
|
|
57
|
+
"@typescript-eslint/no-unused-vars": [
|
|
58
|
+
"error"
|
|
59
|
+
],
|
|
60
|
+
"import/no-unresolved": "off",
|
|
61
|
+
"import/extensions": [
|
|
62
|
+
"error",
|
|
63
|
+
"always",
|
|
64
|
+
{
|
|
65
|
+
"ignorePackages": true
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"prettier": {
|
|
71
|
+
"singleQuote": true,
|
|
72
|
+
"arrowParens": "avoid"
|
|
73
|
+
},
|
|
74
|
+
"husky": {
|
|
75
|
+
"hooks": {
|
|
76
|
+
"pre-commit": "lint-staged"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"lint-staged": {
|
|
80
|
+
"*.ts": [
|
|
81
|
+
"eslint --fix",
|
|
82
|
+
"prettier --write"
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
}
|
package/snowpack.config.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
buildOptions: {
|
|
3
|
-
out: 'docs',
|
|
4
|
-
},
|
|
5
|
-
mount: {
|
|
6
|
-
'demo/js': { url: '/dist/demo/js' },
|
|
7
|
-
demo: { url: '/demo' },
|
|
8
|
-
src: { url: '/dist/src' },
|
|
9
|
-
},
|
|
10
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
buildOptions: {
|
|
3
|
+
out: 'docs',
|
|
4
|
+
},
|
|
5
|
+
mount: {
|
|
6
|
+
'demo/js': { url: '/dist/demo/js' },
|
|
7
|
+
demo: { url: '/demo' },
|
|
8
|
+
src: { url: '/dist/src' },
|
|
9
|
+
},
|
|
10
|
+
};
|