@internetarchive/histogram-date-range 1.4.0-alpha-webdev7756.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +284 -268
- package/dist/src/histogram-date-range.js.map +1 -1
- package/dist/test/histogram-date-range.test.js +174 -156
- 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 +7 -4
- package/package.json +1 -1
- package/src/histogram-date-range.ts +1172 -1152
- package/test/histogram-date-range.test.ts +992 -966
|
@@ -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,
|
|
@@ -416,9 +432,9 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
416
432
|
window.scrollX;
|
|
417
433
|
// Place the tooltip (with arrow) just above the top of the histogram bars
|
|
418
434
|
this._tooltipOffsetY = histogramY - heightAboveHistogram + window.scrollY;
|
|
419
|
-
this._tooltipContent = html `
|
|
420
|
-
${formattedNumItems} ${itemsText}<br />
|
|
421
|
-
${dataset.tooltip}
|
|
435
|
+
this._tooltipContent = html `
|
|
436
|
+
${formattedNumItems} ${itemsText}<br />
|
|
437
|
+
${dataset.tooltip}
|
|
422
438
|
`;
|
|
423
439
|
(_b = (_a = this._tooltip).showPopover) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
424
440
|
}
|
|
@@ -615,25 +631,25 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
615
631
|
// border-radius); used as part of a SVG quadratic curve. see
|
|
616
632
|
// https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#curve_commands
|
|
617
633
|
const cs = SLIDER_CORNER_SIZE;
|
|
618
|
-
const sliderShape = `
|
|
619
|
-
M${this.minSliderX},0
|
|
620
|
-
h-${this.sliderWidth - cs}
|
|
621
|
-
q-${cs},0 -${cs},${cs}
|
|
622
|
-
v${this.height - cs * 2}
|
|
623
|
-
q0,${cs} ${cs},${cs}
|
|
624
|
-
h${this.sliderWidth - cs}
|
|
634
|
+
const sliderShape = `
|
|
635
|
+
M${this.minSliderX},0
|
|
636
|
+
h-${this.sliderWidth - cs}
|
|
637
|
+
q-${cs},0 -${cs},${cs}
|
|
638
|
+
v${this.height - cs * 2}
|
|
639
|
+
q0,${cs} ${cs},${cs}
|
|
640
|
+
h${this.sliderWidth - cs}
|
|
625
641
|
`;
|
|
626
642
|
return this.generateSliderSVG(this.minSliderX, 'slider-min', sliderShape);
|
|
627
643
|
}
|
|
628
644
|
get maxSliderTemplate() {
|
|
629
645
|
const cs = SLIDER_CORNER_SIZE;
|
|
630
|
-
const sliderShape = `
|
|
631
|
-
M${this.maxSliderX},0
|
|
632
|
-
h${this.sliderWidth - cs}
|
|
633
|
-
q${cs},0 ${cs},${cs}
|
|
634
|
-
v${this.height - cs * 2}
|
|
635
|
-
q0,${cs} -${cs},${cs}
|
|
636
|
-
h-${this.sliderWidth - cs}
|
|
646
|
+
const sliderShape = `
|
|
647
|
+
M${this.maxSliderX},0
|
|
648
|
+
h${this.sliderWidth - cs}
|
|
649
|
+
q${cs},0 ${cs},${cs}
|
|
650
|
+
v${this.height - cs * 2}
|
|
651
|
+
q0,${cs} -${cs},${cs}
|
|
652
|
+
h-${this.sliderWidth - cs}
|
|
637
653
|
`;
|
|
638
654
|
return this.generateSliderSVG(this.maxSliderX, 'slider-max', sliderShape);
|
|
639
655
|
}
|
|
@@ -646,38 +662,38 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
646
662
|
draggable: !this.disabled,
|
|
647
663
|
dragging: this._isDragging,
|
|
648
664
|
});
|
|
649
|
-
return svg `
|
|
650
|
-
<svg
|
|
651
|
-
id=${id}
|
|
652
|
-
class=${sliderClasses}
|
|
653
|
-
@pointerdown=${this.drag}
|
|
654
|
-
>
|
|
655
|
-
<path d="${sliderShape} z" fill="${sliderColor}" />
|
|
656
|
-
<rect
|
|
657
|
-
x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k}"
|
|
658
|
-
y="${this.height / 3}"
|
|
659
|
-
width="1"
|
|
660
|
-
height="${this.height / 3}"
|
|
661
|
-
fill="white"
|
|
662
|
-
/>
|
|
663
|
-
<rect
|
|
664
|
-
x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k}"
|
|
665
|
-
y="${this.height / 3}"
|
|
666
|
-
width="1"
|
|
667
|
-
height="${this.height / 3}"
|
|
668
|
-
fill="white"
|
|
669
|
-
/>
|
|
670
|
-
</svg>
|
|
665
|
+
return svg `
|
|
666
|
+
<svg
|
|
667
|
+
id=${id}
|
|
668
|
+
class=${sliderClasses}
|
|
669
|
+
@pointerdown=${this.drag}
|
|
670
|
+
>
|
|
671
|
+
<path d="${sliderShape} z" fill="${sliderColor}" />
|
|
672
|
+
<rect
|
|
673
|
+
x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k}"
|
|
674
|
+
y="${this.height / 3}"
|
|
675
|
+
width="1"
|
|
676
|
+
height="${this.height / 3}"
|
|
677
|
+
fill="white"
|
|
678
|
+
/>
|
|
679
|
+
<rect
|
|
680
|
+
x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k}"
|
|
681
|
+
y="${this.height / 3}"
|
|
682
|
+
width="1"
|
|
683
|
+
height="${this.height / 3}"
|
|
684
|
+
fill="white"
|
|
685
|
+
/>
|
|
686
|
+
</svg>
|
|
671
687
|
`;
|
|
672
688
|
}
|
|
673
689
|
get selectedRangeTemplate() {
|
|
674
|
-
return svg `
|
|
675
|
-
<rect
|
|
676
|
-
x="${this.minSliderX}"
|
|
677
|
-
y="0"
|
|
678
|
-
width="${this.maxSliderX - this.minSliderX}"
|
|
679
|
-
height="${this.height}"
|
|
680
|
-
fill="${selectedRangeColor}"
|
|
690
|
+
return svg `
|
|
691
|
+
<rect
|
|
692
|
+
x="${this.minSliderX}"
|
|
693
|
+
y="0"
|
|
694
|
+
width="${this.maxSliderX - this.minSliderX}"
|
|
695
|
+
height="${this.height}"
|
|
696
|
+
fill="${selectedRangeColor}"
|
|
681
697
|
/>`;
|
|
682
698
|
}
|
|
683
699
|
get histogramTemplate() {
|
|
@@ -695,30 +711,30 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
695
711
|
// between adjacent bars (eg when viewing the tooltips or when trying to
|
|
696
712
|
// extend the range by clicking on a bar)
|
|
697
713
|
const barStyle = `stroke-dasharray: 0 ${barWidth} ${barHeight} ${barWidth} 0 ${barHeight}`;
|
|
698
|
-
const bar = svg `
|
|
699
|
-
<rect
|
|
700
|
-
class="bar-pointer-target"
|
|
701
|
-
x=${x}
|
|
702
|
-
y="0"
|
|
703
|
-
width=${barWidth}
|
|
704
|
-
height=${this.height}
|
|
705
|
-
@pointerenter=${this.showTooltip}
|
|
706
|
-
@pointerleave=${this.hideTooltip}
|
|
707
|
-
@click=${this.handleBarClick}
|
|
708
|
-
fill="transparent"
|
|
709
|
-
data-num-items=${data.value}
|
|
710
|
-
data-bin-start=${data.binStart}
|
|
711
|
-
data-bin-end=${data.binEnd}
|
|
712
|
-
data-tooltip=${data.tooltip}
|
|
713
|
-
/>
|
|
714
|
-
<rect
|
|
715
|
-
class="bar"
|
|
716
|
-
style=${barStyle}
|
|
717
|
-
x=${x}
|
|
718
|
-
y=${this.height - barHeight}
|
|
719
|
-
width=${barWidth}
|
|
720
|
-
height=${barHeight}
|
|
721
|
-
fill=${barFill}
|
|
714
|
+
const bar = svg `
|
|
715
|
+
<rect
|
|
716
|
+
class="bar-pointer-target"
|
|
717
|
+
x=${x}
|
|
718
|
+
y="0"
|
|
719
|
+
width=${barWidth}
|
|
720
|
+
height=${this.height}
|
|
721
|
+
@pointerenter=${this.showTooltip}
|
|
722
|
+
@pointerleave=${this.hideTooltip}
|
|
723
|
+
@click=${this.handleBarClick}
|
|
724
|
+
fill="transparent"
|
|
725
|
+
data-num-items=${data.value}
|
|
726
|
+
data-bin-start=${data.binStart}
|
|
727
|
+
data-bin-end=${data.binEnd}
|
|
728
|
+
data-tooltip=${data.tooltip}
|
|
729
|
+
/>
|
|
730
|
+
<rect
|
|
731
|
+
class="bar"
|
|
732
|
+
style=${barStyle}
|
|
733
|
+
x=${x}
|
|
734
|
+
y=${this.height - barHeight}
|
|
735
|
+
width=${barWidth}
|
|
736
|
+
height=${barHeight}
|
|
737
|
+
fill=${barFill}
|
|
722
738
|
/>`;
|
|
723
739
|
x += xScale;
|
|
724
740
|
return bar;
|
|
@@ -758,31 +774,31 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
758
774
|
* https://lit.dev/docs/templates/directives/#live
|
|
759
775
|
*/
|
|
760
776
|
get minInputTemplate() {
|
|
761
|
-
return html `
|
|
762
|
-
<input
|
|
763
|
-
id="date-min"
|
|
764
|
-
placeholder=${this.dateFormat}
|
|
765
|
-
type="text"
|
|
766
|
-
@focus=${this.handleInputFocus}
|
|
767
|
-
@blur=${this.handleMinDateInput}
|
|
768
|
-
@keyup=${this.handleKeyUp}
|
|
769
|
-
.value=${live(this.minSelectedDate)}
|
|
770
|
-
?disabled=${this.disabled}
|
|
771
|
-
/>
|
|
777
|
+
return html `
|
|
778
|
+
<input
|
|
779
|
+
id="date-min"
|
|
780
|
+
placeholder=${this.dateFormat}
|
|
781
|
+
type="text"
|
|
782
|
+
@focus=${this.handleInputFocus}
|
|
783
|
+
@blur=${this.handleMinDateInput}
|
|
784
|
+
@keyup=${this.handleKeyUp}
|
|
785
|
+
.value=${live(this.minSelectedDate)}
|
|
786
|
+
?disabled=${this.disabled}
|
|
787
|
+
/>
|
|
772
788
|
`;
|
|
773
789
|
}
|
|
774
790
|
get maxInputTemplate() {
|
|
775
|
-
return html `
|
|
776
|
-
<input
|
|
777
|
-
id="date-max"
|
|
778
|
-
placeholder=${this.dateFormat}
|
|
779
|
-
type="text"
|
|
780
|
-
@focus=${this.handleInputFocus}
|
|
781
|
-
@blur=${this.handleMaxDateInput}
|
|
782
|
-
@keyup=${this.handleKeyUp}
|
|
783
|
-
.value=${live(this.maxSelectedDate)}
|
|
784
|
-
?disabled=${this.disabled}
|
|
785
|
-
/>
|
|
791
|
+
return html `
|
|
792
|
+
<input
|
|
793
|
+
id="date-max"
|
|
794
|
+
placeholder=${this.dateFormat}
|
|
795
|
+
type="text"
|
|
796
|
+
@focus=${this.handleInputFocus}
|
|
797
|
+
@blur=${this.handleMaxDateInput}
|
|
798
|
+
@keyup=${this.handleKeyUp}
|
|
799
|
+
.value=${live(this.maxSelectedDate)}
|
|
800
|
+
?disabled=${this.disabled}
|
|
801
|
+
/>
|
|
786
802
|
`;
|
|
787
803
|
}
|
|
788
804
|
get minLabelTemplate() {
|
|
@@ -798,184 +814,184 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
|
|
|
798
814
|
top: `${this._tooltipOffsetY}px`,
|
|
799
815
|
left: `${this._tooltipOffsetX}px`,
|
|
800
816
|
});
|
|
801
|
-
return html `
|
|
802
|
-
<div id="tooltip" style=${styles} popover>${this._tooltipContent}</div>
|
|
817
|
+
return html `
|
|
818
|
+
<div id="tooltip" style=${styles} popover>${this._tooltipContent}</div>
|
|
803
819
|
`;
|
|
804
820
|
}
|
|
805
821
|
get noDataTemplate() {
|
|
806
|
-
return html `
|
|
807
|
-
<div class="missing-data-message">${this.missingDataMessage}</div>
|
|
822
|
+
return html `
|
|
823
|
+
<div class="missing-data-message">${this.missingDataMessage}</div>
|
|
808
824
|
`;
|
|
809
825
|
}
|
|
810
826
|
get activityIndicatorTemplate() {
|
|
811
827
|
if (!this.loading) {
|
|
812
828
|
return nothing;
|
|
813
829
|
}
|
|
814
|
-
return html `
|
|
815
|
-
<ia-activity-indicator mode="processing"> </ia-activity-indicator>
|
|
830
|
+
return html `
|
|
831
|
+
<ia-activity-indicator mode="processing"> </ia-activity-indicator>
|
|
816
832
|
`;
|
|
817
833
|
}
|
|
818
834
|
render() {
|
|
819
835
|
if (!this.hasBinData) {
|
|
820
836
|
return this.noDataTemplate;
|
|
821
837
|
}
|
|
822
|
-
return html `
|
|
823
|
-
<div
|
|
824
|
-
id="container"
|
|
825
|
-
class="
|
|
826
|
-
noselect
|
|
827
|
-
${this._isDragging ? 'dragging' : ''}
|
|
828
|
-
"
|
|
829
|
-
style="width: ${this.width}px"
|
|
830
|
-
>
|
|
831
|
-
${this.activityIndicatorTemplate} ${this.tooltipTemplate}
|
|
832
|
-
<div
|
|
833
|
-
class="inner-container
|
|
834
|
-
${this.disabled ? 'disabled' : ''}"
|
|
835
|
-
>
|
|
836
|
-
<svg
|
|
837
|
-
width="${this.width}"
|
|
838
|
-
height="${this.height}"
|
|
839
|
-
@pointerleave="${this.drop}"
|
|
840
|
-
>
|
|
841
|
-
${this.selectedRangeTemplate}
|
|
842
|
-
<svg id="histogram">${this.histogramTemplate}</svg>
|
|
843
|
-
${this.minSliderTemplate} ${this.maxSliderTemplate}
|
|
844
|
-
</svg>
|
|
845
|
-
<div id="inputs">
|
|
846
|
-
${this.minLabelTemplate} ${this.minInputTemplate}
|
|
847
|
-
<div class="dash">-</div>
|
|
848
|
-
${this.maxLabelTemplate} ${this.maxInputTemplate}
|
|
849
|
-
<slot name="inputs-right-side"></slot>
|
|
850
|
-
</div>
|
|
851
|
-
</div>
|
|
852
|
-
</div>
|
|
838
|
+
return html `
|
|
839
|
+
<div
|
|
840
|
+
id="container"
|
|
841
|
+
class="
|
|
842
|
+
noselect
|
|
843
|
+
${this._isDragging ? 'dragging' : ''}
|
|
844
|
+
"
|
|
845
|
+
style="width: ${this.width}px"
|
|
846
|
+
>
|
|
847
|
+
${this.activityIndicatorTemplate} ${this.tooltipTemplate}
|
|
848
|
+
<div
|
|
849
|
+
class="inner-container
|
|
850
|
+
${this.disabled ? 'disabled' : ''}"
|
|
851
|
+
>
|
|
852
|
+
<svg
|
|
853
|
+
width="${this.width}"
|
|
854
|
+
height="${this.height}"
|
|
855
|
+
@pointerleave="${this.drop}"
|
|
856
|
+
>
|
|
857
|
+
${this.selectedRangeTemplate}
|
|
858
|
+
<svg id="histogram">${this.histogramTemplate}</svg>
|
|
859
|
+
${this.minSliderTemplate} ${this.maxSliderTemplate}
|
|
860
|
+
</svg>
|
|
861
|
+
<div id="inputs">
|
|
862
|
+
${this.minLabelTemplate} ${this.minInputTemplate}
|
|
863
|
+
<div class="dash">-</div>
|
|
864
|
+
${this.maxLabelTemplate} ${this.maxInputTemplate}
|
|
865
|
+
<slot name="inputs-right-side"></slot>
|
|
866
|
+
</div>
|
|
867
|
+
</div>
|
|
868
|
+
</div>
|
|
853
869
|
`;
|
|
854
870
|
}
|
|
855
871
|
};
|
|
856
|
-
HistogramDateRange.styles = css `
|
|
857
|
-
.missing-data-message {
|
|
858
|
-
text-align: center;
|
|
859
|
-
}
|
|
860
|
-
#container {
|
|
861
|
-
margin: 0;
|
|
862
|
-
touch-action: none;
|
|
863
|
-
position: relative;
|
|
864
|
-
}
|
|
865
|
-
.disabled {
|
|
866
|
-
opacity: 0.3;
|
|
867
|
-
}
|
|
868
|
-
ia-activity-indicator {
|
|
869
|
-
position: absolute;
|
|
870
|
-
left: calc(50% - 10px);
|
|
871
|
-
top: 10px;
|
|
872
|
-
width: 20px;
|
|
873
|
-
height: 20px;
|
|
874
|
-
--activityIndicatorLoadingDotColor: rgba(0, 0, 0, 0);
|
|
875
|
-
--activityIndicatorLoadingRingColor: ${activityIndicatorColor};
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
/* prevent selection from interfering with tooltip, especially on mobile */
|
|
879
|
-
/* https://stackoverflow.com/a/4407335/1163042 */
|
|
880
|
-
.noselect {
|
|
881
|
-
-webkit-touch-callout: none; /* iOS Safari */
|
|
882
|
-
-webkit-user-select: none; /* Safari */
|
|
883
|
-
-moz-user-select: none; /* Old versions of Firefox */
|
|
884
|
-
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
885
|
-
user-select: none; /* current Chrome, Edge, Opera and Firefox */
|
|
886
|
-
}
|
|
887
|
-
.bar,
|
|
888
|
-
.bar-pointer-target {
|
|
889
|
-
/* create a transparent border around the hist bars to prevent "gaps" and
|
|
890
|
-
flickering when moving around between bars. this also helps with handling
|
|
891
|
-
clicks on the bars, preventing users from being able to click in between
|
|
892
|
-
bars */
|
|
893
|
-
stroke: rgba(0, 0, 0, 0);
|
|
894
|
-
/* ensure transparent stroke wide enough to cover gap between bars */
|
|
895
|
-
stroke-width: 2px;
|
|
896
|
-
}
|
|
897
|
-
.bar {
|
|
898
|
-
/* ensure the bar's pointer target receives events, not the bar itself */
|
|
899
|
-
pointer-events: none;
|
|
900
|
-
}
|
|
901
|
-
.bar-pointer-target:hover + .bar {
|
|
902
|
-
/* highlight currently hovered bar */
|
|
903
|
-
fill-opacity: 0.7;
|
|
904
|
-
}
|
|
905
|
-
.disabled .bar-pointer-target:hover + .bar {
|
|
906
|
-
/* ensure no visual hover interaction when disabled */
|
|
907
|
-
fill-opacity: 1;
|
|
908
|
-
}
|
|
909
|
-
/****** histogram ********/
|
|
910
|
-
#tooltip {
|
|
911
|
-
position: absolute;
|
|
912
|
-
background: ${tooltipBackgroundColor};
|
|
913
|
-
margin: 0;
|
|
914
|
-
border: 0;
|
|
915
|
-
color: ${tooltipTextColor};
|
|
916
|
-
text-align: center;
|
|
917
|
-
border-radius: 3px;
|
|
918
|
-
padding: 2px;
|
|
919
|
-
font-size: ${tooltipFontSize};
|
|
920
|
-
font-family: ${tooltipFontFamily};
|
|
921
|
-
touch-action: none;
|
|
922
|
-
pointer-events: none;
|
|
923
|
-
overflow: visible;
|
|
924
|
-
}
|
|
925
|
-
#tooltip:after {
|
|
926
|
-
content: '';
|
|
927
|
-
position: absolute;
|
|
928
|
-
margin-left: -5px;
|
|
929
|
-
top: 100%;
|
|
930
|
-
left: 50%;
|
|
931
|
-
/* arrow */
|
|
932
|
-
border: 5px solid ${tooltipTextColor};
|
|
933
|
-
border-color: ${tooltipBackgroundColor} transparent transparent
|
|
934
|
-
transparent;
|
|
935
|
-
}
|
|
936
|
-
/****** slider ********/
|
|
937
|
-
.slider {
|
|
938
|
-
shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */
|
|
939
|
-
}
|
|
940
|
-
.draggable:hover {
|
|
941
|
-
cursor: grab;
|
|
942
|
-
}
|
|
943
|
-
.dragging {
|
|
944
|
-
cursor: grabbing !important;
|
|
945
|
-
}
|
|
946
|
-
/****** inputs ********/
|
|
947
|
-
#inputs {
|
|
948
|
-
display: flex;
|
|
949
|
-
justify-content: center;
|
|
950
|
-
margin: ${inputRowMargin};
|
|
951
|
-
}
|
|
952
|
-
#inputs .dash {
|
|
953
|
-
position: relative;
|
|
954
|
-
bottom: -1px;
|
|
955
|
-
align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */
|
|
956
|
-
}
|
|
957
|
-
input {
|
|
958
|
-
width: ${inputWidth};
|
|
959
|
-
margin: 0 3px;
|
|
960
|
-
border: ${inputBorder};
|
|
961
|
-
border-radius: 2px !important;
|
|
962
|
-
text-align: center;
|
|
963
|
-
font-size: ${inputFontSize};
|
|
964
|
-
font-family: ${inputFontFamily};
|
|
965
|
-
}
|
|
966
|
-
.sr-only {
|
|
967
|
-
position: absolute !important;
|
|
968
|
-
width: 1px !important;
|
|
969
|
-
height: 1px !important;
|
|
970
|
-
margin: 0 !important;
|
|
971
|
-
padding: 0 !important;
|
|
972
|
-
border: 0 !important;
|
|
973
|
-
overflow: hidden !important;
|
|
974
|
-
white-space: nowrap !important;
|
|
975
|
-
clip: rect(1px, 1px, 1px, 1px) !important;
|
|
976
|
-
-webkit-clip-path: inset(50%) !important;
|
|
977
|
-
clip-path: inset(50%) !important;
|
|
978
|
-
}
|
|
872
|
+
HistogramDateRange.styles = css `
|
|
873
|
+
.missing-data-message {
|
|
874
|
+
text-align: center;
|
|
875
|
+
}
|
|
876
|
+
#container {
|
|
877
|
+
margin: 0;
|
|
878
|
+
touch-action: none;
|
|
879
|
+
position: relative;
|
|
880
|
+
}
|
|
881
|
+
.disabled {
|
|
882
|
+
opacity: 0.3;
|
|
883
|
+
}
|
|
884
|
+
ia-activity-indicator {
|
|
885
|
+
position: absolute;
|
|
886
|
+
left: calc(50% - 10px);
|
|
887
|
+
top: 10px;
|
|
888
|
+
width: 20px;
|
|
889
|
+
height: 20px;
|
|
890
|
+
--activityIndicatorLoadingDotColor: rgba(0, 0, 0, 0);
|
|
891
|
+
--activityIndicatorLoadingRingColor: ${activityIndicatorColor};
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
/* prevent selection from interfering with tooltip, especially on mobile */
|
|
895
|
+
/* https://stackoverflow.com/a/4407335/1163042 */
|
|
896
|
+
.noselect {
|
|
897
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
898
|
+
-webkit-user-select: none; /* Safari */
|
|
899
|
+
-moz-user-select: none; /* Old versions of Firefox */
|
|
900
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
901
|
+
user-select: none; /* current Chrome, Edge, Opera and Firefox */
|
|
902
|
+
}
|
|
903
|
+
.bar,
|
|
904
|
+
.bar-pointer-target {
|
|
905
|
+
/* create a transparent border around the hist bars to prevent "gaps" and
|
|
906
|
+
flickering when moving around between bars. this also helps with handling
|
|
907
|
+
clicks on the bars, preventing users from being able to click in between
|
|
908
|
+
bars */
|
|
909
|
+
stroke: rgba(0, 0, 0, 0);
|
|
910
|
+
/* ensure transparent stroke wide enough to cover gap between bars */
|
|
911
|
+
stroke-width: 2px;
|
|
912
|
+
}
|
|
913
|
+
.bar {
|
|
914
|
+
/* ensure the bar's pointer target receives events, not the bar itself */
|
|
915
|
+
pointer-events: none;
|
|
916
|
+
}
|
|
917
|
+
.bar-pointer-target:hover + .bar {
|
|
918
|
+
/* highlight currently hovered bar */
|
|
919
|
+
fill-opacity: 0.7;
|
|
920
|
+
}
|
|
921
|
+
.disabled .bar-pointer-target:hover + .bar {
|
|
922
|
+
/* ensure no visual hover interaction when disabled */
|
|
923
|
+
fill-opacity: 1;
|
|
924
|
+
}
|
|
925
|
+
/****** histogram ********/
|
|
926
|
+
#tooltip {
|
|
927
|
+
position: absolute;
|
|
928
|
+
background: ${tooltipBackgroundColor};
|
|
929
|
+
margin: 0;
|
|
930
|
+
border: 0;
|
|
931
|
+
color: ${tooltipTextColor};
|
|
932
|
+
text-align: center;
|
|
933
|
+
border-radius: 3px;
|
|
934
|
+
padding: 2px;
|
|
935
|
+
font-size: ${tooltipFontSize};
|
|
936
|
+
font-family: ${tooltipFontFamily};
|
|
937
|
+
touch-action: none;
|
|
938
|
+
pointer-events: none;
|
|
939
|
+
overflow: visible;
|
|
940
|
+
}
|
|
941
|
+
#tooltip:after {
|
|
942
|
+
content: '';
|
|
943
|
+
position: absolute;
|
|
944
|
+
margin-left: -5px;
|
|
945
|
+
top: 100%;
|
|
946
|
+
left: 50%;
|
|
947
|
+
/* arrow */
|
|
948
|
+
border: 5px solid ${tooltipTextColor};
|
|
949
|
+
border-color: ${tooltipBackgroundColor} transparent transparent
|
|
950
|
+
transparent;
|
|
951
|
+
}
|
|
952
|
+
/****** slider ********/
|
|
953
|
+
.slider {
|
|
954
|
+
shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */
|
|
955
|
+
}
|
|
956
|
+
.draggable:hover {
|
|
957
|
+
cursor: grab;
|
|
958
|
+
}
|
|
959
|
+
.dragging {
|
|
960
|
+
cursor: grabbing !important;
|
|
961
|
+
}
|
|
962
|
+
/****** inputs ********/
|
|
963
|
+
#inputs {
|
|
964
|
+
display: flex;
|
|
965
|
+
justify-content: center;
|
|
966
|
+
margin: ${inputRowMargin};
|
|
967
|
+
}
|
|
968
|
+
#inputs .dash {
|
|
969
|
+
position: relative;
|
|
970
|
+
bottom: -1px;
|
|
971
|
+
align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */
|
|
972
|
+
}
|
|
973
|
+
input {
|
|
974
|
+
width: ${inputWidth};
|
|
975
|
+
margin: 0 3px;
|
|
976
|
+
border: ${inputBorder};
|
|
977
|
+
border-radius: 2px !important;
|
|
978
|
+
text-align: center;
|
|
979
|
+
font-size: ${inputFontSize};
|
|
980
|
+
font-family: ${inputFontFamily};
|
|
981
|
+
}
|
|
982
|
+
.sr-only {
|
|
983
|
+
position: absolute !important;
|
|
984
|
+
width: 1px !important;
|
|
985
|
+
height: 1px !important;
|
|
986
|
+
margin: 0 !important;
|
|
987
|
+
padding: 0 !important;
|
|
988
|
+
border: 0 !important;
|
|
989
|
+
overflow: hidden !important;
|
|
990
|
+
white-space: nowrap !important;
|
|
991
|
+
clip: rect(1px, 1px, 1px, 1px) !important;
|
|
992
|
+
-webkit-clip-path: inset(50%) !important;
|
|
993
|
+
clip-path: inset(50%) !important;
|
|
994
|
+
}
|
|
979
995
|
`;
|
|
980
996
|
__decorate([
|
|
981
997
|
property({ type: Number })
|
|
@@ -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);
|