@internetarchive/histogram-date-range 1.4.0-alpha-webdev7756.0 → 1.4.0-alpha-webdev7756.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/demo/index.html +22 -9
- package/demo/js/{lit-histogram-wrapper.ts → app-root.ts} +4 -20
- package/dist/demo/js/app-root.d.ts +1 -2
- package/dist/demo/js/app-root.js +19 -20
- package/dist/demo/js/app-root.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/histogram-date-range.d.ts +18 -9
- package/dist/src/histogram-date-range.js +32 -16
- package/dist/src/histogram-date-range.js.map +1 -1
- package/dist/test/histogram-date-range.test.js +19 -1
- package/dist/test/histogram-date-range.test.js.map +1 -1
- package/docs/demo/index.html +22 -9
- package/docs/dist/demo/js/{lit-histogram-wrapper.js → app-root.js} +7 -22
- package/docs/dist/src/histogram-date-range.js +14 -5
- package/index.ts +3 -0
- package/package.json +1 -1
- package/src/histogram-date-range.ts +55 -35
- package/test/histogram-date-range.test.ts +27 -1
package/demo/index.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<script type="module">
|
|
10
10
|
import '../dist/src/histogram-date-range.js';
|
|
11
11
|
let eventCount = 0;
|
|
12
|
-
import '../dist/demo/js/
|
|
12
|
+
import '../dist/demo/js/app-root.js';
|
|
13
13
|
// listen to events from the component and display the data received from them
|
|
14
14
|
document.addEventListener('histogramDateRangeUpdated', e => {
|
|
15
15
|
document.querySelector('.received-events').innerHTML =
|
|
@@ -22,14 +22,7 @@
|
|
|
22
22
|
<div class="description">
|
|
23
23
|
histogram inside a lit element
|
|
24
24
|
</div>
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
<div class="description">
|
|
28
|
-
bars scaled linearly (not logarithmic)
|
|
29
|
-
</div>
|
|
30
|
-
<lit-histogram-wrapper
|
|
31
|
-
barScaling="linear"
|
|
32
|
-
></lit-histogram-wrapper>
|
|
25
|
+
<app-root></app-root>
|
|
33
26
|
|
|
34
27
|
<div class="description">
|
|
35
28
|
pre-selected range with 1000ms debounce delay
|
|
@@ -79,6 +72,26 @@
|
|
|
79
72
|
</histogram-date-range>
|
|
80
73
|
</div>
|
|
81
74
|
|
|
75
|
+
<div class="container">
|
|
76
|
+
<div class="description">
|
|
77
|
+
as above, but with linear scaled bars
|
|
78
|
+
</div>
|
|
79
|
+
<histogram-date-range
|
|
80
|
+
width="175"
|
|
81
|
+
tooltipwidth="120"
|
|
82
|
+
dateFormat="YYYY"
|
|
83
|
+
updateDelay="1000"
|
|
84
|
+
missingDataMessage="..."
|
|
85
|
+
barScaling="linear"
|
|
86
|
+
minSelectedDate="1987"
|
|
87
|
+
maxSelectedDate="2016"
|
|
88
|
+
minDate="1987"
|
|
89
|
+
maxDate="2016"
|
|
90
|
+
bins="[1519,1643,1880,2046,1973,2085,2148,2152,2349,2304,2314,2484,2590,2450,2495,2475,2392,2631,2504,2619,2519,2552,2462,2217,2171,2132,2127,2041,1638,1441]"
|
|
91
|
+
>
|
|
92
|
+
</histogram-date-range>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
82
95
|
<div class="container">
|
|
83
96
|
<div class="description">small year range and few bins</div>
|
|
84
97
|
<histogram-date-range width="175" tooltipwidth="120"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LitElement, html,
|
|
2
|
-
import { customElement,
|
|
1
|
+
import { LitElement, html, TemplateResult } from 'lit';
|
|
2
|
+
import { customElement, state } from 'lit/decorators.js';
|
|
3
3
|
import '../../src/histogram-date-range';
|
|
4
4
|
|
|
5
5
|
interface DataSource {
|
|
@@ -10,16 +10,12 @@ interface DataSource {
|
|
|
10
10
|
bins: number[];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const IDENTITY_FN = (x: number) => x;
|
|
14
|
-
|
|
15
13
|
/**
|
|
16
14
|
* This is mainly to test the histogram-date-range within
|
|
17
15
|
* a lit-element.
|
|
18
16
|
*/
|
|
19
|
-
@customElement('
|
|
20
|
-
export class
|
|
21
|
-
@property({ type: String }) barScaling?: 'linear' | 'logarithmic';
|
|
22
|
-
|
|
17
|
+
@customElement('app-root')
|
|
18
|
+
export class AppRoot extends LitElement {
|
|
23
19
|
@state() dataSource: DataSource = {
|
|
24
20
|
minDate: 1955,
|
|
25
21
|
maxDate: 2000,
|
|
@@ -31,7 +27,6 @@ export class LitHistogramWrapper extends LitElement {
|
|
|
31
27
|
};
|
|
32
28
|
|
|
33
29
|
render(): TemplateResult {
|
|
34
|
-
const scalingFn = this.barScaling === 'linear' ? IDENTITY_FN : nothing;
|
|
35
30
|
return html`
|
|
36
31
|
<histogram-date-range
|
|
37
32
|
.minDate=${this.dataSource?.minDate}
|
|
@@ -40,7 +35,6 @@ export class LitHistogramWrapper extends LitElement {
|
|
|
40
35
|
.maxSelectedDate=${this.dataSource?.maxSelectedDate}
|
|
41
36
|
.updateDelay=${1000}
|
|
42
37
|
.bins=${this.dataSource?.bins}
|
|
43
|
-
.barScalingFunction=${scalingFn}
|
|
44
38
|
></histogram-date-range>
|
|
45
39
|
|
|
46
40
|
<button @click=${this.randomize}>Randomize</button>
|
|
@@ -62,14 +56,4 @@ export class LitHistogramWrapper extends LitElement {
|
|
|
62
56
|
bins: bins,
|
|
63
57
|
};
|
|
64
58
|
}
|
|
65
|
-
|
|
66
|
-
static get styles() {
|
|
67
|
-
return css`
|
|
68
|
-
:host {
|
|
69
|
-
display: flex;
|
|
70
|
-
flex-direction: column;
|
|
71
|
-
align-items: center;
|
|
72
|
-
}
|
|
73
|
-
`;
|
|
74
|
-
}
|
|
75
59
|
}
|
|
@@ -6,13 +6,12 @@ interface DataSource {
|
|
|
6
6
|
minSelectedDate: unknown;
|
|
7
7
|
maxSelectedDate: unknown;
|
|
8
8
|
bins: number[];
|
|
9
|
-
barScalingFunction?: (input: number) => number;
|
|
10
9
|
}
|
|
11
10
|
/**
|
|
12
11
|
* This is mainly to test the histogram-date-range within
|
|
13
12
|
* a lit-element.
|
|
14
13
|
*/
|
|
15
|
-
export declare class
|
|
14
|
+
export declare class AppRoot extends LitElement {
|
|
16
15
|
dataSource: DataSource;
|
|
17
16
|
render(): TemplateResult;
|
|
18
17
|
private randomize;
|
package/dist/demo/js/app-root.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { LitElement, html
|
|
2
|
+
import { LitElement, html } from 'lit';
|
|
3
3
|
import { customElement, state } from 'lit/decorators.js';
|
|
4
4
|
import '../../src/histogram-date-range';
|
|
5
5
|
/**
|
|
6
6
|
* This is mainly to test the histogram-date-range within
|
|
7
7
|
* a lit-element.
|
|
8
8
|
*/
|
|
9
|
-
let
|
|
9
|
+
let AppRoot = class AppRoot extends LitElement {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
12
12
|
this.dataSource = {
|
|
@@ -20,19 +20,18 @@ let LitHistogramWrapper = class LitHistogramWrapper extends LitElement {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
render() {
|
|
23
|
-
var _a, _b, _c, _d, _e
|
|
24
|
-
return html `
|
|
25
|
-
<histogram-date-range
|
|
26
|
-
.minDate=${(_a = this.dataSource) === null || _a === void 0 ? void 0 : _a.minDate}
|
|
27
|
-
.maxDate=${(_b = this.dataSource) === null || _b === void 0 ? void 0 : _b.maxDate}
|
|
28
|
-
.minSelectedDate=${(_c = this.dataSource) === null || _c === void 0 ? void 0 : _c.minSelectedDate}
|
|
29
|
-
.maxSelectedDate=${(_d = this.dataSource) === null || _d === void 0 ? void 0 : _d.maxSelectedDate}
|
|
30
|
-
.updateDelay=${1000}
|
|
31
|
-
.bins=${(_e = this.dataSource) === null || _e === void 0 ? void 0 : _e.bins}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<button @click=${this.randomize}>Randomize</button>
|
|
23
|
+
var _a, _b, _c, _d, _e;
|
|
24
|
+
return html `
|
|
25
|
+
<histogram-date-range
|
|
26
|
+
.minDate=${(_a = this.dataSource) === null || _a === void 0 ? void 0 : _a.minDate}
|
|
27
|
+
.maxDate=${(_b = this.dataSource) === null || _b === void 0 ? void 0 : _b.maxDate}
|
|
28
|
+
.minSelectedDate=${(_c = this.dataSource) === null || _c === void 0 ? void 0 : _c.minSelectedDate}
|
|
29
|
+
.maxSelectedDate=${(_d = this.dataSource) === null || _d === void 0 ? void 0 : _d.maxSelectedDate}
|
|
30
|
+
.updateDelay=${1000}
|
|
31
|
+
.bins=${(_e = this.dataSource) === null || _e === void 0 ? void 0 : _e.bins}
|
|
32
|
+
></histogram-date-range>
|
|
33
|
+
|
|
34
|
+
<button @click=${this.randomize}>Randomize</button>
|
|
36
35
|
`;
|
|
37
36
|
}
|
|
38
37
|
randomize() {
|
|
@@ -51,9 +50,9 @@ let LitHistogramWrapper = class LitHistogramWrapper extends LitElement {
|
|
|
51
50
|
};
|
|
52
51
|
__decorate([
|
|
53
52
|
state()
|
|
54
|
-
],
|
|
55
|
-
|
|
56
|
-
customElement('
|
|
57
|
-
],
|
|
58
|
-
export {
|
|
53
|
+
], AppRoot.prototype, "dataSource", void 0);
|
|
54
|
+
AppRoot = __decorate([
|
|
55
|
+
customElement('app-root')
|
|
56
|
+
], AppRoot);
|
|
57
|
+
export { AppRoot };
|
|
59
58
|
//# sourceMappingURL=app-root.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-root.js","sourceRoot":"","sources":["../../../demo/js/app-root.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,
|
|
1
|
+
{"version":3,"file":"app-root.js","sourceRoot":"","sources":["../../../demo/js/app-root.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,gCAAgC,CAAC;AAUxC;;;GAGG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,UAAU;IAAhC;;QACI,eAAU,GAAe;YAChC,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;YACb,eAAe,EAAE,IAAI;YACrB,eAAe,EAAE,IAAI;YACrB,IAAI,EAAE;gBACJ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;aACtE;SACF,CAAC;IAgCJ,CAAC;IA9BC,MAAM;;QACJ,OAAO,IAAI,CAAA;;mBAEI,MAAA,IAAI,CAAC,UAAU,0CAAE,OAAO;mBACxB,MAAA,IAAI,CAAC,UAAU,0CAAE,OAAO;2BAChB,MAAA,IAAI,CAAC,UAAU,0CAAE,eAAe;2BAChC,MAAA,IAAI,CAAC,UAAU,0CAAE,eAAe;uBACpC,IAAI;gBACX,MAAA,IAAI,CAAC,UAAU,0CAAE,IAAI;;;uBAGd,IAAI,CAAC,SAAS;KAChC,CAAC;IACJ,CAAC;IAEO,SAAS;QACf,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3D,uBAAuB;QACvB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAC3C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CACpC,CAAC;QACF,IAAI,CAAC,UAAU,GAAG;YAChB,OAAO;YACP,OAAO;YACP,eAAe,EAAE,OAAO;YACxB,eAAe,EAAE,OAAO;YACxB,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC;CACF,CAAA;AAxCU;IAAR,KAAK,EAAE;2CAQN;AATS,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAyCnB","sourcesContent":["import { LitElement, html, TemplateResult } from 'lit';\nimport { customElement, state } from 'lit/decorators.js';\nimport '../../src/histogram-date-range';\n\ninterface DataSource {\n minDate: unknown;\n maxDate: unknown;\n minSelectedDate: unknown;\n maxSelectedDate: unknown;\n bins: number[];\n}\n\n/**\n * This is mainly to test the histogram-date-range within\n * a lit-element.\n */\n@customElement('app-root')\nexport class AppRoot extends LitElement {\n @state() dataSource: DataSource = {\n minDate: 1955,\n maxDate: 2000,\n minSelectedDate: 1955,\n maxSelectedDate: 2000,\n bins: [\n 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n ],\n };\n\n render(): TemplateResult {\n return html`\n <histogram-date-range\n .minDate=${this.dataSource?.minDate}\n .maxDate=${this.dataSource?.maxDate}\n .minSelectedDate=${this.dataSource?.minSelectedDate}\n .maxSelectedDate=${this.dataSource?.maxSelectedDate}\n .updateDelay=${1000}\n .bins=${this.dataSource?.bins}\n ></histogram-date-range>\n\n <button @click=${this.randomize}>Randomize</button>\n `;\n }\n\n private randomize() {\n const minDate = Math.round(Math.random() * 1000);\n const maxDate = minDate + Math.round(Math.random() * 1000);\n // generate random bins\n const bins = Array.from({ length: 20 }, () =>\n Math.floor(Math.random() * minDate)\n );\n this.dataSource = {\n minDate,\n maxDate,\n minSelectedDate: minDate,\n maxSelectedDate: maxDate,\n bins: bins,\n };\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { HistogramDateRange, BinSnappingInterval, } from './src/histogram-date-range';
|
|
1
|
+
export { HistogramDateRange, BinSnappingInterval, BarScalingPreset, BarScalingFunction, BarScalingOption, } from './src/histogram-date-range';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAKnB,MAAM,4BAA4B,CAAC","sourcesContent":["export {\n HistogramDateRange,\n BinSnappingInterval,\n BarScalingPreset,\n BarScalingFunction,\n BarScalingOption,\n} from './src/histogram-date-range';\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import '@internetarchive/ia-activity-indicator';
|
|
2
2
|
import { LitElement, PropertyValues, SVGTemplateResult, TemplateResult } from 'lit';
|
|
3
3
|
export type BinSnappingInterval = 'none' | 'month' | 'year';
|
|
4
|
+
export type BarScalingPreset = 'linear' | 'logarithmic';
|
|
5
|
+
export type BarScalingFunction = (binValue: number) => number;
|
|
6
|
+
export type BarScalingOption = BarScalingPreset | BarScalingFunction;
|
|
4
7
|
export declare class HistogramDateRange extends LitElement {
|
|
5
8
|
width: number;
|
|
6
9
|
height: number;
|
|
@@ -34,18 +37,20 @@ export declare class HistogramDateRange extends LitElement {
|
|
|
34
37
|
*/
|
|
35
38
|
tooltipLabel: string;
|
|
36
39
|
/**
|
|
37
|
-
* A function
|
|
38
|
-
*
|
|
40
|
+
* A function or preset value indicating how the height of each bar relates to its
|
|
41
|
+
* corresponding bin value. Current presets available are 'logarithmic' and 'linear',
|
|
42
|
+
* but a custom function may be provided instead if other behavior is desired.
|
|
39
43
|
*
|
|
40
|
-
*
|
|
41
|
-
* bars for smaller values
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
44
|
+
* The default scaling (`'logarithmic'`) uses the logarithm of each bin value, yielding
|
|
45
|
+
* more prominent bars for smaller values. This ensures that even when the difference
|
|
46
|
+
* between the min & max values is large, small values are unlikely to completely disappear
|
|
47
|
+
* visually. However, the cost is that bars have less noticeable variation among values of
|
|
48
|
+
* a similar magnitude, and their heights are not a direct representation of the bin values.
|
|
45
49
|
*
|
|
46
|
-
*
|
|
50
|
+
* The `'linear'` preset option instead sizes the bars in linear proportion to their bin
|
|
51
|
+
* values.
|
|
47
52
|
*/
|
|
48
|
-
|
|
53
|
+
barScaling: BarScalingOption;
|
|
49
54
|
private _tooltipOffsetX;
|
|
50
55
|
private _tooltipOffsetY;
|
|
51
56
|
private _tooltipContent?;
|
|
@@ -95,6 +100,10 @@ export declare class HistogramDateRange extends LitElement {
|
|
|
95
100
|
* Default is simply to snap to the nearest full second.
|
|
96
101
|
*/
|
|
97
102
|
private snapTimestamp;
|
|
103
|
+
/**
|
|
104
|
+
* Function to scale bin values, whether from a preset or a provided custom function.
|
|
105
|
+
*/
|
|
106
|
+
private get barScalingFunction();
|
|
98
107
|
private calculateHistData;
|
|
99
108
|
private get hasBinData();
|
|
100
109
|
private get _numBins();
|
|
@@ -20,10 +20,15 @@ const DATE_FORMAT = 'YYYY';
|
|
|
20
20
|
const MISSING_DATA = 'no data';
|
|
21
21
|
const UPDATE_DEBOUNCE_DELAY_MS = 0;
|
|
22
22
|
const TOOLTIP_LABEL = 'item';
|
|
23
|
-
// this function may be overridden only via Lit property expression or direct assignment
|
|
24
|
-
const LOG_BAR_SCALING_FN = (binValue) => Math.log1p(binValue);
|
|
25
23
|
// this constant is not set up to be overridden
|
|
26
24
|
const SLIDER_CORNER_SIZE = 4;
|
|
25
|
+
/**
|
|
26
|
+
* Map from bar scaling preset options to the corresponding function they represent
|
|
27
|
+
*/
|
|
28
|
+
const BAR_SCALING_PRESET_FNS = {
|
|
29
|
+
linear: (binValue) => binValue,
|
|
30
|
+
logarithmic: (binValue) => Math.log1p(binValue),
|
|
31
|
+
};
|
|
27
32
|
// these CSS custom props can be overridden from the HTML that is invoking this component
|
|
28
33
|
const sliderColor = css `var(--histogramDateRangeSliderColor, #4B65FE)`;
|
|
29
34
|
const selectedRangeColor = css `var(--histogramDateRangeSelectedRangeColor, #DBE0FF)`;
|
|
@@ -76,18 +81,20 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
76
81
|
*/
|
|
77
82
|
this.tooltipLabel = TOOLTIP_LABEL;
|
|
78
83
|
/**
|
|
79
|
-
* A function
|
|
80
|
-
*
|
|
84
|
+
* A function or preset value indicating how the height of each bar relates to its
|
|
85
|
+
* corresponding bin value. Current presets available are 'logarithmic' and 'linear',
|
|
86
|
+
* but a custom function may be provided instead if other behavior is desired.
|
|
81
87
|
*
|
|
82
|
-
*
|
|
83
|
-
* bars for smaller values
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
88
|
+
* The default scaling (`'logarithmic'`) uses the logarithm of each bin value, yielding
|
|
89
|
+
* more prominent bars for smaller values. This ensures that even when the difference
|
|
90
|
+
* between the min & max values is large, small values are unlikely to completely disappear
|
|
91
|
+
* visually. However, the cost is that bars have less noticeable variation among values of
|
|
92
|
+
* a similar magnitude, and their heights are not a direct representation of the bin values.
|
|
87
93
|
*
|
|
88
|
-
*
|
|
94
|
+
* The `'linear'` preset option instead sizes the bars in linear proportion to their bin
|
|
95
|
+
* values.
|
|
89
96
|
*/
|
|
90
|
-
this.
|
|
97
|
+
this.barScaling = 'logarithmic';
|
|
91
98
|
// internal reactive properties not exposed as attributes
|
|
92
99
|
this._tooltipOffsetX = 0;
|
|
93
100
|
this._tooltipOffsetY = 0;
|
|
@@ -159,7 +166,8 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
159
166
|
changedProps.has('maxSelectedDate') ||
|
|
160
167
|
changedProps.has('width') ||
|
|
161
168
|
changedProps.has('height') ||
|
|
162
|
-
changedProps.has('binSnapping')
|
|
169
|
+
changedProps.has('binSnapping') ||
|
|
170
|
+
changedProps.has('barScaling')) {
|
|
163
171
|
this.handleDataUpdate();
|
|
164
172
|
}
|
|
165
173
|
}
|
|
@@ -247,6 +255,15 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
247
255
|
return this.snapToNextSecond(timestamp);
|
|
248
256
|
}
|
|
249
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Function to scale bin values, whether from a preset or a provided custom function.
|
|
260
|
+
*/
|
|
261
|
+
get barScalingFunction() {
|
|
262
|
+
if (typeof this.barScaling === 'string') {
|
|
263
|
+
return BAR_SCALING_PRESET_FNS[this.barScaling];
|
|
264
|
+
}
|
|
265
|
+
return this.barScaling;
|
|
266
|
+
}
|
|
250
267
|
calculateHistData() {
|
|
251
268
|
const { bins, height, dateRangeMS, _numBins, _minDateMS } = this;
|
|
252
269
|
const minValue = Math.min(...this.bins);
|
|
@@ -270,8 +287,7 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
270
287
|
: `${tooltipStart} - ${tooltipEnd}`;
|
|
271
288
|
return {
|
|
272
289
|
value: v,
|
|
273
|
-
//
|
|
274
|
-
// making the smaller ones too small to see
|
|
290
|
+
// apply the configured scaling function to the bin value before determining bar height
|
|
275
291
|
height: Math.floor(this.barScalingFunction(v) * valueScale),
|
|
276
292
|
binStart,
|
|
277
293
|
binEnd,
|
|
@@ -1023,8 +1039,8 @@ __decorate([
|
|
|
1023
1039
|
property({ type: String })
|
|
1024
1040
|
], HistogramDateRange.prototype, "tooltipLabel", void 0);
|
|
1025
1041
|
__decorate([
|
|
1026
|
-
property({
|
|
1027
|
-
], HistogramDateRange.prototype, "
|
|
1042
|
+
property({ type: String })
|
|
1043
|
+
], HistogramDateRange.prototype, "barScaling", void 0);
|
|
1028
1044
|
__decorate([
|
|
1029
1045
|
state()
|
|
1030
1046
|
], HistogramDateRange.prototype, "_tooltipOffsetX", void 0);
|