@internetarchive/histogram-date-range 1.3.0 → 1.3.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/dist/index.js.map +1 -1
- package/dist/src/dayjs/fix-first-century-years.d.ts +2 -0
- package/dist/src/dayjs/fix-first-century-years.js +25 -0
- package/dist/src/dayjs/fix-first-century-years.js.map +1 -0
- package/dist/src/dayjs/fix-two-digit-dates.d.ts +2 -0
- package/dist/src/dayjs/fix-two-digit-dates.js +25 -0
- package/dist/src/dayjs/fix-two-digit-dates.js.map +1 -0
- package/dist/src/histogram-date-range.js +29 -13
- package/dist/src/histogram-date-range.js.map +1 -1
- package/dist/src/plugins/fix-first-century-years.d.ts +23 -0
- package/dist/src/plugins/fix-first-century-years.js +43 -0
- package/dist/src/plugins/fix-first-century-years.js.map +1 -0
- package/dist/test/histogram-date-range.test.js +67 -3
- package/dist/test/histogram-date-range.test.js.map +1 -1
- package/docs/dist/src/histogram-date-range.js +12 -7
- package/docs/dist/src/plugins/fix-first-century-years.js +19 -0
- package/index.ts +4 -4
- package/package.json +1 -1
- package/src/histogram-date-range.ts +29 -15
- package/src/plugins/fix-first-century-years.ts +52 -0
- package/test/histogram-date-range.test.ts +77 -3
- package/types/dayjs.d.ts +10 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC","sourcesContent":["export {\
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC","sourcesContent":["export {\n HistogramDateRange,\n BinSnappingInterval,\n} from './src/histogram-date-range';\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function fixFirstCenturyYears(_, cls) {
|
|
2
|
+
const proto = cls.prototype;
|
|
3
|
+
const oldParse = proto.parse;
|
|
4
|
+
proto.parse = function (cfg) {
|
|
5
|
+
this.__lastDate = cfg === null || cfg === void 0 ? void 0 : cfg.date;
|
|
6
|
+
this.__lastFormat = cfg === null || cfg === void 0 ? void 0 : cfg.args[1];
|
|
7
|
+
oldParse.call(this, cfg);
|
|
8
|
+
const isProblemDateRange = this.$y >= 1900 && this.$y < 2000;
|
|
9
|
+
const isProblemStringFormat = typeof this.__lastFormat === 'string' &&
|
|
10
|
+
this.__lastFormat.includes('YYYY');
|
|
11
|
+
const isProblemArrayFormat = Array.isArray(this.__lastFormat) &&
|
|
12
|
+
typeof this.__lastFormat[1] === 'string' &&
|
|
13
|
+
this.__lastFormat[1].includes('YYYY');
|
|
14
|
+
const isProblemFormat = isProblemStringFormat || isProblemArrayFormat;
|
|
15
|
+
const missingParsedYear = typeof this.__lastDate === 'string' &&
|
|
16
|
+
!this.__lastDate.includes(`${this.$y}`);
|
|
17
|
+
if (isProblemDateRange && isProblemFormat && missingParsedYear) {
|
|
18
|
+
const old = new Date(this.$d);
|
|
19
|
+
this.$d.setFullYear(this.$y - 1900);
|
|
20
|
+
this.init();
|
|
21
|
+
console.log('fixed year', this.__lastDate, this.__lastFormat, old, this.$d);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=fix-first-century-years.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-first-century-years.js","sourceRoot":"","sources":["../../../src/dayjs/fix-first-century-years.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CAAC,CAAU,EAAE,GAAuB;IACtE,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;IAC7B,KAAK,CAAC,KAAK,GAAG,UAAU,GAAG;QACzB,IAAI,CAAC,UAAU,GAAG,GAAG,aAAH,GAAG,u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,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import dayjs from 'dayjs/esm';\n\nexport function fixFirstCenturyYears(_: unknown, cls: typeof dayjs.Dayjs) {\n const proto = cls.prototype;\n const oldParse = proto.parse;\n proto.parse = function (cfg) {\n this.__lastDate = cfg?.date;\n this.__lastFormat = cfg?.args[1];\n oldParse.call(this, cfg);\n\n const isProblemDateRange = this.$y >= 1900 && this.$y < 2000;\n const isProblemStringFormat =\n typeof this.__lastFormat === 'string' &&\n this.__lastFormat.includes('YYYY');\n const isProblemArrayFormat =\n Array.isArray(this.__lastFormat) &&\n typeof this.__lastFormat[1] === 'string' &&\n this.__lastFormat[1].includes('YYYY');\n const isProblemFormat = isProblemStringFormat || isProblemArrayFormat;\n const missingParsedYear = \n typeof this.__lastDate === 'string' &&\n !this.__lastDate.includes(`${this.$y}`);\n \n if (isProblemDateRange && isProblemFormat && missingParsedYear) {\n const old = new Date(this.$d);\n this.$d.setFullYear(this.$y - 1900);\n this.init();\n console.log('fixed year', this.__lastDate, this.__lastFormat, old, this.$d);\n }\n };\n}"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function fixFirstCenturyYears(_, cls) {
|
|
2
|
+
const proto = cls.prototype;
|
|
3
|
+
const oldParse = proto.parse;
|
|
4
|
+
proto.parse = function (cfg) {
|
|
5
|
+
this.__lastDate = cfg === null || cfg === void 0 ? void 0 : cfg.date;
|
|
6
|
+
this.__lastFormat = cfg === null || cfg === void 0 ? void 0 : cfg.args[1];
|
|
7
|
+
oldParse.call(this, cfg);
|
|
8
|
+
const isProblemDateRange = this.$y >= 1900 && this.$y < 2000;
|
|
9
|
+
const isProblemStringFormat = typeof this.__lastFormat === 'string' &&
|
|
10
|
+
this.__lastFormat.includes('YYYY');
|
|
11
|
+
const isProblemArrayFormat = Array.isArray(this.__lastFormat) &&
|
|
12
|
+
typeof this.__lastFormat[1] === 'string' &&
|
|
13
|
+
this.__lastFormat[1].includes('YYYY');
|
|
14
|
+
const isProblemFormat = isProblemStringFormat || isProblemArrayFormat;
|
|
15
|
+
const missingParsedYear = typeof this.__lastDate === 'string' &&
|
|
16
|
+
!this.__lastDate.includes(`${this.$y}`);
|
|
17
|
+
if (isProblemDateRange && isProblemFormat && missingParsedYear) {
|
|
18
|
+
const old = new Date(this.$d);
|
|
19
|
+
this.$d.setFullYear(this.$y - 1900);
|
|
20
|
+
this.init();
|
|
21
|
+
console.log('fixed year', this.__lastDate, this.__lastFormat, old, this.$d);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=fix-two-digit-dates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-two-digit-dates.js","sourceRoot":"","sources":["../../../src/dayjs/fix-two-digit-dates.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CAAC,CAAU,EAAE,GAAuB;IACtE,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;IAC7B,KAAK,CAAC,KAAK,GAAG,UAAU,GAAG;QACzB,IAAI,CAAC,UAAU,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QACjC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAEzB,MAAM,kBAAkB,GAAG,IAAI,CAAC,EAAE,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;QAC7D,MAAM,qBAAqB,GACzB,OAAO,IAAI,CAAC,YAAY,KAAK,QAAQ;YACrC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,oBAAoB,GACxB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;YAChC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,QAAQ;YACxC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACxC,MAAM,eAAe,GAAG,qBAAqB,IAAI,oBAAoB,CAAC;QACtE,MAAM,iBAAiB,GACrB,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ;YACnC,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAE1C,IAAI,kBAAkB,IAAI,eAAe,IAAI,iBAAiB,EAAE;YAC9D,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC9B,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;SAC7E;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import dayjs from 'dayjs/esm';\n\nexport function fixFirstCenturyYears(_: unknown, cls: typeof dayjs.Dayjs) {\n const proto = cls.prototype;\n const oldParse = proto.parse;\n proto.parse = function (cfg) {\n this.__lastDate = cfg?.date;\n this.__lastFormat = cfg?.args[1];\n oldParse.call(this, cfg);\n\n const isProblemDateRange = this.$y >= 1900 && this.$y < 2000;\n const isProblemStringFormat =\n typeof this.__lastFormat === 'string' &&\n this.__lastFormat.includes('YYYY');\n const isProblemArrayFormat =\n Array.isArray(this.__lastFormat) &&\n typeof this.__lastFormat[1] === 'string' &&\n this.__lastFormat[1].includes('YYYY');\n const isProblemFormat = isProblemStringFormat || isProblemArrayFormat;\n const missingParsedYear = \n typeof this.__lastDate === 'string' &&\n !this.__lastDate.includes(`${this.$y}`);\n \n if (isProblemDateRange && isProblemFormat && missingParsedYear) {\n const old = new Date(this.$d);\n this.$d.setFullYear(this.$y - 1900);\n this.init();\n console.log('fixed year', this.__lastDate, this.__lastFormat, old, this.$d);\n }\n };\n}"]}
|
|
@@ -2,11 +2,13 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import '@internetarchive/ia-activity-indicator';
|
|
3
3
|
import dayjs from 'dayjs/esm';
|
|
4
4
|
import customParseFormat from 'dayjs/esm/plugin/customParseFormat';
|
|
5
|
+
import fixFirstCenturyYears from './plugins/fix-first-century-years';
|
|
5
6
|
import { css, html, LitElement, nothing, svg, } from 'lit';
|
|
6
7
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
7
8
|
import { live } from 'lit/directives/live.js';
|
|
8
9
|
import { classMap } from 'lit/directives/class-map.js';
|
|
9
10
|
dayjs.extend(customParseFormat);
|
|
11
|
+
dayjs.extend(fixFirstCenturyYears);
|
|
10
12
|
// these values can be overridden via the component's HTML (camelCased) attributes
|
|
11
13
|
const WIDTH = 180;
|
|
12
14
|
const HEIGHT = 40;
|
|
@@ -178,11 +180,16 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
178
180
|
* while dates past the 15th are rounded up.
|
|
179
181
|
*/
|
|
180
182
|
snapToMonth(timestamp) {
|
|
181
|
-
const d =
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
const d = dayjs(timestamp);
|
|
184
|
+
const monthsToAdd = d.date() < 16 ? 0 : 1;
|
|
185
|
+
const snapped = d
|
|
186
|
+
.add(monthsToAdd, 'month')
|
|
187
|
+
.date(1)
|
|
188
|
+
.hour(0)
|
|
189
|
+
.minute(0)
|
|
190
|
+
.second(0)
|
|
191
|
+
.millisecond(0); // First millisecond of the month
|
|
192
|
+
return snapped.valueOf();
|
|
186
193
|
}
|
|
187
194
|
/**
|
|
188
195
|
* Rounds the given timestamp to the (approximate) nearest start of a year,
|
|
@@ -190,11 +197,17 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
190
197
|
* July or later are rounded up.
|
|
191
198
|
*/
|
|
192
199
|
snapToYear(timestamp) {
|
|
193
|
-
const d =
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
200
|
+
const d = dayjs(timestamp);
|
|
201
|
+
const yearsToAdd = d.month() < 6 ? 0 : 1;
|
|
202
|
+
const snapped = d
|
|
203
|
+
.add(yearsToAdd, 'year')
|
|
204
|
+
.month(0)
|
|
205
|
+
.date(1)
|
|
206
|
+
.hour(0)
|
|
207
|
+
.minute(0)
|
|
208
|
+
.second(0)
|
|
209
|
+
.millisecond(0); // First millisecond of the year
|
|
210
|
+
return snapped.valueOf();
|
|
198
211
|
}
|
|
199
212
|
/**
|
|
200
213
|
* Rounds the given timestamp according to the `binSnapping` property.
|
|
@@ -685,9 +698,12 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
685
698
|
}
|
|
686
699
|
const date = dayjs(dateMS);
|
|
687
700
|
if (date.year() < 1000) {
|
|
688
|
-
// years before 1000 don't play well with dayjs custom formatting, so
|
|
689
|
-
//
|
|
690
|
-
|
|
701
|
+
// years before 1000 don't play well with dayjs custom formatting, so work around dayjs
|
|
702
|
+
// by setting the year to a sentinel value and then replacing it instead.
|
|
703
|
+
// this is a bit hacky but it does the trick for essentially all reasonable cases
|
|
704
|
+
// until such time as we replace dayjs.
|
|
705
|
+
const tmpDate = date.year(199999);
|
|
706
|
+
return tmpDate.format(format).replace(/199999/g, date.year().toString());
|
|
691
707
|
}
|
|
692
708
|
return date.format(format);
|
|
693
709
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"histogram-date-range.js","sourceRoot":"","sources":["../../src/histogram-date-range.ts"],"names":[],"mappings":";AAAA,OAAO,wCAAwC,CAAC;AAChD,OAAO,KAAK,MAAM,WAAW,CAAC;AAC9B,OAAO,iBAAi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,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gDAAqB;AAElB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8DAA4B;AAa5B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA2C;AAG7D;IAAR,KAAK,EAAE;0DAA4B;AAC3B;IAAR,KAAK,EAAE;2DAA0C;AACzC;IAAR,KAAK,EAAE;2DAAiC;AAChC;IAAR,KAAK,EAAE;8DAAqC;AACpC;IAAR,KAAK,EAAE;uDAA6B;AAC5B;IAAR,KAAK,EAAE;sDAA4B;AAiNR;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAE1B;AAO4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAE3B;AAQW;IAAX,QAAQ,EAAE;yDAEV;AAsBW;IAAX,QAAQ,EAAE;yDAEV;AApSU,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CA4+B9B;SA5+BY,kBAAkB","sourcesContent":["import '@internetarchive/ia-activity-indicator';\r\nimport dayjs from 'dayjs/esm';\r\nimport customParseFormat from 'dayjs/esm/plugin/customParseFormat';\r\nimport {\r\n css,\r\n html,\r\n LitElement,\r\n nothing,\r\n PropertyValues,\r\n svg,\r\n SVGTemplateResult,\r\n TemplateResult,\r\n} from 'lit';\r\nimport { customElement, property, state } from 'lit/decorators.js';\r\nimport { live } from 'lit/directives/live.js';\r\nimport { classMap } from 'lit/directives/class-map.js';\r\n\r\ndayjs.extend(customParseFormat);\r\n\r\n// these values can be overridden via the component's HTML (camelCased) attributes\r\nconst WIDTH = 180;\r\nconst HEIGHT = 40;\r\nconst SLIDER_WIDTH = 10;\r\nconst TOOLTIP_WIDTH = 125;\r\nconst TOOLTIP_HEIGHT = 30;\r\nconst DATE_FORMAT = 'YYYY';\r\nconst MISSING_DATA = 'no data';\r\nconst UPDATE_DEBOUNCE_DELAY_MS = 0;\r\n\r\n// this constant is not set up to be overridden\r\nconst SLIDER_CORNER_SIZE = 4;\r\n\r\n// these CSS custom props can be overridden from the HTML that is invoking this component\r\nconst sliderColor = css`var(--histogramDateRangeSliderColor, #4B65FE)`;\r\nconst selectedRangeColor = css`var(--histogramDateRangeSelectedRangeColor, #DBE0FF)`;\r\nconst barIncludedFill = css`var(--histogramDateRangeBarIncludedFill, #2C2C2C)`;\r\nconst activityIndicatorColor = css`var(--histogramDateRangeActivityIndicator, #2C2C2C)`;\r\nconst barExcludedFill = css`var(--histogramDateRangeBarExcludedFill, #CCCCCC)`;\r\nconst inputRowMargin = css`var(--histogramDateRangeInputRowMargin, 0)`;\r\nconst inputBorder = css`var(--histogramDateRangeInputBorder, 0.5px solid #2C2C2C)`;\r\nconst inputWidth = css`var(--histogramDateRangeInputWidth, 35px)`;\r\nconst inputFontSize = css`var(--histogramDateRangeInputFontSize, 1.2rem)`;\r\nconst inputFontFamily = css`var(--histogramDateRangeInputFontFamily, sans-serif)`;\r\nconst tooltipBackgroundColor = css`var(--histogramDateRangeTooltipBackgroundColor, #2C2C2C)`;\r\nconst tooltipTextColor = css`var(--histogramDateRangeTooltipTextColor, #FFFFFF)`;\r\nconst tooltipFontSize = css`var(--histogramDateRangeTooltipFontSize, 1.1rem)`;\r\nconst tooltipFontFamily = css`var(--histogramDateRangeTooltipFontFamily, sans-serif)`;\r\n\r\ntype SliderId = 'slider-min' | 'slider-max';\r\n\r\nexport type BinSnappingInterval = 'none' | 'month' | 'year';\r\n\r\ninterface HistogramItem {\r\n value: number;\r\n height: number;\r\n binStart: string;\r\n binEnd: string;\r\n tooltip: string;\r\n}\r\n\r\ninterface BarDataset extends DOMStringMap {\r\n numItems: string;\r\n binStart: string;\r\n binEnd: string;\r\n}\r\n\r\n@customElement('histogram-date-range')\r\nexport class HistogramDateRange extends LitElement {\r\n /* eslint-disable lines-between-class-members */\r\n\r\n // public reactive properties that can be set via HTML attributes\r\n @property({ type: Number }) width = WIDTH;\r\n @property({ type: Number }) height = HEIGHT;\r\n @property({ type: Number }) sliderWidth = SLIDER_WIDTH;\r\n @property({ type: Number }) tooltipWidth = TOOLTIP_WIDTH;\r\n @property({ type: Number }) tooltipHeight = TOOLTIP_HEIGHT;\r\n @property({ type: Number }) updateDelay = UPDATE_DEBOUNCE_DELAY_MS;\r\n @property({ type: String }) dateFormat = DATE_FORMAT;\r\n @property({ type: String }) missingDataMessage = MISSING_DATA;\r\n @property({ type: String }) minDate = '';\r\n @property({ type: String }) maxDate = '';\r\n @property({ type: Boolean }) disabled = false;\r\n @property({ type: Array }) bins: number[] = [];\r\n /** If true, update events will not be canceled by the date inputs receiving focus */\r\n @property({ type: Boolean }) updateWhileFocused = false;\r\n\r\n /**\r\n * What interval bins should be snapped to for determining their time ranges.\r\n * - `none` (default): Bins should each represent an identical duration of time,\r\n * without regard for the actual dates represented.\r\n * - `month`: Bins should each represent one or more full, non-overlapping months.\r\n * The bin ranges will be \"snapped\" to the nearest month boundaries, which can\r\n * result in bins that represent different amounts of time, particularly if the\r\n * provided bins do not evenly divide the provided date range, or if the months\r\n * represented are of different lengths.\r\n * - `year`: Same as `month`, but snapping to year boundaries instead of months.\r\n */\r\n @property({ type: String }) binSnapping: BinSnappingInterval = 'none';\r\n\r\n // internal reactive properties not exposed as attributes\r\n @state() private _tooltipOffset = 0;\r\n @state() private _tooltipContent?: TemplateResult;\r\n @state() private _tooltipVisible = false;\r\n @state() private _tooltipDateFormat?: string;\r\n @state() private _isDragging = false;\r\n @state() private _isLoading = false;\r\n\r\n // non-reactive properties (changes don't auto-trigger re-rendering)\r\n private _minSelectedDate = '';\r\n private _maxSelectedDate = '';\r\n private _minDateMS = 0;\r\n private _maxDateMS = 0;\r\n private _dragOffset = 0;\r\n private _histWidth = 0;\r\n private _binWidth = 0;\r\n private _currentSlider?: SVGRectElement;\r\n private _histData: HistogramItem[] = [];\r\n private _emitUpdatedEventTimer?: ReturnType<typeof setTimeout>;\r\n private _previousDateRange = '';\r\n\r\n /* eslint-enable lines-between-class-members */\r\n\r\n disconnectedCallback(): void {\r\n this.removeListeners();\r\n super.disconnectedCallback();\r\n }\r\n\r\n willUpdate(changedProps: PropertyValues): void {\r\n // check for changes that would affect bin data calculations\r\n if (\r\n changedProps.has('bins') ||\r\n changedProps.has('minDate') ||\r\n changedProps.has('maxDate') ||\r\n changedProps.has('minSelectedDate') ||\r\n changedProps.has('maxSelectedDate') ||\r\n changedProps.has('width') ||\r\n changedProps.has('height') ||\r\n changedProps.has('binSnapping')\r\n ) {\r\n this.handleDataUpdate();\r\n }\r\n }\r\n\r\n /**\r\n * Set private properties that depend on the attribute bin data\r\n *\r\n * We're caching these values and not using getters to avoid recalculating all\r\n * of the hist data every time the user drags a slider or hovers over a bar\r\n * creating a tooltip.\r\n */\r\n private handleDataUpdate(): void {\r\n if (!this.hasBinData) {\r\n return;\r\n }\r\n this._histWidth = this.width - this.sliderWidth * 2;\r\n\r\n this._minDateMS = this.snapTimestamp(this.getMSFromString(this.minDate));\r\n // NB: The max date string, converted as-is to ms, represents the *start* of the\r\n // final date interval; we want the *end*, so we add any snap interval/offset.\r\n this._maxDateMS =\r\n this.snapTimestamp(\r\n this.getMSFromString(this.maxDate) + this.snapInterval\r\n ) + this.snapEndOffset;\r\n\r\n this._binWidth = this._histWidth / this._numBins;\r\n this._previousDateRange = this.currentDateRangeString;\r\n this._histData = this.calculateHistData();\r\n this.minSelectedDate = this.minSelectedDate\r\n ? this.minSelectedDate\r\n : this.minDate;\r\n this.maxSelectedDate = this.maxSelectedDate\r\n ? this.maxSelectedDate\r\n : this.maxDate;\r\n }\r\n\r\n /**\r\n * Rounds the given timestamp to the next full second.\r\n */\r\n private snapToNextSecond(timestamp: number): number {\r\n return Math.ceil(timestamp / 1000) * 1000;\r\n }\r\n\r\n /**\r\n * Rounds the given timestamp to the (approximate) nearest start of a month,\r\n * such that dates up to and including the 15th of the month are rounded down,\r\n * while dates past the 15th are rounded up.\r\n */\r\n private snapToMonth(timestamp: number): number {\r\n const d = new Date(timestamp);\r\n const [year, month, day] = [d.getFullYear(), d.getMonth(), d.getDate()];\r\n\r\n return day < 16 // Obviously only an approximation, but good enough for snapping\r\n ? new Date(year, month, 1).getTime()\r\n : new Date(year, month + 1, 1).getTime();\r\n }\r\n\r\n /**\r\n * Rounds the given timestamp to the (approximate) nearest start of a year,\r\n * such that dates up to the end of June are rounded down, while dates in\r\n * July or later are rounded up.\r\n */\r\n private snapToYear(timestamp: number): number {\r\n const d = new Date(timestamp);\r\n const [year, month] = [d.getFullYear(), d.getMonth()];\r\n\r\n return month < 6 // NB: months are 0-indexed, so 6 = July\r\n ? new Date(year, 0, 1).getTime()\r\n : new Date(year + 1, 0, 1).getTime();\r\n }\r\n\r\n /**\r\n * Rounds the given timestamp according to the `binSnapping` property.\r\n * Default is simply to snap to the nearest full second.\r\n */\r\n private snapTimestamp(timestamp: number): number {\r\n switch (this.binSnapping) {\r\n case 'year':\r\n return this.snapToYear(timestamp);\r\n case 'month':\r\n return this.snapToMonth(timestamp);\r\n case 'none':\r\n default:\r\n // We still align it to second boundaries to resolve minor discrepancies\r\n return this.snapToNextSecond(timestamp);\r\n }\r\n }\r\n\r\n private calculateHistData(): HistogramItem[] {\r\n const { bins, height, dateRangeMS, _numBins, _minDateMS } = this;\r\n const minValue = Math.min(...this.bins);\r\n const maxValue = Math.max(...this.bins);\r\n // if there is no difference between the min and max values, use a range of\r\n // 1 because log scaling will fail if the range is 0\r\n const valueRange = minValue === maxValue ? 1 : Math.log1p(maxValue);\r\n const valueScale = height / valueRange;\r\n const dateScale = dateRangeMS / _numBins;\r\n\r\n return bins.map((v: number, i: number) => {\r\n const binStartMS = this.snapTimestamp(i * dateScale + _minDateMS);\r\n const binStart = this.formatDate(binStartMS);\r\n\r\n const binEndMS =\r\n this.snapTimestamp((i + 1) * dateScale + _minDateMS) +\r\n this.snapEndOffset;\r\n const binEnd = this.formatDate(binEndMS);\r\n\r\n const tooltipStart = this.formatDate(binStartMS, this.tooltipDateFormat);\r\n const tooltipEnd = this.formatDate(binEndMS, this.tooltipDateFormat);\r\n // If start/end are the same, just render a single value\r\n const tooltip =\r\n tooltipStart === tooltipEnd\r\n ? tooltipStart\r\n : `${tooltipStart} - ${tooltipEnd}`;\r\n\r\n return {\r\n value: v,\r\n // use log scaling for the height of the bar to prevent tall bars from\r\n // making the smaller ones too small to see\r\n height: Math.floor(Math.log1p(v) * valueScale),\r\n binStart,\r\n binEnd,\r\n tooltip,\r\n };\r\n });\r\n }\r\n\r\n private get hasBinData(): boolean {\r\n return this._numBins > 0;\r\n }\r\n\r\n private get _numBins(): number {\r\n if (!this.bins || !this.bins.length) {\r\n return 0;\r\n }\r\n return this.bins.length;\r\n }\r\n\r\n private get histogramLeftEdgeX(): number {\r\n return this.sliderWidth;\r\n }\r\n\r\n private get histogramRightEdgeX(): number {\r\n return this.width - this.sliderWidth;\r\n }\r\n\r\n /**\r\n * Approximate size in ms of the interval to which bins are snapped.\r\n */\r\n private get snapInterval(): number {\r\n const yearMS = 31_536_000_000; // A 365-day approximation of ms in a year\r\n const monthMS = 2_592_000_000; // A 30-day approximation of ms in a month\r\n switch (this.binSnapping) {\r\n case 'year':\r\n return yearMS;\r\n case 'month':\r\n return monthMS;\r\n case 'none':\r\n default:\r\n return 0;\r\n }\r\n }\r\n\r\n /**\r\n * Offset added to the end of each bin to ensure disjoint intervals,\r\n * depending on whether snapping is enabled and there are multiple bins.\r\n */\r\n private get snapEndOffset(): number {\r\n return this.binSnapping !== 'none' && this._numBins > 1 ? -1 : 0;\r\n }\r\n\r\n /**\r\n * Optional date format to use for tooltips only.\r\n * Falls back to `dateFormat` if not provided.\r\n */\r\n @property({ type: String }) get tooltipDateFormat(): string {\r\n return this._tooltipDateFormat ?? this.dateFormat;\r\n }\r\n\r\n set tooltipDateFormat(value: string) {\r\n this._tooltipDateFormat = value;\r\n }\r\n\r\n /** component's loading (and disabled) state */\r\n @property({ type: Boolean }) get loading(): boolean {\r\n return this._isLoading;\r\n }\r\n\r\n set loading(value: boolean) {\r\n this.disabled = value;\r\n this._isLoading = value;\r\n }\r\n\r\n /** formatted minimum date of selected date range */\r\n @property() get minSelectedDate(): string {\r\n return this.formatDate(this.getMSFromString(this._minSelectedDate));\r\n }\r\n\r\n /** updates minSelectedDate if new date is valid */\r\n set minSelectedDate(rawDate: string) {\r\n if (!this._minSelectedDate) {\r\n // because the values needed to calculate valid max/min values are not\r\n // available during the lit init when it's populating properties from\r\n // attributes, fall back to just the raw date if nothing is already set\r\n this._minSelectedDate = rawDate;\r\n return;\r\n }\r\n const proposedDateMS = this.getMSFromString(rawDate);\r\n const isValidDate = !Number.isNaN(proposedDateMS);\r\n const isNotTooRecent =\r\n proposedDateMS <= this.getMSFromString(this.maxSelectedDate);\r\n if (isValidDate && isNotTooRecent) {\r\n this._minSelectedDate = this.formatDate(proposedDateMS);\r\n }\r\n this.requestUpdate();\r\n }\r\n\r\n /** formatted maximum date of selected date range */\r\n @property() get maxSelectedDate(): string {\r\n return this.formatDate(this.getMSFromString(this._maxSelectedDate));\r\n }\r\n\r\n /** updates maxSelectedDate if new date is valid */\r\n set maxSelectedDate(rawDate: string) {\r\n if (!this._maxSelectedDate) {\r\n // because the values needed to calculate valid max/min values are not\r\n // available during the lit init when it's populating properties from\r\n // attributes, fall back to just the raw date if nothing is already set\r\n this._maxSelectedDate = rawDate;\r\n return;\r\n }\r\n const proposedDateMS = this.getMSFromString(rawDate);\r\n const isValidDate = !Number.isNaN(proposedDateMS);\r\n const isNotTooOld =\r\n proposedDateMS >= this.getMSFromString(this.minSelectedDate);\r\n if (isValidDate && isNotTooOld) {\r\n this._maxSelectedDate = this.formatDate(proposedDateMS);\r\n }\r\n this.requestUpdate();\r\n }\r\n\r\n /** horizontal position of min date slider */\r\n get minSliderX(): number {\r\n const x = this.translateDateToPosition(this.minSelectedDate);\r\n return this.validMinSliderX(x);\r\n }\r\n\r\n /** horizontal position of max date slider */\r\n get maxSliderX(): number {\r\n const maxSelectedDateMS = this.snapTimestamp(\r\n this.getMSFromString(this.maxSelectedDate) + this.snapInterval\r\n );\r\n const x = this.translateDateToPosition(this.formatDate(maxSelectedDateMS));\r\n return this.validMaxSliderX(x);\r\n }\r\n\r\n private get dateRangeMS(): number {\r\n return this._maxDateMS - this._minDateMS;\r\n }\r\n\r\n private showTooltip(e: PointerEvent): void {\r\n if (this._isDragging || this.disabled) {\r\n return;\r\n }\r\n const target = e.currentTarget as SVGRectElement;\r\n const x = target.x.baseVal.value + this.sliderWidth / 2;\r\n const dataset = target.dataset as BarDataset;\r\n const itemsText = `item${dataset.numItems !== '1' ? 's' : ''}`;\r\n const formattedNumItems = Number(dataset.numItems).toLocaleString();\r\n\r\n this._tooltipOffset =\r\n x + (this._binWidth - this.sliderWidth - this.tooltipWidth) / 2;\r\n\r\n this._tooltipContent = html`\r\n ${formattedNumItems} ${itemsText}<br />\r\n ${dataset.tooltip}\r\n `;\r\n this._tooltipVisible = true;\r\n }\r\n\r\n private hideTooltip(): void {\r\n this._tooltipContent = undefined;\r\n this._tooltipVisible = false;\r\n }\r\n\r\n // use arrow functions (rather than standard JS class instance methods) so\r\n // that `this` is bound to the histogramDateRange object and not the event\r\n // target. for more info see\r\n // https://lit-element.polymer-project.org/guide/events#using-this-in-event-listeners\r\n private drag = (e: PointerEvent): void => {\r\n // prevent selecting text or other ranges while dragging, especially in Safari\r\n e.preventDefault();\r\n if (this.disabled) {\r\n return;\r\n }\r\n this.setDragOffset(e);\r\n this._isDragging = true;\r\n this.addListeners();\r\n this.cancelPendingUpdateEvent();\r\n };\r\n\r\n private drop = (): void => {\r\n if (this._isDragging) {\r\n this.removeListeners();\r\n this.beginEmitUpdateProcess();\r\n }\r\n this._isDragging = false;\r\n };\r\n\r\n /**\r\n * Adjust the date range based on slider movement\r\n *\r\n * @param e PointerEvent from the slider being moved\r\n */\r\n private move = (e: PointerEvent): void => {\r\n const histogramClientX = this.getBoundingClientRect().x;\r\n const newX = e.clientX - histogramClientX - this._dragOffset;\r\n const slider = this._currentSlider as SVGRectElement;\r\n if ((slider.id as SliderId) === 'slider-min') {\r\n this.minSelectedDate = this.translatePositionToDate(\r\n this.validMinSliderX(newX)\r\n );\r\n } else {\r\n this.maxSelectedDate = this.translatePositionToDate(\r\n this.validMaxSliderX(newX)\r\n );\r\n if (this.getMSFromString(this.maxSelectedDate) > this._maxDateMS) {\r\n this.maxSelectedDate = this.maxDate;\r\n }\r\n }\r\n };\r\n\r\n /**\r\n * Constrain a proposed value for the minimum (left) slider\r\n *\r\n * If the value is less than the leftmost valid position, then set it to the\r\n * left edge of the histogram (ie the slider width). If the value is greater\r\n * than the rightmost valid position (the position of the max slider), then\r\n * set it to the position of the max slider\r\n */\r\n private validMinSliderX(newX: number): number {\r\n // allow the left slider to go right only to the right slider, even if the\r\n // max selected date is out of range\r\n const rightLimit = Math.min(\r\n this.translateDateToPosition(this.maxSelectedDate),\r\n this.histogramRightEdgeX\r\n );\r\n newX = this.clamp(newX, this.histogramLeftEdgeX, rightLimit);\r\n const isInvalid =\r\n Number.isNaN(newX) || rightLimit < this.histogramLeftEdgeX;\r\n return isInvalid ? this.histogramLeftEdgeX : newX;\r\n }\r\n\r\n /**\r\n * Constrain a proposed value for the maximum (right) slider\r\n *\r\n * If the value is greater than the rightmost valid position, then set it to\r\n * the right edge of the histogram (ie histogram width - slider width). If the\r\n * value is less than the leftmost valid position (the position of the min\r\n * slider), then set it to the position of the min slider\r\n */\r\n private validMaxSliderX(newX: number): number {\r\n // allow the right slider to go left only to the left slider, even if the\r\n // min selected date is out of range\r\n const leftLimit = Math.max(\r\n this.histogramLeftEdgeX,\r\n this.translateDateToPosition(this.minSelectedDate)\r\n );\r\n newX = this.clamp(newX, leftLimit, this.histogramRightEdgeX);\r\n const isInvalid =\r\n Number.isNaN(newX) || leftLimit > this.histogramRightEdgeX;\r\n return isInvalid ? this.histogramRightEdgeX : newX;\r\n }\r\n\r\n private addListeners(): void {\r\n window.addEventListener('pointermove', this.move);\r\n window.addEventListener('pointerup', this.drop);\r\n window.addEventListener('pointercancel', this.drop);\r\n }\r\n\r\n private removeListeners(): void {\r\n window.removeEventListener('pointermove', this.move);\r\n window.removeEventListener('pointerup', this.drop);\r\n window.removeEventListener('pointercancel', this.drop);\r\n }\r\n\r\n /**\r\n * start a timer to emit an update event. this timer can be canceled (and the\r\n * event not emitted) if user drags a slider or focuses a date input within\r\n * the update delay\r\n */\r\n private beginEmitUpdateProcess(): void {\r\n this.cancelPendingUpdateEvent();\r\n this._emitUpdatedEventTimer = setTimeout(() => {\r\n if (this.currentDateRangeString === this._previousDateRange) {\r\n // don't emit duplicate event if no change since last emitted event\r\n return;\r\n }\r\n this._previousDateRange = this.currentDateRangeString;\r\n const options = {\r\n detail: {\r\n minDate: this.minSelectedDate,\r\n maxDate: this.maxSelectedDate,\r\n },\r\n bubbles: true,\r\n composed: true,\r\n };\r\n this.dispatchEvent(new CustomEvent('histogramDateRangeUpdated', options));\r\n }, this.updateDelay);\r\n }\r\n\r\n private cancelPendingUpdateEvent(): void {\r\n if (this._emitUpdatedEventTimer === undefined) {\r\n return;\r\n }\r\n clearTimeout(this._emitUpdatedEventTimer);\r\n this._emitUpdatedEventTimer = undefined;\r\n }\r\n\r\n /**\r\n * find position of pointer in relation to the current slider\r\n */\r\n private setDragOffset(e: PointerEvent): void {\r\n this._currentSlider = e.currentTarget as SVGRectElement;\r\n const sliderX =\r\n (this._currentSlider.id as SliderId) === 'slider-min'\r\n ? this.minSliderX\r\n : this.maxSliderX;\r\n const histogramClientX = this.getBoundingClientRect().x;\r\n this._dragOffset = e.clientX - histogramClientX - sliderX;\r\n }\r\n\r\n /**\r\n * @param x horizontal position of slider\r\n * @returns string representation of date\r\n */\r\n private translatePositionToDate(x: number): string {\r\n // Snap to the nearest second, fixing the case where input like 1/1/2010\r\n // would get translated to 12/31/2009 due to slight discrepancies from\r\n // pixel boundaries and floating point error.\r\n const milliseconds = this.snapToNextSecond(\r\n ((x - this.sliderWidth) * this.dateRangeMS) / this._histWidth\r\n );\r\n return this.formatDate(this._minDateMS + milliseconds);\r\n }\r\n\r\n /**\r\n * Returns slider x-position corresponding to given date\r\n *\r\n * @param date\r\n * @returns x-position of slider\r\n */\r\n private translateDateToPosition(date: string): number {\r\n const milliseconds = this.getMSFromString(date);\r\n return (\r\n this.sliderWidth +\r\n ((milliseconds - this._minDateMS) * this._histWidth) / this.dateRangeMS\r\n );\r\n }\r\n\r\n /** ensure that the returned value is between minValue and maxValue */\r\n private clamp(x: number, minValue: number, maxValue: number): number {\r\n return Math.min(Math.max(x, minValue), maxValue);\r\n }\r\n\r\n private handleInputFocus(): void {\r\n if (!this.updateWhileFocused) {\r\n this.cancelPendingUpdateEvent();\r\n }\r\n }\r\n\r\n private handleMinDateInput(e: Event): void {\r\n const target = e.currentTarget as HTMLInputElement;\r\n if (target.value !== this.minSelectedDate) {\r\n this.minSelectedDate = target.value;\r\n this.beginEmitUpdateProcess();\r\n }\r\n }\r\n\r\n private handleMaxDateInput(e: Event): void {\r\n const target = e.currentTarget as HTMLInputElement;\r\n if (target.value !== this.maxSelectedDate) {\r\n this.maxSelectedDate = target.value;\r\n this.beginEmitUpdateProcess();\r\n }\r\n }\r\n\r\n private handleKeyUp(e: KeyboardEvent): void {\r\n if (e.key === 'Enter') {\r\n const target = e.currentTarget as HTMLInputElement;\r\n target.blur();\r\n if (target.id === 'date-min') {\r\n this.handleMinDateInput(e);\r\n } else if (target.id === 'date-max') {\r\n this.handleMaxDateInput(e);\r\n }\r\n }\r\n }\r\n\r\n private get currentDateRangeString(): string {\r\n return `${this.minSelectedDate}:${this.maxSelectedDate}`;\r\n }\r\n\r\n private getMSFromString(date: unknown): number {\r\n // It's possible that `date` is not a string in certain situations.\r\n // For instance if you use LitElement bindings and the date is `2000`,\r\n // it will be treated as a number instead of a string. This just makes sure\r\n // we're dealing with a string.\r\n const stringified = typeof date === 'string' ? date : String(date);\r\n const digitGroupCount = (stringified.split(/(\\d+)/).length - 1) / 2;\r\n if (digitGroupCount === 1) {\r\n // if there's just a single set of digits, assume it's a year\r\n const dateObj = new Date(0, 0); // start at January 1, 1900\r\n dateObj.setFullYear(Number(stringified)); // override year\r\n return dateObj.getTime(); // get time in milliseconds\r\n }\r\n return dayjs(stringified, [this.dateFormat, DATE_FORMAT]).valueOf();\r\n }\r\n\r\n /**\r\n * expand or narrow the selected range by moving the slider nearest the\r\n * clicked bar to the outer edge of the clicked bar\r\n *\r\n * @param e Event click event from a histogram bar\r\n */\r\n private handleBarClick(e: Event): void {\r\n const dataset = (e.currentTarget as SVGRectElement).dataset as BarDataset;\r\n // use the midpoint of the width of the clicked bar to determine which is\r\n // the nearest slider\r\n const clickPosition =\r\n (this.getMSFromString(dataset.binStart) +\r\n this.getMSFromString(dataset.binEnd)) /\r\n 2;\r\n const distanceFromMinSlider = Math.abs(\r\n clickPosition - this.getMSFromString(this.minSelectedDate)\r\n );\r\n const distanceFromMaxSlider = Math.abs(\r\n clickPosition - this.getMSFromString(this.maxSelectedDate)\r\n );\r\n // update the selected range by moving the nearer slider\r\n if (distanceFromMinSlider < distanceFromMaxSlider) {\r\n this.minSelectedDate = dataset.binStart;\r\n } else {\r\n this.maxSelectedDate = dataset.binEnd;\r\n }\r\n this.beginEmitUpdateProcess();\r\n }\r\n\r\n private get minSliderTemplate(): SVGTemplateResult {\r\n // width/height in pixels of curved part of the sliders (like\r\n // border-radius); used as part of a SVG quadratic curve. see\r\n // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#curve_commands\r\n const cs = SLIDER_CORNER_SIZE;\r\n\r\n const sliderShape = `\r\n M${this.minSliderX},0\r\n h-${this.sliderWidth - cs}\r\n q-${cs},0 -${cs},${cs}\r\n v${this.height - cs * 2}\r\n q0,${cs} ${cs},${cs}\r\n h${this.sliderWidth - cs}\r\n `;\r\n return this.generateSliderSVG(this.minSliderX, 'slider-min', sliderShape);\r\n }\r\n\r\n private get maxSliderTemplate(): SVGTemplateResult {\r\n const cs = SLIDER_CORNER_SIZE;\r\n const sliderShape = `\r\n M${this.maxSliderX},0\r\n h${this.sliderWidth - cs}\r\n q${cs},0 ${cs},${cs}\r\n v${this.height - cs * 2}\r\n q0,${cs} -${cs},${cs}\r\n h-${this.sliderWidth - cs}\r\n `;\r\n return this.generateSliderSVG(this.maxSliderX, 'slider-max', sliderShape);\r\n }\r\n\r\n private generateSliderSVG(\r\n sliderPositionX: number,\r\n id: SliderId,\r\n sliderShape: string\r\n ): SVGTemplateResult {\r\n // whether the curved part of the slider is facing towards the left (1), ie\r\n // minimum, or facing towards the right (-1), ie maximum\r\n const k = id === 'slider-min' ? 1 : -1;\r\n\r\n const sliderClasses = classMap({\r\n slider: true,\r\n draggable: !this.disabled,\r\n dragging: this._isDragging,\r\n });\r\n\r\n return svg`\r\n <svg\r\n id=${id}\r\n class=${sliderClasses}\r\n @pointerdown=${this.drag}\r\n >\r\n <path d=\"${sliderShape} z\" fill=\"${sliderColor}\" />\r\n <rect\r\n x=\"${\r\n sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k\r\n }\"\r\n y=\"${this.height / 3}\"\r\n width=\"1\"\r\n height=\"${this.height / 3}\"\r\n fill=\"white\"\r\n />\r\n <rect\r\n x=\"${\r\n sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k\r\n }\"\r\n y=\"${this.height / 3}\"\r\n width=\"1\"\r\n height=\"${this.height / 3}\"\r\n fill=\"white\"\r\n />\r\n </svg>\r\n `;\r\n }\r\n\r\n get selectedRangeTemplate(): SVGTemplateResult {\r\n return svg`\r\n <rect\r\n x=\"${this.minSliderX}\"\r\n y=\"0\"\r\n width=\"${this.maxSliderX - this.minSliderX}\"\r\n height=\"${this.height}\"\r\n fill=\"${selectedRangeColor}\"\r\n />`;\r\n }\r\n\r\n get histogramTemplate(): SVGTemplateResult[] {\r\n const xScale = this._histWidth / this._numBins;\r\n const barWidth = xScale - 1;\r\n let x = this.sliderWidth; // start at the left edge of the histogram\r\n\r\n return this._histData.map(data => {\r\n const { minSelectedDate, maxSelectedDate } = this;\r\n const barHeight = data.height;\r\n\r\n const binIsBeforeMin = this.isBefore(data.binEnd, minSelectedDate);\r\n const binIsAfterMax = this.isAfter(data.binStart, maxSelectedDate);\r\n const barFill =\r\n binIsBeforeMin || binIsAfterMax ? barExcludedFill : barIncludedFill;\r\n\r\n // the stroke-dasharray style below creates a transparent border around the\r\n // right edge of the bar, which prevents user from encountering a gap\r\n // between adjacent bars (eg when viewing the tooltips or when trying to\r\n // extend the range by clicking on a bar)\r\n const barStyle = `stroke-dasharray: 0 ${barWidth} ${barHeight} ${barWidth} 0 ${barHeight}`;\r\n\r\n const bar = svg`\r\n <rect\r\n class=\"bar\"\r\n style=${barStyle}\r\n x=${x}\r\n y=${this.height - barHeight}\r\n width=${barWidth}\r\n height=${barHeight}\r\n @pointerenter=${this.showTooltip}\r\n @pointerleave=${this.hideTooltip}\r\n @click=${this.handleBarClick}\r\n fill=${barFill}\r\n data-num-items=${data.value}\r\n data-bin-start=${data.binStart}\r\n data-bin-end=${data.binEnd}\r\n data-tooltip=${data.tooltip}\r\n />`;\r\n x += xScale;\r\n return bar;\r\n });\r\n }\r\n\r\n /** Whether the first arg represents a date strictly before the second arg */\r\n private isBefore(date1: string, date2: string): boolean {\r\n const date1MS = this.getMSFromString(date1);\r\n const date2MS = this.getMSFromString(date2);\r\n return date1MS < date2MS;\r\n }\r\n\r\n /** Whether the first arg represents a date strictly after the second arg */\r\n private isAfter(date1: string, date2: string): boolean {\r\n const date1MS = this.getMSFromString(date1);\r\n const date2MS = this.getMSFromString(date2);\r\n return date1MS > date2MS;\r\n }\r\n\r\n private formatDate(dateMS: number, format: string = this.dateFormat): string {\r\n if (Number.isNaN(dateMS)) {\r\n return '';\r\n }\r\n const date = dayjs(dateMS);\r\n if (date.year() < 1000) {\r\n // years before 1000 don't play well with dayjs custom formatting, so fall\r\n // back to displaying only the year\r\n return String(date.year());\r\n }\r\n return date.format(format);\r\n }\r\n\r\n /**\r\n * NOTE: we are relying on the lit `live` directive in the template to\r\n * ensure that the change to minSelectedDate is noticed and the input value\r\n * gets properly re-rendered. see\r\n * https://lit.dev/docs/templates/directives/#live\r\n */\r\n get minInputTemplate(): TemplateResult {\r\n return html`\r\n <input\r\n id=\"date-min\"\r\n placeholder=${this.dateFormat}\r\n type=\"text\"\r\n @focus=${this.handleInputFocus}\r\n @blur=${this.handleMinDateInput}\r\n @keyup=${this.handleKeyUp}\r\n .value=${live(this.minSelectedDate)}\r\n ?disabled=${this.disabled}\r\n />\r\n `;\r\n }\r\n\r\n get maxInputTemplate(): TemplateResult {\r\n return html`\r\n <input\r\n id=\"date-max\"\r\n placeholder=${this.dateFormat}\r\n type=\"text\"\r\n @focus=${this.handleInputFocus}\r\n @blur=${this.handleMaxDateInput}\r\n @keyup=${this.handleKeyUp}\r\n .value=${live(this.maxSelectedDate)}\r\n ?disabled=${this.disabled}\r\n />\r\n `;\r\n }\r\n\r\n get minLabelTemplate(): TemplateResult {\r\n return html`<label for=\"date-min\" class=\"sr-only\">Minimum date:</label>`;\r\n }\r\n\r\n get maxLabelTemplate(): TemplateResult {\r\n return html`<label for=\"date-max\" class=\"sr-only\">Maximum date:</label>`;\r\n }\r\n\r\n get tooltipTemplate(): TemplateResult {\r\n return html`\r\n <style>\r\n #tooltip {\r\n width: ${this.tooltipWidth}px;\r\n height: ${this.tooltipHeight}px;\r\n top: ${-9 - this.tooltipHeight}px;\r\n left: ${this._tooltipOffset}px;\r\n display: ${this._tooltipVisible ? 'block' : 'none'};\r\n }\r\n #tooltip:after {\r\n left: ${this.tooltipWidth / 2}px;\r\n }\r\n </style>\r\n <div id=\"tooltip\">${this._tooltipContent}</div>\r\n `;\r\n }\r\n\r\n private get noDataTemplate(): TemplateResult {\r\n return html`\r\n <div class=\"missing-data-message\">${this.missingDataMessage}</div>\r\n `;\r\n }\r\n\r\n private get activityIndicatorTemplate(): TemplateResult | typeof nothing {\r\n if (!this.loading) {\r\n return nothing;\r\n }\r\n return html`\r\n <ia-activity-indicator mode=\"processing\"> </ia-activity-indicator>\r\n `;\r\n }\r\n\r\n static styles = css`\r\n .missing-data-message {\r\n text-align: center;\r\n }\r\n #container {\r\n margin: 0;\r\n touch-action: none;\r\n position: relative;\r\n }\r\n .disabled {\r\n opacity: 0.3;\r\n }\r\n ia-activity-indicator {\r\n position: absolute;\r\n left: calc(50% - 10px);\r\n top: 10px;\r\n width: 20px;\r\n height: 20px;\r\n --activityIndicatorLoadingDotColor: rgba(0, 0, 0, 0);\r\n --activityIndicatorLoadingRingColor: ${activityIndicatorColor};\r\n }\r\n\r\n /* prevent selection from interfering with tooltip, especially on mobile */\r\n /* https://stackoverflow.com/a/4407335/1163042 */\r\n .noselect {\r\n -webkit-touch-callout: none; /* iOS Safari */\r\n -webkit-user-select: none; /* Safari */\r\n -moz-user-select: none; /* Old versions of Firefox */\r\n -ms-user-select: none; /* Internet Explorer/Edge */\r\n user-select: none; /* current Chrome, Edge, Opera and Firefox */\r\n }\r\n .bar {\r\n /* create a transparent border around the hist bars to prevent \"gaps\" and\r\n flickering when moving around between bars. this also helps with handling\r\n clicks on the bars, preventing users from being able to click in between\r\n bars */\r\n stroke: rgba(0, 0, 0, 0);\r\n /* ensure transparent stroke wide enough to cover gap between bars */\r\n stroke-width: 2px;\r\n }\r\n .bar:hover {\r\n /* highlight currently hovered bar */\r\n fill-opacity: 0.7;\r\n }\r\n .disabled .bar:hover {\r\n /* ensure no visual hover interaction when disabled */\r\n fill-opacity: 1;\r\n }\r\n /****** histogram ********/\r\n #tooltip {\r\n position: absolute;\r\n background: ${tooltipBackgroundColor};\r\n color: ${tooltipTextColor};\r\n text-align: center;\r\n border-radius: 3px;\r\n padding: 2px;\r\n font-size: ${tooltipFontSize};\r\n font-family: ${tooltipFontFamily};\r\n touch-action: none;\r\n pointer-events: none;\r\n }\r\n #tooltip:after {\r\n content: '';\r\n position: absolute;\r\n margin-left: -5px;\r\n top: 100%;\r\n /* arrow */\r\n border: 5px solid ${tooltipTextColor};\r\n border-color: ${tooltipBackgroundColor} transparent transparent\r\n transparent;\r\n }\r\n /****** slider ********/\r\n .slider {\r\n shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */\r\n }\r\n .draggable:hover {\r\n cursor: grab;\r\n }\r\n .dragging {\r\n cursor: grabbing !important;\r\n }\r\n /****** inputs ********/\r\n #inputs {\r\n display: flex;\r\n justify-content: center;\r\n margin: ${inputRowMargin};\r\n }\r\n #inputs .dash {\r\n position: relative;\r\n bottom: -1px;\r\n align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */\r\n }\r\n input {\r\n width: ${inputWidth};\r\n margin: 0 3px;\r\n border: ${inputBorder};\r\n border-radius: 2px !important;\r\n text-align: center;\r\n font-size: ${inputFontSize};\r\n font-family: ${inputFontFamily};\r\n }\r\n .sr-only {\r\n position: absolute !important;\r\n width: 1px !important;\r\n height: 1px !important;\r\n margin: 0 !important;\r\n padding: 0 !important;\r\n border: 0 !important;\r\n overflow: hidden !important;\r\n white-space: nowrap !important;\r\n clip: rect(1px, 1px, 1px, 1px) !important;\r\n -webkit-clip-path: inset(50%) !important;\r\n clip-path: inset(50%) !important;\r\n }\r\n `;\r\n\r\n render(): TemplateResult {\r\n if (!this.hasBinData) {\r\n return this.noDataTemplate;\r\n }\r\n return html`\r\n <div\r\n id=\"container\"\r\n class=\"\r\n noselect\r\n ${this._isDragging ? 'dragging' : ''}\r\n \"\r\n style=\"width: ${this.width}px\"\r\n >\r\n ${this.activityIndicatorTemplate} ${this.tooltipTemplate}\r\n <div\r\n class=\"inner-container\r\n ${this.disabled ? 'disabled' : ''}\"\r\n >\r\n <svg\r\n width=\"${this.width}\"\r\n height=\"${this.height}\"\r\n @pointerleave=\"${this.drop}\"\r\n >\r\n ${this.selectedRangeTemplate}\r\n <svg id=\"histogram\">${this.histogramTemplate}</svg>\r\n ${this.minSliderTemplate} ${this.maxSliderTemplate}\r\n </svg>\r\n <div id=\"inputs\">\r\n ${this.minLabelTemplate} ${this.minInputTemplate}\r\n <div class=\"dash\">-</div>\r\n ${this.maxLabelTemplate} ${this.maxInputTemplate}\r\n <slot name=\"inputs-right-side\"></slot>\r\n </div>\r\n </div>\r\n </div>\r\n `;\r\n }\r\n}\r\n\r\n// help TypeScript provide strong typing when interacting with DOM APIs\r\n// https://stackoverflow.com/questions/65148695/lit-element-typescript-project-global-interface-declaration-necessary\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n 'histogram-date-range': HistogramDateRange;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"histogram-date-range.js","sourceRoot":"","sources":["../../src/histogram-date-range.ts"],"names":[],"mappings":";AAAA,OAAO,wCAAwC,CAAC;AAChD,OAAO,KAAK,MAAM,WAAW,CAAC;AAC9B,OAAO,iBAAiB,MAAM,oCAAoC,CAAC;AACnE,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,EAEP,GAAG,GAGJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAChC,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAEnC,kFAAkF;AAClF,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,MAAM,MAAM,GAAG,EAAE,CAAC;AAClB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC,+CAA+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B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAE3B;AAQW;IAAX,QAAQ,EAAE;yDAEV;AAsBW;IAAX,QAAQ,EAAE;yDAEV;AA7SU,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAw/B9B;SAx/BY,kBAAkB","sourcesContent":["import '@internetarchive/ia-activity-indicator';\r\nimport dayjs from 'dayjs/esm';\r\nimport customParseFormat from 'dayjs/esm/plugin/customParseFormat';\r\nimport fixFirstCenturyYears from './plugins/fix-first-century-years';\r\nimport {\r\n css,\r\n html,\r\n LitElement,\r\n nothing,\r\n PropertyValues,\r\n svg,\r\n SVGTemplateResult,\r\n TemplateResult,\r\n} from 'lit';\r\nimport { customElement, property, state } from 'lit/decorators.js';\r\nimport { live } from 'lit/directives/live.js';\r\nimport { classMap } from 'lit/directives/class-map.js';\r\n\r\ndayjs.extend(customParseFormat);\r\ndayjs.extend(fixFirstCenturyYears);\r\n\r\n// these values can be overridden via the component's HTML (camelCased) attributes\r\nconst WIDTH = 180;\r\nconst HEIGHT = 40;\r\nconst SLIDER_WIDTH = 10;\r\nconst TOOLTIP_WIDTH = 125;\r\nconst TOOLTIP_HEIGHT = 30;\r\nconst DATE_FORMAT = 'YYYY';\r\nconst MISSING_DATA = 'no data';\r\nconst UPDATE_DEBOUNCE_DELAY_MS = 0;\r\n\r\n// this constant is not set up to be overridden\r\nconst SLIDER_CORNER_SIZE = 4;\r\n\r\n// these CSS custom props can be overridden from the HTML that is invoking this component\r\nconst sliderColor = css`var(--histogramDateRangeSliderColor, #4B65FE)`;\r\nconst selectedRangeColor = css`var(--histogramDateRangeSelectedRangeColor, #DBE0FF)`;\r\nconst barIncludedFill = css`var(--histogramDateRangeBarIncludedFill, #2C2C2C)`;\r\nconst activityIndicatorColor = css`var(--histogramDateRangeActivityIndicator, #2C2C2C)`;\r\nconst barExcludedFill = css`var(--histogramDateRangeBarExcludedFill, #CCCCCC)`;\r\nconst inputRowMargin = css`var(--histogramDateRangeInputRowMargin, 0)`;\r\nconst inputBorder = css`var(--histogramDateRangeInputBorder, 0.5px solid #2C2C2C)`;\r\nconst inputWidth = css`var(--histogramDateRangeInputWidth, 35px)`;\r\nconst inputFontSize = css`var(--histogramDateRangeInputFontSize, 1.2rem)`;\r\nconst inputFontFamily = css`var(--histogramDateRangeInputFontFamily, sans-serif)`;\r\nconst tooltipBackgroundColor = css`var(--histogramDateRangeTooltipBackgroundColor, #2C2C2C)`;\r\nconst tooltipTextColor = css`var(--histogramDateRangeTooltipTextColor, #FFFFFF)`;\r\nconst tooltipFontSize = css`var(--histogramDateRangeTooltipFontSize, 1.1rem)`;\r\nconst tooltipFontFamily = css`var(--histogramDateRangeTooltipFontFamily, sans-serif)`;\r\n\r\ntype SliderId = 'slider-min' | 'slider-max';\r\n\r\nexport type BinSnappingInterval = 'none' | 'month' | 'year';\r\n\r\ninterface HistogramItem {\r\n value: number;\r\n height: number;\r\n binStart: string;\r\n binEnd: string;\r\n tooltip: string;\r\n}\r\n\r\ninterface BarDataset extends DOMStringMap {\r\n numItems: string;\r\n binStart: string;\r\n binEnd: string;\r\n}\r\n\r\n@customElement('histogram-date-range')\r\nexport class HistogramDateRange extends LitElement {\r\n /* eslint-disable lines-between-class-members */\r\n\r\n // public reactive properties that can be set via HTML attributes\r\n @property({ type: Number }) width = WIDTH;\r\n @property({ type: Number }) height = HEIGHT;\r\n @property({ type: Number }) sliderWidth = SLIDER_WIDTH;\r\n @property({ type: Number }) tooltipWidth = TOOLTIP_WIDTH;\r\n @property({ type: Number }) tooltipHeight = TOOLTIP_HEIGHT;\r\n @property({ type: Number }) updateDelay = UPDATE_DEBOUNCE_DELAY_MS;\r\n @property({ type: String }) dateFormat = DATE_FORMAT;\r\n @property({ type: String }) missingDataMessage = MISSING_DATA;\r\n @property({ type: String }) minDate = '';\r\n @property({ type: String }) maxDate = '';\r\n @property({ type: Boolean }) disabled = false;\r\n @property({ type: Array }) bins: number[] = [];\r\n /** If true, update events will not be canceled by the date inputs receiving focus */\r\n @property({ type: Boolean }) updateWhileFocused = false;\r\n\r\n /**\r\n * What interval bins should be snapped to for determining their time ranges.\r\n * - `none` (default): Bins should each represent an identical duration of time,\r\n * without regard for the actual dates represented.\r\n * - `month`: Bins should each represent one or more full, non-overlapping months.\r\n * The bin ranges will be \"snapped\" to the nearest month boundaries, which can\r\n * result in bins that represent different amounts of time, particularly if the\r\n * provided bins do not evenly divide the provided date range, or if the months\r\n * represented are of different lengths.\r\n * - `year`: Same as `month`, but snapping to year boundaries instead of months.\r\n */\r\n @property({ type: String }) binSnapping: BinSnappingInterval = 'none';\r\n\r\n // internal reactive properties not exposed as attributes\r\n @state() private _tooltipOffset = 0;\r\n @state() private _tooltipContent?: TemplateResult;\r\n @state() private _tooltipVisible = false;\r\n @state() private _tooltipDateFormat?: string;\r\n @state() private _isDragging = false;\r\n @state() private _isLoading = false;\r\n\r\n // non-reactive properties (changes don't auto-trigger re-rendering)\r\n private _minSelectedDate = '';\r\n private _maxSelectedDate = '';\r\n private _minDateMS = 0;\r\n private _maxDateMS = 0;\r\n private _dragOffset = 0;\r\n private _histWidth = 0;\r\n private _binWidth = 0;\r\n private _currentSlider?: SVGRectElement;\r\n private _histData: HistogramItem[] = [];\r\n private _emitUpdatedEventTimer?: ReturnType<typeof setTimeout>;\r\n private _previousDateRange = '';\r\n\r\n /* eslint-enable lines-between-class-members */\r\n\r\n disconnectedCallback(): void {\r\n this.removeListeners();\r\n super.disconnectedCallback();\r\n }\r\n\r\n willUpdate(changedProps: PropertyValues): void {\r\n // check for changes that would affect bin data calculations\r\n if (\r\n changedProps.has('bins') ||\r\n changedProps.has('minDate') ||\r\n changedProps.has('maxDate') ||\r\n changedProps.has('minSelectedDate') ||\r\n changedProps.has('maxSelectedDate') ||\r\n changedProps.has('width') ||\r\n changedProps.has('height') ||\r\n changedProps.has('binSnapping')\r\n ) {\r\n this.handleDataUpdate();\r\n }\r\n }\r\n\r\n /**\r\n * Set private properties that depend on the attribute bin data\r\n *\r\n * We're caching these values and not using getters to avoid recalculating all\r\n * of the hist data every time the user drags a slider or hovers over a bar\r\n * creating a tooltip.\r\n */\r\n private handleDataUpdate(): void {\r\n if (!this.hasBinData) {\r\n return;\r\n }\r\n this._histWidth = this.width - this.sliderWidth * 2;\r\n\r\n this._minDateMS = this.snapTimestamp(this.getMSFromString(this.minDate));\r\n // NB: The max date string, converted as-is to ms, represents the *start* of the\r\n // final date interval; we want the *end*, so we add any snap interval/offset.\r\n this._maxDateMS =\r\n this.snapTimestamp(\r\n this.getMSFromString(this.maxDate) + this.snapInterval\r\n ) + this.snapEndOffset;\r\n\r\n this._binWidth = this._histWidth / this._numBins;\r\n this._previousDateRange = this.currentDateRangeString;\r\n this._histData = this.calculateHistData();\r\n this.minSelectedDate = this.minSelectedDate\r\n ? this.minSelectedDate\r\n : this.minDate;\r\n this.maxSelectedDate = this.maxSelectedDate\r\n ? this.maxSelectedDate\r\n : this.maxDate;\r\n }\r\n\r\n /**\r\n * Rounds the given timestamp to the next full second.\r\n */\r\n private snapToNextSecond(timestamp: number): number {\r\n return Math.ceil(timestamp / 1000) * 1000;\r\n }\r\n\r\n /**\r\n * Rounds the given timestamp to the (approximate) nearest start of a month,\r\n * such that dates up to and including the 15th of the month are rounded down,\r\n * while dates past the 15th are rounded up.\r\n */\r\n private snapToMonth(timestamp: number): number {\r\n const d = dayjs(timestamp);\r\n const monthsToAdd = d.date() < 16 ? 0 : 1;\r\n const snapped = d\r\n .add(monthsToAdd, 'month')\r\n .date(1)\r\n .hour(0)\r\n .minute(0)\r\n .second(0)\r\n .millisecond(0); // First millisecond of the month\r\n return snapped.valueOf();\r\n }\r\n\r\n /**\r\n * Rounds the given timestamp to the (approximate) nearest start of a year,\r\n * such that dates up to the end of June are rounded down, while dates in\r\n * July or later are rounded up.\r\n */\r\n private snapToYear(timestamp: number): number {\r\n const d = dayjs(timestamp);\r\n const yearsToAdd = d.month() < 6 ? 0 : 1;\r\n const snapped = d\r\n .add(yearsToAdd, 'year')\r\n .month(0)\r\n .date(1)\r\n .hour(0)\r\n .minute(0)\r\n .second(0)\r\n .millisecond(0); // First millisecond of the year\r\n return snapped.valueOf();\r\n }\r\n\r\n /**\r\n * Rounds the given timestamp according to the `binSnapping` property.\r\n * Default is simply to snap to the nearest full second.\r\n */\r\n private snapTimestamp(timestamp: number): number {\r\n switch (this.binSnapping) {\r\n case 'year':\r\n return this.snapToYear(timestamp);\r\n case 'month':\r\n return this.snapToMonth(timestamp);\r\n case 'none':\r\n default:\r\n // We still align it to second boundaries to resolve minor discrepancies\r\n return this.snapToNextSecond(timestamp);\r\n }\r\n }\r\n\r\n private calculateHistData(): HistogramItem[] {\r\n const { bins, height, dateRangeMS, _numBins, _minDateMS } = this;\r\n const minValue = Math.min(...this.bins);\r\n const maxValue = Math.max(...this.bins);\r\n // if there is no difference between the min and max values, use a range of\r\n // 1 because log scaling will fail if the range is 0\r\n const valueRange = minValue === maxValue ? 1 : Math.log1p(maxValue);\r\n const valueScale = height / valueRange;\r\n const dateScale = dateRangeMS / _numBins;\r\n\r\n return bins.map((v: number, i: number) => {\r\n const binStartMS = this.snapTimestamp(i * dateScale + _minDateMS);\r\n const binStart = this.formatDate(binStartMS);\r\n\r\n const binEndMS =\r\n this.snapTimestamp((i + 1) * dateScale + _minDateMS) +\r\n this.snapEndOffset;\r\n const binEnd = this.formatDate(binEndMS);\r\n\r\n const tooltipStart = this.formatDate(binStartMS, this.tooltipDateFormat);\r\n const tooltipEnd = this.formatDate(binEndMS, this.tooltipDateFormat);\r\n // If start/end are the same, just render a single value\r\n const tooltip =\r\n tooltipStart === tooltipEnd\r\n ? tooltipStart\r\n : `${tooltipStart} - ${tooltipEnd}`;\r\n\r\n return {\r\n value: v,\r\n // use log scaling for the height of the bar to prevent tall bars from\r\n // making the smaller ones too small to see\r\n height: Math.floor(Math.log1p(v) * valueScale),\r\n binStart,\r\n binEnd,\r\n tooltip,\r\n };\r\n });\r\n }\r\n\r\n private get hasBinData(): boolean {\r\n return this._numBins > 0;\r\n }\r\n\r\n private get _numBins(): number {\r\n if (!this.bins || !this.bins.length) {\r\n return 0;\r\n }\r\n return this.bins.length;\r\n }\r\n\r\n private get histogramLeftEdgeX(): number {\r\n return this.sliderWidth;\r\n }\r\n\r\n private get histogramRightEdgeX(): number {\r\n return this.width - this.sliderWidth;\r\n }\r\n\r\n /**\r\n * Approximate size in ms of the interval to which bins are snapped.\r\n */\r\n private get snapInterval(): number {\r\n const yearMS = 31_536_000_000; // A 365-day approximation of ms in a year\r\n const monthMS = 2_592_000_000; // A 30-day approximation of ms in a month\r\n switch (this.binSnapping) {\r\n case 'year':\r\n return yearMS;\r\n case 'month':\r\n return monthMS;\r\n case 'none':\r\n default:\r\n return 0;\r\n }\r\n }\r\n\r\n /**\r\n * Offset added to the end of each bin to ensure disjoint intervals,\r\n * depending on whether snapping is enabled and there are multiple bins.\r\n */\r\n private get snapEndOffset(): number {\r\n return this.binSnapping !== 'none' && this._numBins > 1 ? -1 : 0;\r\n }\r\n\r\n /**\r\n * Optional date format to use for tooltips only.\r\n * Falls back to `dateFormat` if not provided.\r\n */\r\n @property({ type: String }) get tooltipDateFormat(): string {\r\n return this._tooltipDateFormat ?? this.dateFormat;\r\n }\r\n\r\n set tooltipDateFormat(value: string) {\r\n this._tooltipDateFormat = value;\r\n }\r\n\r\n /** component's loading (and disabled) state */\r\n @property({ type: Boolean }) get loading(): boolean {\r\n return this._isLoading;\r\n }\r\n\r\n set loading(value: boolean) {\r\n this.disabled = value;\r\n this._isLoading = value;\r\n }\r\n\r\n /** formatted minimum date of selected date range */\r\n @property() get minSelectedDate(): string {\r\n return this.formatDate(this.getMSFromString(this._minSelectedDate));\r\n }\r\n\r\n /** updates minSelectedDate if new date is valid */\r\n set minSelectedDate(rawDate: string) {\r\n if (!this._minSelectedDate) {\r\n // because the values needed to calculate valid max/min values are not\r\n // available during the lit init when it's populating properties from\r\n // attributes, fall back to just the raw date if nothing is already set\r\n this._minSelectedDate = rawDate;\r\n return;\r\n }\r\n const proposedDateMS = this.getMSFromString(rawDate);\r\n const isValidDate = !Number.isNaN(proposedDateMS);\r\n const isNotTooRecent =\r\n proposedDateMS <= this.getMSFromString(this.maxSelectedDate);\r\n if (isValidDate && isNotTooRecent) {\r\n this._minSelectedDate = this.formatDate(proposedDateMS);\r\n }\r\n this.requestUpdate();\r\n }\r\n\r\n /** formatted maximum date of selected date range */\r\n @property() get maxSelectedDate(): string {\r\n return this.formatDate(this.getMSFromString(this._maxSelectedDate));\r\n }\r\n\r\n /** updates maxSelectedDate if new date is valid */\r\n set maxSelectedDate(rawDate: string) {\r\n if (!this._maxSelectedDate) {\r\n // because the values needed to calculate valid max/min values are not\r\n // available during the lit init when it's populating properties from\r\n // attributes, fall back to just the raw date if nothing is already set\r\n this._maxSelectedDate = rawDate;\r\n return;\r\n }\r\n const proposedDateMS = this.getMSFromString(rawDate);\r\n const isValidDate = !Number.isNaN(proposedDateMS);\r\n const isNotTooOld =\r\n proposedDateMS >= this.getMSFromString(this.minSelectedDate);\r\n if (isValidDate && isNotTooOld) {\r\n this._maxSelectedDate = this.formatDate(proposedDateMS);\r\n }\r\n this.requestUpdate();\r\n }\r\n\r\n /** horizontal position of min date slider */\r\n get minSliderX(): number {\r\n const x = this.translateDateToPosition(this.minSelectedDate);\r\n return this.validMinSliderX(x);\r\n }\r\n\r\n /** horizontal position of max date slider */\r\n get maxSliderX(): number {\r\n const maxSelectedDateMS = this.snapTimestamp(\r\n this.getMSFromString(this.maxSelectedDate) + this.snapInterval\r\n );\r\n const x = this.translateDateToPosition(this.formatDate(maxSelectedDateMS));\r\n return this.validMaxSliderX(x);\r\n }\r\n\r\n private get dateRangeMS(): number {\r\n return this._maxDateMS - this._minDateMS;\r\n }\r\n\r\n private showTooltip(e: PointerEvent): void {\r\n if (this._isDragging || this.disabled) {\r\n return;\r\n }\r\n const target = e.currentTarget as SVGRectElement;\r\n const x = target.x.baseVal.value + this.sliderWidth / 2;\r\n const dataset = target.dataset as BarDataset;\r\n const itemsText = `item${dataset.numItems !== '1' ? 's' : ''}`;\r\n const formattedNumItems = Number(dataset.numItems).toLocaleString();\r\n\r\n this._tooltipOffset =\r\n x + (this._binWidth - this.sliderWidth - this.tooltipWidth) / 2;\r\n\r\n this._tooltipContent = html`\r\n ${formattedNumItems} ${itemsText}<br />\r\n ${dataset.tooltip}\r\n `;\r\n this._tooltipVisible = true;\r\n }\r\n\r\n private hideTooltip(): void {\r\n this._tooltipContent = undefined;\r\n this._tooltipVisible = false;\r\n }\r\n\r\n // use arrow functions (rather than standard JS class instance methods) so\r\n // that `this` is bound to the histogramDateRange object and not the event\r\n // target. for more info see\r\n // https://lit-element.polymer-project.org/guide/events#using-this-in-event-listeners\r\n private drag = (e: PointerEvent): void => {\r\n // prevent selecting text or other ranges while dragging, especially in Safari\r\n e.preventDefault();\r\n if (this.disabled) {\r\n return;\r\n }\r\n this.setDragOffset(e);\r\n this._isDragging = true;\r\n this.addListeners();\r\n this.cancelPendingUpdateEvent();\r\n };\r\n\r\n private drop = (): void => {\r\n if (this._isDragging) {\r\n this.removeListeners();\r\n this.beginEmitUpdateProcess();\r\n }\r\n this._isDragging = false;\r\n };\r\n\r\n /**\r\n * Adjust the date range based on slider movement\r\n *\r\n * @param e PointerEvent from the slider being moved\r\n */\r\n private move = (e: PointerEvent): void => {\r\n const histogramClientX = this.getBoundingClientRect().x;\r\n const newX = e.clientX - histogramClientX - this._dragOffset;\r\n const slider = this._currentSlider as SVGRectElement;\r\n if ((slider.id as SliderId) === 'slider-min') {\r\n this.minSelectedDate = this.translatePositionToDate(\r\n this.validMinSliderX(newX)\r\n );\r\n } else {\r\n this.maxSelectedDate = this.translatePositionToDate(\r\n this.validMaxSliderX(newX)\r\n );\r\n if (this.getMSFromString(this.maxSelectedDate) > this._maxDateMS) {\r\n this.maxSelectedDate = this.maxDate;\r\n }\r\n }\r\n };\r\n\r\n /**\r\n * Constrain a proposed value for the minimum (left) slider\r\n *\r\n * If the value is less than the leftmost valid position, then set it to the\r\n * left edge of the histogram (ie the slider width). If the value is greater\r\n * than the rightmost valid position (the position of the max slider), then\r\n * set it to the position of the max slider\r\n */\r\n private validMinSliderX(newX: number): number {\r\n // allow the left slider to go right only to the right slider, even if the\r\n // max selected date is out of range\r\n const rightLimit = Math.min(\r\n this.translateDateToPosition(this.maxSelectedDate),\r\n this.histogramRightEdgeX\r\n );\r\n newX = this.clamp(newX, this.histogramLeftEdgeX, rightLimit);\r\n const isInvalid =\r\n Number.isNaN(newX) || rightLimit < this.histogramLeftEdgeX;\r\n return isInvalid ? this.histogramLeftEdgeX : newX;\r\n }\r\n\r\n /**\r\n * Constrain a proposed value for the maximum (right) slider\r\n *\r\n * If the value is greater than the rightmost valid position, then set it to\r\n * the right edge of the histogram (ie histogram width - slider width). If the\r\n * value is less than the leftmost valid position (the position of the min\r\n * slider), then set it to the position of the min slider\r\n */\r\n private validMaxSliderX(newX: number): number {\r\n // allow the right slider to go left only to the left slider, even if the\r\n // min selected date is out of range\r\n const leftLimit = Math.max(\r\n this.histogramLeftEdgeX,\r\n this.translateDateToPosition(this.minSelectedDate)\r\n );\r\n newX = this.clamp(newX, leftLimit, this.histogramRightEdgeX);\r\n const isInvalid =\r\n Number.isNaN(newX) || leftLimit > this.histogramRightEdgeX;\r\n return isInvalid ? this.histogramRightEdgeX : newX;\r\n }\r\n\r\n private addListeners(): void {\r\n window.addEventListener('pointermove', this.move);\r\n window.addEventListener('pointerup', this.drop);\r\n window.addEventListener('pointercancel', this.drop);\r\n }\r\n\r\n private removeListeners(): void {\r\n window.removeEventListener('pointermove', this.move);\r\n window.removeEventListener('pointerup', this.drop);\r\n window.removeEventListener('pointercancel', this.drop);\r\n }\r\n\r\n /**\r\n * start a timer to emit an update event. this timer can be canceled (and the\r\n * event not emitted) if user drags a slider or focuses a date input within\r\n * the update delay\r\n */\r\n private beginEmitUpdateProcess(): void {\r\n this.cancelPendingUpdateEvent();\r\n this._emitUpdatedEventTimer = setTimeout(() => {\r\n if (this.currentDateRangeString === this._previousDateRange) {\r\n // don't emit duplicate event if no change since last emitted event\r\n return;\r\n }\r\n this._previousDateRange = this.currentDateRangeString;\r\n const options = {\r\n detail: {\r\n minDate: this.minSelectedDate,\r\n maxDate: this.maxSelectedDate,\r\n },\r\n bubbles: true,\r\n composed: true,\r\n };\r\n this.dispatchEvent(new CustomEvent('histogramDateRangeUpdated', options));\r\n }, this.updateDelay);\r\n }\r\n\r\n private cancelPendingUpdateEvent(): void {\r\n if (this._emitUpdatedEventTimer === undefined) {\r\n return;\r\n }\r\n clearTimeout(this._emitUpdatedEventTimer);\r\n this._emitUpdatedEventTimer = undefined;\r\n }\r\n\r\n /**\r\n * find position of pointer in relation to the current slider\r\n */\r\n private setDragOffset(e: PointerEvent): void {\r\n this._currentSlider = e.currentTarget as SVGRectElement;\r\n const sliderX =\r\n (this._currentSlider.id as SliderId) === 'slider-min'\r\n ? this.minSliderX\r\n : this.maxSliderX;\r\n const histogramClientX = this.getBoundingClientRect().x;\r\n this._dragOffset = e.clientX - histogramClientX - sliderX;\r\n }\r\n\r\n /**\r\n * @param x horizontal position of slider\r\n * @returns string representation of date\r\n */\r\n private translatePositionToDate(x: number): string {\r\n // Snap to the nearest second, fixing the case where input like 1/1/2010\r\n // would get translated to 12/31/2009 due to slight discrepancies from\r\n // pixel boundaries and floating point error.\r\n const milliseconds = this.snapToNextSecond(\r\n ((x - this.sliderWidth) * this.dateRangeMS) / this._histWidth\r\n );\r\n return this.formatDate(this._minDateMS + milliseconds);\r\n }\r\n\r\n /**\r\n * Returns slider x-position corresponding to given date\r\n *\r\n * @param date\r\n * @returns x-position of slider\r\n */\r\n private translateDateToPosition(date: string): number {\r\n const milliseconds = this.getMSFromString(date);\r\n return (\r\n this.sliderWidth +\r\n ((milliseconds - this._minDateMS) * this._histWidth) / this.dateRangeMS\r\n );\r\n }\r\n\r\n /** ensure that the returned value is between minValue and maxValue */\r\n private clamp(x: number, minValue: number, maxValue: number): number {\r\n return Math.min(Math.max(x, minValue), maxValue);\r\n }\r\n\r\n private handleInputFocus(): void {\r\n if (!this.updateWhileFocused) {\r\n this.cancelPendingUpdateEvent();\r\n }\r\n }\r\n\r\n private handleMinDateInput(e: Event): void {\r\n const target = e.currentTarget as HTMLInputElement;\r\n if (target.value !== this.minSelectedDate) {\r\n this.minSelectedDate = target.value;\r\n this.beginEmitUpdateProcess();\r\n }\r\n }\r\n\r\n private handleMaxDateInput(e: Event): void {\r\n const target = e.currentTarget as HTMLInputElement;\r\n if (target.value !== this.maxSelectedDate) {\r\n this.maxSelectedDate = target.value;\r\n this.beginEmitUpdateProcess();\r\n }\r\n }\r\n\r\n private handleKeyUp(e: KeyboardEvent): void {\r\n if (e.key === 'Enter') {\r\n const target = e.currentTarget as HTMLInputElement;\r\n target.blur();\r\n if (target.id === 'date-min') {\r\n this.handleMinDateInput(e);\r\n } else if (target.id === 'date-max') {\r\n this.handleMaxDateInput(e);\r\n }\r\n }\r\n }\r\n\r\n private get currentDateRangeString(): string {\r\n return `${this.minSelectedDate}:${this.maxSelectedDate}`;\r\n }\r\n\r\n private getMSFromString(date: unknown): number {\r\n // It's possible that `date` is not a string in certain situations.\r\n // For instance if you use LitElement bindings and the date is `2000`,\r\n // it will be treated as a number instead of a string. This just makes sure\r\n // we're dealing with a string.\r\n const stringified = typeof date === 'string' ? date : String(date);\r\n const digitGroupCount = (stringified.split(/(\\d+)/).length - 1) / 2;\r\n if (digitGroupCount === 1) {\r\n // if there's just a single set of digits, assume it's a year\r\n const dateObj = new Date(0, 0); // start at January 1, 1900\r\n dateObj.setFullYear(Number(stringified)); // override year\r\n return dateObj.getTime(); // get time in milliseconds\r\n }\r\n return dayjs(stringified, [this.dateFormat, DATE_FORMAT]).valueOf();\r\n }\r\n\r\n /**\r\n * expand or narrow the selected range by moving the slider nearest the\r\n * clicked bar to the outer edge of the clicked bar\r\n *\r\n * @param e Event click event from a histogram bar\r\n */\r\n private handleBarClick(e: Event): void {\r\n const dataset = (e.currentTarget as SVGRectElement).dataset as BarDataset;\r\n // use the midpoint of the width of the clicked bar to determine which is\r\n // the nearest slider\r\n const clickPosition =\r\n (this.getMSFromString(dataset.binStart) +\r\n this.getMSFromString(dataset.binEnd)) /\r\n 2;\r\n const distanceFromMinSlider = Math.abs(\r\n clickPosition - this.getMSFromString(this.minSelectedDate)\r\n );\r\n const distanceFromMaxSlider = Math.abs(\r\n clickPosition - this.getMSFromString(this.maxSelectedDate)\r\n );\r\n // update the selected range by moving the nearer slider\r\n if (distanceFromMinSlider < distanceFromMaxSlider) {\r\n this.minSelectedDate = dataset.binStart;\r\n } else {\r\n this.maxSelectedDate = dataset.binEnd;\r\n }\r\n this.beginEmitUpdateProcess();\r\n }\r\n\r\n private get minSliderTemplate(): SVGTemplateResult {\r\n // width/height in pixels of curved part of the sliders (like\r\n // border-radius); used as part of a SVG quadratic curve. see\r\n // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#curve_commands\r\n const cs = SLIDER_CORNER_SIZE;\r\n\r\n const sliderShape = `\r\n M${this.minSliderX},0\r\n h-${this.sliderWidth - cs}\r\n q-${cs},0 -${cs},${cs}\r\n v${this.height - cs * 2}\r\n q0,${cs} ${cs},${cs}\r\n h${this.sliderWidth - cs}\r\n `;\r\n return this.generateSliderSVG(this.minSliderX, 'slider-min', sliderShape);\r\n }\r\n\r\n private get maxSliderTemplate(): SVGTemplateResult {\r\n const cs = SLIDER_CORNER_SIZE;\r\n const sliderShape = `\r\n M${this.maxSliderX},0\r\n h${this.sliderWidth - cs}\r\n q${cs},0 ${cs},${cs}\r\n v${this.height - cs * 2}\r\n q0,${cs} -${cs},${cs}\r\n h-${this.sliderWidth - cs}\r\n `;\r\n return this.generateSliderSVG(this.maxSliderX, 'slider-max', sliderShape);\r\n }\r\n\r\n private generateSliderSVG(\r\n sliderPositionX: number,\r\n id: SliderId,\r\n sliderShape: string\r\n ): SVGTemplateResult {\r\n // whether the curved part of the slider is facing towards the left (1), ie\r\n // minimum, or facing towards the right (-1), ie maximum\r\n const k = id === 'slider-min' ? 1 : -1;\r\n\r\n const sliderClasses = classMap({\r\n slider: true,\r\n draggable: !this.disabled,\r\n dragging: this._isDragging,\r\n });\r\n\r\n return svg`\r\n <svg\r\n id=${id}\r\n class=${sliderClasses}\r\n @pointerdown=${this.drag}\r\n >\r\n <path d=\"${sliderShape} z\" fill=\"${sliderColor}\" />\r\n <rect\r\n x=\"${\r\n sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k\r\n }\"\r\n y=\"${this.height / 3}\"\r\n width=\"1\"\r\n height=\"${this.height / 3}\"\r\n fill=\"white\"\r\n />\r\n <rect\r\n x=\"${\r\n sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k\r\n }\"\r\n y=\"${this.height / 3}\"\r\n width=\"1\"\r\n height=\"${this.height / 3}\"\r\n fill=\"white\"\r\n />\r\n </svg>\r\n `;\r\n }\r\n\r\n get selectedRangeTemplate(): SVGTemplateResult {\r\n return svg`\r\n <rect\r\n x=\"${this.minSliderX}\"\r\n y=\"0\"\r\n width=\"${this.maxSliderX - this.minSliderX}\"\r\n height=\"${this.height}\"\r\n fill=\"${selectedRangeColor}\"\r\n />`;\r\n }\r\n\r\n get histogramTemplate(): SVGTemplateResult[] {\r\n const xScale = this._histWidth / this._numBins;\r\n const barWidth = xScale - 1;\r\n let x = this.sliderWidth; // start at the left edge of the histogram\r\n\r\n return this._histData.map(data => {\r\n const { minSelectedDate, maxSelectedDate } = this;\r\n const barHeight = data.height;\r\n\r\n const binIsBeforeMin = this.isBefore(data.binEnd, minSelectedDate);\r\n const binIsAfterMax = this.isAfter(data.binStart, maxSelectedDate);\r\n const barFill =\r\n binIsBeforeMin || binIsAfterMax ? barExcludedFill : barIncludedFill;\r\n\r\n // the stroke-dasharray style below creates a transparent border around the\r\n // right edge of the bar, which prevents user from encountering a gap\r\n // between adjacent bars (eg when viewing the tooltips or when trying to\r\n // extend the range by clicking on a bar)\r\n const barStyle = `stroke-dasharray: 0 ${barWidth} ${barHeight} ${barWidth} 0 ${barHeight}`;\r\n\r\n const bar = svg`\r\n <rect\r\n class=\"bar\"\r\n style=${barStyle}\r\n x=${x}\r\n y=${this.height - barHeight}\r\n width=${barWidth}\r\n height=${barHeight}\r\n @pointerenter=${this.showTooltip}\r\n @pointerleave=${this.hideTooltip}\r\n @click=${this.handleBarClick}\r\n fill=${barFill}\r\n data-num-items=${data.value}\r\n data-bin-start=${data.binStart}\r\n data-bin-end=${data.binEnd}\r\n data-tooltip=${data.tooltip}\r\n />`;\r\n x += xScale;\r\n return bar;\r\n });\r\n }\r\n\r\n /** Whether the first arg represents a date strictly before the second arg */\r\n private isBefore(date1: string, date2: string): boolean {\r\n const date1MS = this.getMSFromString(date1);\r\n const date2MS = this.getMSFromString(date2);\r\n return date1MS < date2MS;\r\n }\r\n\r\n /** Whether the first arg represents a date strictly after the second arg */\r\n private isAfter(date1: string, date2: string): boolean {\r\n const date1MS = this.getMSFromString(date1);\r\n const date2MS = this.getMSFromString(date2);\r\n return date1MS > date2MS;\r\n }\r\n\r\n private formatDate(dateMS: number, format: string = this.dateFormat): string {\r\n if (Number.isNaN(dateMS)) {\r\n return '';\r\n }\r\n const date = dayjs(dateMS);\r\n if (date.year() < 1000) {\r\n // years before 1000 don't play well with dayjs custom formatting, so work around dayjs\r\n // by setting the year to a sentinel value and then replacing it instead.\r\n // this is a bit hacky but it does the trick for essentially all reasonable cases\r\n // until such time as we replace dayjs.\r\n const tmpDate = date.year(199999);\r\n return tmpDate.format(format).replace(/199999/g, date.year().toString());\r\n }\r\n return date.format(format);\r\n }\r\n\r\n /**\r\n * NOTE: we are relying on the lit `live` directive in the template to\r\n * ensure that the change to minSelectedDate is noticed and the input value\r\n * gets properly re-rendered. see\r\n * https://lit.dev/docs/templates/directives/#live\r\n */\r\n get minInputTemplate(): TemplateResult {\r\n return html`\r\n <input\r\n id=\"date-min\"\r\n placeholder=${this.dateFormat}\r\n type=\"text\"\r\n @focus=${this.handleInputFocus}\r\n @blur=${this.handleMinDateInput}\r\n @keyup=${this.handleKeyUp}\r\n .value=${live(this.minSelectedDate)}\r\n ?disabled=${this.disabled}\r\n />\r\n `;\r\n }\r\n\r\n get maxInputTemplate(): TemplateResult {\r\n return html`\r\n <input\r\n id=\"date-max\"\r\n placeholder=${this.dateFormat}\r\n type=\"text\"\r\n @focus=${this.handleInputFocus}\r\n @blur=${this.handleMaxDateInput}\r\n @keyup=${this.handleKeyUp}\r\n .value=${live(this.maxSelectedDate)}\r\n ?disabled=${this.disabled}\r\n />\r\n `;\r\n }\r\n\r\n get minLabelTemplate(): TemplateResult {\r\n return html`<label for=\"date-min\" class=\"sr-only\">Minimum date:</label>`;\r\n }\r\n\r\n get maxLabelTemplate(): TemplateResult {\r\n return html`<label for=\"date-max\" class=\"sr-only\">Maximum date:</label>`;\r\n }\r\n\r\n get tooltipTemplate(): TemplateResult {\r\n return html`\r\n <style>\r\n #tooltip {\r\n width: ${this.tooltipWidth}px;\r\n height: ${this.tooltipHeight}px;\r\n top: ${-9 - this.tooltipHeight}px;\r\n left: ${this._tooltipOffset}px;\r\n display: ${this._tooltipVisible ? 'block' : 'none'};\r\n }\r\n #tooltip:after {\r\n left: ${this.tooltipWidth / 2}px;\r\n }\r\n </style>\r\n <div id=\"tooltip\">${this._tooltipContent}</div>\r\n `;\r\n }\r\n\r\n private get noDataTemplate(): TemplateResult {\r\n return html`\r\n <div class=\"missing-data-message\">${this.missingDataMessage}</div>\r\n `;\r\n }\r\n\r\n private get activityIndicatorTemplate(): TemplateResult | typeof nothing {\r\n if (!this.loading) {\r\n return nothing;\r\n }\r\n return html`\r\n <ia-activity-indicator mode=\"processing\"> </ia-activity-indicator>\r\n `;\r\n }\r\n\r\n static styles = css`\r\n .missing-data-message {\r\n text-align: center;\r\n }\r\n #container {\r\n margin: 0;\r\n touch-action: none;\r\n position: relative;\r\n }\r\n .disabled {\r\n opacity: 0.3;\r\n }\r\n ia-activity-indicator {\r\n position: absolute;\r\n left: calc(50% - 10px);\r\n top: 10px;\r\n width: 20px;\r\n height: 20px;\r\n --activityIndicatorLoadingDotColor: rgba(0, 0, 0, 0);\r\n --activityIndicatorLoadingRingColor: ${activityIndicatorColor};\r\n }\r\n\r\n /* prevent selection from interfering with tooltip, especially on mobile */\r\n /* https://stackoverflow.com/a/4407335/1163042 */\r\n .noselect {\r\n -webkit-touch-callout: none; /* iOS Safari */\r\n -webkit-user-select: none; /* Safari */\r\n -moz-user-select: none; /* Old versions of Firefox */\r\n -ms-user-select: none; /* Internet Explorer/Edge */\r\n user-select: none; /* current Chrome, Edge, Opera and Firefox */\r\n }\r\n .bar {\r\n /* create a transparent border around the hist bars to prevent \"gaps\" and\r\n flickering when moving around between bars. this also helps with handling\r\n clicks on the bars, preventing users from being able to click in between\r\n bars */\r\n stroke: rgba(0, 0, 0, 0);\r\n /* ensure transparent stroke wide enough to cover gap between bars */\r\n stroke-width: 2px;\r\n }\r\n .bar:hover {\r\n /* highlight currently hovered bar */\r\n fill-opacity: 0.7;\r\n }\r\n .disabled .bar:hover {\r\n /* ensure no visual hover interaction when disabled */\r\n fill-opacity: 1;\r\n }\r\n /****** histogram ********/\r\n #tooltip {\r\n position: absolute;\r\n background: ${tooltipBackgroundColor};\r\n color: ${tooltipTextColor};\r\n text-align: center;\r\n border-radius: 3px;\r\n padding: 2px;\r\n font-size: ${tooltipFontSize};\r\n font-family: ${tooltipFontFamily};\r\n touch-action: none;\r\n pointer-events: none;\r\n }\r\n #tooltip:after {\r\n content: '';\r\n position: absolute;\r\n margin-left: -5px;\r\n top: 100%;\r\n /* arrow */\r\n border: 5px solid ${tooltipTextColor};\r\n border-color: ${tooltipBackgroundColor} transparent transparent\r\n transparent;\r\n }\r\n /****** slider ********/\r\n .slider {\r\n shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */\r\n }\r\n .draggable:hover {\r\n cursor: grab;\r\n }\r\n .dragging {\r\n cursor: grabbing !important;\r\n }\r\n /****** inputs ********/\r\n #inputs {\r\n display: flex;\r\n justify-content: center;\r\n margin: ${inputRowMargin};\r\n }\r\n #inputs .dash {\r\n position: relative;\r\n bottom: -1px;\r\n align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */\r\n }\r\n input {\r\n width: ${inputWidth};\r\n margin: 0 3px;\r\n border: ${inputBorder};\r\n border-radius: 2px !important;\r\n text-align: center;\r\n font-size: ${inputFontSize};\r\n font-family: ${inputFontFamily};\r\n }\r\n .sr-only {\r\n position: absolute !important;\r\n width: 1px !important;\r\n height: 1px !important;\r\n margin: 0 !important;\r\n padding: 0 !important;\r\n border: 0 !important;\r\n overflow: hidden !important;\r\n white-space: nowrap !important;\r\n clip: rect(1px, 1px, 1px, 1px) !important;\r\n -webkit-clip-path: inset(50%) !important;\r\n clip-path: inset(50%) !important;\r\n }\r\n `;\r\n\r\n render(): TemplateResult {\r\n if (!this.hasBinData) {\r\n return this.noDataTemplate;\r\n }\r\n return html`\r\n <div\r\n id=\"container\"\r\n class=\"\r\n noselect\r\n ${this._isDragging ? 'dragging' : ''}\r\n \"\r\n style=\"width: ${this.width}px\"\r\n >\r\n ${this.activityIndicatorTemplate} ${this.tooltipTemplate}\r\n <div\r\n class=\"inner-container\r\n ${this.disabled ? 'disabled' : ''}\"\r\n >\r\n <svg\r\n width=\"${this.width}\"\r\n height=\"${this.height}\"\r\n @pointerleave=\"${this.drop}\"\r\n >\r\n ${this.selectedRangeTemplate}\r\n <svg id=\"histogram\">${this.histogramTemplate}</svg>\r\n ${this.minSliderTemplate} ${this.maxSliderTemplate}\r\n </svg>\r\n <div id=\"inputs\">\r\n ${this.minLabelTemplate} ${this.minInputTemplate}\r\n <div class=\"dash\">-</div>\r\n ${this.maxLabelTemplate} ${this.maxInputTemplate}\r\n <slot name=\"inputs-right-side\"></slot>\r\n </div>\r\n </div>\r\n </div>\r\n `;\r\n }\r\n}\r\n\r\n// help TypeScript provide strong typing when interacting with DOM APIs\r\n// https://stackoverflow.com/questions/65148695/lit-element-typescript-project-global-interface-declaration-necessary\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n 'histogram-date-range': HistogramDateRange;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type dayjs from 'dayjs/esm';
|
|
2
|
+
/**
|
|
3
|
+
* As with the Date(y, m, ...) constructor, dayjs interprets years 0-99 as offsets
|
|
4
|
+
* from the year 1900 instead of the actual first-century years.
|
|
5
|
+
* We don't want that weird legacy behavior; we want years parsed literally.
|
|
6
|
+
*
|
|
7
|
+
* The maintainer of dayjs apparently refuses to address this:
|
|
8
|
+
* - https://github.com/iamkun/dayjs/pull/548#issuecomment-477660947
|
|
9
|
+
* - https://github.com/iamkun/dayjs/issues/1237
|
|
10
|
+
*
|
|
11
|
+
* So this plugin tries to detect the anomalous cases where the date format
|
|
12
|
+
* contains a YYYY block and the parsed date has a year in the 1900-1999 range,
|
|
13
|
+
* by checking whether the parsed year actually occurred in the original string.
|
|
14
|
+
* If not, then we assume it was parsed incorrectly as an offset, and adjust.
|
|
15
|
+
*
|
|
16
|
+
* In practice this assumption could fail if the input date is invalid in some
|
|
17
|
+
* way (e.g. having overflow, like a YYYY-MM-DD of "1950-22-33", which might be
|
|
18
|
+
* converted to 1951-11-02 and produce a false positive). Essentially, we trade away
|
|
19
|
+
* leniency for overflow dates to ensure that we handle all valid ones correctly.
|
|
20
|
+
* This seems a reasonable tradeoff for our present use cases. But realistically we
|
|
21
|
+
* should probably explore moving to a date lib that handles these cases properly.
|
|
22
|
+
*/
|
|
23
|
+
export default function fixFirstCenturyYears(_: unknown, dayjsClass: typeof dayjs.Dayjs): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* As with the Date(y, m, ...) constructor, dayjs interprets years 0-99 as offsets
|
|
3
|
+
* from the year 1900 instead of the actual first-century years.
|
|
4
|
+
* We don't want that weird legacy behavior; we want years parsed literally.
|
|
5
|
+
*
|
|
6
|
+
* The maintainer of dayjs apparently refuses to address this:
|
|
7
|
+
* - https://github.com/iamkun/dayjs/pull/548#issuecomment-477660947
|
|
8
|
+
* - https://github.com/iamkun/dayjs/issues/1237
|
|
9
|
+
*
|
|
10
|
+
* So this plugin tries to detect the anomalous cases where the date format
|
|
11
|
+
* contains a YYYY block and the parsed date has a year in the 1900-1999 range,
|
|
12
|
+
* by checking whether the parsed year actually occurred in the original string.
|
|
13
|
+
* If not, then we assume it was parsed incorrectly as an offset, and adjust.
|
|
14
|
+
*
|
|
15
|
+
* In practice this assumption could fail if the input date is invalid in some
|
|
16
|
+
* way (e.g. having overflow, like a YYYY-MM-DD of "1950-22-33", which might be
|
|
17
|
+
* converted to 1951-11-02 and produce a false positive). Essentially, we trade away
|
|
18
|
+
* leniency for overflow dates to ensure that we handle all valid ones correctly.
|
|
19
|
+
* This seems a reasonable tradeoff for our present use cases. But realistically we
|
|
20
|
+
* should probably explore moving to a date lib that handles these cases properly.
|
|
21
|
+
*/
|
|
22
|
+
export default function fixFirstCenturyYears(_, dayjsClass) {
|
|
23
|
+
const proto = dayjsClass.prototype;
|
|
24
|
+
const oldParse = proto.parse;
|
|
25
|
+
proto.parse = function (cfg) {
|
|
26
|
+
const inputDate = cfg.date;
|
|
27
|
+
const format = cfg.args[1];
|
|
28
|
+
oldParse.call(this, cfg);
|
|
29
|
+
const year = this.year();
|
|
30
|
+
const isProblemDateRange = year >= 1900 && year < 2000;
|
|
31
|
+
const isProblemStringFormat = typeof format === 'string' && format.includes('YYYY');
|
|
32
|
+
const isProblemArrayFormat = Array.isArray(format) &&
|
|
33
|
+
typeof format[0] === 'string' &&
|
|
34
|
+
format[0].includes('YYYY');
|
|
35
|
+
const isProblemFormat = isProblemStringFormat || isProblemArrayFormat;
|
|
36
|
+
const missingParsedYear = typeof inputDate === 'string' && !inputDate.includes(`${year}`);
|
|
37
|
+
if (isProblemDateRange && isProblemFormat && missingParsedYear) {
|
|
38
|
+
this.$d.setFullYear(year - 1900);
|
|
39
|
+
this.init(); // Re-initialize with the new date
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=fix-first-century-years.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-first-century-years.js","sourceRoot":"","sources":["../../../src/plugins/fix-first-century-years.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,CAAU,EACV,UAA8B;IAE9B,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC;IACnC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;IAC7B,KAAK,CAAC,KAAK,GAAG,UAAU,GAAG;QACzB,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC;QAC3B,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3B,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAEzB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACzB,MAAM,kBAAkB,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG,IAAI,CAAC;QACvD,MAAM,qBAAqB,GACzB,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACxD,MAAM,oBAAoB,GACxB,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YACrB,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ;YAC7B,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC7B,MAAM,eAAe,GAAG,qBAAqB,IAAI,oBAAoB,CAAC;QACtE,MAAM,iBAAiB,GACrB,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;QAElE,IAAI,kBAAkB,IAAI,eAAe,IAAI,iBAAiB,EAAE;YAC9D,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;YACjC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,kCAAkC;SAChD;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type dayjs from 'dayjs/esm';\r\n\r\n/**\r\n * As with the Date(y, m, ...) constructor, dayjs interprets years 0-99 as offsets\r\n * from the year 1900 instead of the actual first-century years.\r\n * We don't want that weird legacy behavior; we want years parsed literally.\r\n *\r\n * The maintainer of dayjs apparently refuses to address this:\r\n * - https://github.com/iamkun/dayjs/pull/548#issuecomment-477660947\r\n * - https://github.com/iamkun/dayjs/issues/1237\r\n *\r\n * So this plugin tries to detect the anomalous cases where the date format\r\n * contains a YYYY block and the parsed date has a year in the 1900-1999 range,\r\n * by checking whether the parsed year actually occurred in the original string.\r\n * If not, then we assume it was parsed incorrectly as an offset, and adjust.\r\n *\r\n * In practice this assumption could fail if the input date is invalid in some\r\n * way (e.g. having overflow, like a YYYY-MM-DD of \"1950-22-33\", which might be\r\n * converted to 1951-11-02 and produce a false positive). Essentially, we trade away\r\n * leniency for overflow dates to ensure that we handle all valid ones correctly.\r\n * This seems a reasonable tradeoff for our present use cases. But realistically we\r\n * should probably explore moving to a date lib that handles these cases properly.\r\n */\r\nexport default function fixFirstCenturyYears(\r\n _: unknown,\r\n dayjsClass: typeof dayjs.Dayjs\r\n) {\r\n const proto = dayjsClass.prototype;\r\n const oldParse = proto.parse;\r\n proto.parse = function (cfg) {\r\n const inputDate = cfg.date;\r\n const format = cfg.args[1];\r\n oldParse.call(this, cfg);\r\n\r\n const year = this.year();\r\n const isProblemDateRange = year >= 1900 && year < 2000;\r\n const isProblemStringFormat =\r\n typeof format === 'string' && format.includes('YYYY');\r\n const isProblemArrayFormat =\r\n Array.isArray(format) &&\r\n typeof format[0] === 'string' &&\r\n format[0].includes('YYYY');\r\n const isProblemFormat = isProblemStringFormat || isProblemArrayFormat;\r\n const missingParsedYear =\r\n typeof inputDate === 'string' && !inputDate.includes(`${year}`);\r\n\r\n if (isProblemDateRange && isProblemFormat && missingParsedYear) {\r\n this.$d.setFullYear(year - 1900);\r\n this.init(); // Re-initialize with the new date\r\n }\r\n };\r\n}\r\n"]}
|