@internetarchive/histogram-date-range 1.4.0-alpha-webdev7756.1 → 1.4.1-alpha1

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 CHANGED
@@ -1,221 +1,221 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta name="viewport" content="width=device-width, initial-scale=1" />
5
- <meta charset="utf-8" />
6
- <link rel="stylesheet" href="index.css">
7
- </head>
8
-
9
- <script type="module">
10
- import '../dist/src/histogram-date-range.js';
11
- let eventCount = 0;
12
- import '../dist/demo/js/app-root.js';
13
- // listen to events from the component and display the data received from them
14
- document.addEventListener('histogramDateRangeUpdated', e => {
15
- document.querySelector('.received-events').innerHTML =
16
- ++eventCount + ': ' + JSON.stringify(e.detail);
17
- });
18
- </script>
19
- <body>
20
- <pre class="received-events"></pre>
21
- <div class="container">
22
- <div class="description">
23
- histogram inside a lit element
24
- </div>
25
- <app-root></app-root>
26
-
27
- <div class="description">
28
- pre-selected range with 1000ms debounce delay
29
- </div>
30
- <histogram-date-range
31
- minDate="1400"
32
- maxDate="2021"
33
- updateDelay="1000"
34
- minSelectedDate="1800"
35
- maxSelectedDate="1900"
36
- bins="[ 74, 67, 17, 66, 49, 93, 47, 61, 32, 46, 53, 2,
37
- 13, 45, 28, 1, 8, 70, 37, 74, 67, 17, 66, 49, 93,
38
- 47, 61, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32,
39
- 32, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32
40
- ]"
41
- ></histogram-date-range>
42
- </div>
43
-
44
- <div class="container">
45
- <div class="description">range spanning negative to positive years</div>
46
- <histogram-date-range
47
- minDate="-1050" maxDate="2200"
48
- bins="[ 74, 67, 17, 66, 49, 93, 47, 61, 32, 46, 53, 2,
49
- 13, 45, 28, 1, 8, 70, 37, 74, 67, 17, 66, 49, 93,
50
- 47, 61, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32,
51
- 32, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32
52
- ]"
53
- ></histogram-date-range>
54
- </div>
55
-
56
- <div class="container">
57
- <div class="description">
58
- small diff between max and min values
59
- </div>
60
- <histogram-date-range
61
- width="175"
62
- tooltipwidth="120"
63
- dateFormat="YYYY"
64
- updateDelay="1000"
65
- missingDataMessage="..."
66
- minSelectedDate="1987"
67
- maxSelectedDate="2016"
68
- minDate="1987"
69
- maxDate="2016"
70
- 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]"
71
- >
72
- </histogram-date-range>
73
- </div>
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
-
95
- <div class="container">
96
- <div class="description">small year range and few bins</div>
97
- <histogram-date-range width="175" tooltipwidth="120"
98
- minDate="2008" maxDate="2016" bins="[76104,866978,1151617,986331,218672,107410,3324]">
99
- </histogram-date-range>
100
- </div>
101
-
102
- <div class="container">
103
- <div class="description">bins snapped to nearest month</div>
104
- <histogram-date-range
105
- width="175"
106
- tooltipwidth="120"
107
- dateFormat="YYYY-MM"
108
- tooltipDateFormat="MMM YYYY"
109
- binSnapping="month"
110
- minDate="2009-05"
111
- maxDate="2014-08"
112
- bins="[100,5000,2000,100,5000,2000,100,5000,2000,100,5000,2000,100,5000,2000,100]"
113
- style="--histogramDateRangeInputWidth: 50px;"
114
- ></histogram-date-range>
115
- </div>
116
-
117
- <div class="container">
118
- <div class="description">bins snapped to nearest year</div>
119
- <histogram-date-range
120
- width="175"
121
- dateFormat="YYYY"
122
- binSnapping="year"
123
- minDate="2009"
124
- maxDate="2018"
125
- bins="[100,1000,10000,100,1000,10000,100,1000,10000,100]"
126
- ></histogram-date-range>
127
- </div>
128
-
129
- <div class="container">
130
- <div class="clipped text-centered">
131
- <div class="description">inside clipping container</div>
132
- <histogram-date-range
133
- width="175"
134
- dateFormat="MM/YYYY"
135
- binSnapping="month"
136
- minDate="01/2000"
137
- maxDate="12/2005"
138
- bins="[1,12,2,11,3,10,4,9,5,8,6,7]"
139
- style="--histogramDateRangeInputWidth: 50px;"
140
- ></histogram-date-range>
141
- </div>
142
- </div>
143
-
144
- <div class="container">
145
- <div class="description">
146
- default range with custom styling and date format
147
- </div>
148
- <histogram-date-range
149
- width="300"
150
- height="50"
151
- tooltipWidth="140"
152
- dateFormat="DD MMM YYYY"
153
- style="
154
- --histogramDateRangeSliderColor: #d8b384;
155
- --histogramDateRangeSelectedRangeColor: #f3f0d7;
156
- --histogramDateRangeTooltipFontFamily: serif;
157
- --histogramDateRangeInputFontFamily: serif;
158
- --histogramDateRangeTooltipFontSize: 1rem;
159
- --histogramDateRangeInputWidth: 85px;
160
- "
161
- minDate="05 May 1972"
162
- maxDate="21 Dec 1980"
163
- bins="[ 85, 25, 200, 0, 0, 34, 0, 2, 5, 10, 0, 56, 10, 45, 100, 70, 50 ]"
164
- ></histogram-date-range>
165
- </div>
166
-
167
- <div class="container">
168
- <div class="description">loading state toggle</div>
169
- <histogram-date-range
170
- id="loading"
171
- minDate="1900"
172
- maxDate="2021"
173
- bins="[
174
- 74, 67, 17, 66, 49, 93, 47, 61, 32, 46, 53, 2, 13, 45, 67, 17, 66,
175
- 49, 93, 47, 61, 32, 32, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32
176
- ]"
177
- ></histogram-date-range>
178
- <button id="loading-toggle">toggle loading</button>
179
- </div>
180
- <script>
181
- document
182
- .querySelector('#loading-toggle')
183
- .addEventListener('click', () => {
184
- const histogram = document.querySelector(
185
- 'histogram-date-range#loading'
186
- );
187
- histogram.loading = !histogram.loading;
188
- });
189
- </script>
190
-
191
- <div class="container">
192
- <div class="description">data set up with js</div>
193
- <histogram-date-range id="js-setup"></histogram-date-range>
194
- </div>
195
- <script>
196
- document.addEventListener('DOMContentLoaded', function () {
197
- const histogram = document.querySelector(
198
- 'histogram-date-range#js-setup'
199
- );
200
- histogram.minDate = '1950';
201
- histogram.maxDate = '2000';
202
- // generate array of [0, 1, 2, ... 49]
203
- histogram.bins = [...Array(50).keys()];
204
- });
205
- </script>
206
-
207
- <div class="container">
208
- <div class="description">
209
- single bin
210
- </div>
211
- <histogram-date-range minDate="1926" maxDate="1926" bins="[8]">
212
- </histogram-date-range>
213
- </div>
214
-
215
- <div class="container">
216
- <div class="description">empty data</div>
217
- <histogram-date-range missingDataMessage="no data..."></histoghistogram-date-range>
218
- </div>
219
-
220
- </body>
221
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
5
+ <meta charset="utf-8" />
6
+ <link rel="stylesheet" href="index.css">
7
+ </head>
8
+
9
+ <script type="module">
10
+ import '../dist/src/histogram-date-range.js';
11
+ let eventCount = 0;
12
+ import '../dist/demo/js/app-root.js';
13
+ // listen to events from the component and display the data received from them
14
+ document.addEventListener('histogramDateRangeUpdated', e => {
15
+ document.querySelector('.received-events').innerHTML =
16
+ ++eventCount + ': ' + JSON.stringify(e.detail);
17
+ });
18
+ </script>
19
+ <body>
20
+ <pre class="received-events"></pre>
21
+ <div class="container">
22
+ <div class="description">
23
+ histogram inside a lit element
24
+ </div>
25
+ <app-root></app-root>
26
+
27
+ <div class="description">
28
+ pre-selected range with 1000ms debounce delay
29
+ </div>
30
+ <histogram-date-range
31
+ minDate="1400"
32
+ maxDate="2021"
33
+ updateDelay="1000"
34
+ minSelectedDate="1800"
35
+ maxSelectedDate="1900"
36
+ bins="[ 74, 67, 17, 66, 49, 93, 47, 61, 32, 46, 53, 2,
37
+ 13, 45, 28, 1, 8, 70, 37, 74, 67, 17, 66, 49, 93,
38
+ 47, 61, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32,
39
+ 32, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32
40
+ ]"
41
+ ></histogram-date-range>
42
+ </div>
43
+
44
+ <div class="container">
45
+ <div class="description">range spanning negative to positive years</div>
46
+ <histogram-date-range
47
+ minDate="-1050" maxDate="2200"
48
+ bins="[ 74, 67, 17, 66, 49, 93, 47, 61, 32, 46, 53, 2,
49
+ 13, 45, 28, 1, 8, 70, 37, 74, 67, 17, 66, 49, 93,
50
+ 47, 61, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32,
51
+ 32, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32
52
+ ]"
53
+ ></histogram-date-range>
54
+ </div>
55
+
56
+ <div class="container">
57
+ <div class="description">
58
+ small diff between max and min values
59
+ </div>
60
+ <histogram-date-range
61
+ width="175"
62
+ tooltipwidth="120"
63
+ dateFormat="YYYY"
64
+ updateDelay="1000"
65
+ missingDataMessage="..."
66
+ minSelectedDate="1987"
67
+ maxSelectedDate="2016"
68
+ minDate="1987"
69
+ maxDate="2016"
70
+ 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]"
71
+ >
72
+ </histogram-date-range>
73
+ </div>
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
+
95
+ <div class="container">
96
+ <div class="description">small year range and few bins</div>
97
+ <histogram-date-range width="175" tooltipwidth="120"
98
+ minDate="2008" maxDate="2016" bins="[76104,866978,1151617,986331,218672,107410,3324]">
99
+ </histogram-date-range>
100
+ </div>
101
+
102
+ <div class="container">
103
+ <div class="description">bins snapped to nearest month</div>
104
+ <histogram-date-range
105
+ width="175"
106
+ tooltipwidth="120"
107
+ dateFormat="YYYY-MM"
108
+ tooltipDateFormat="MMM YYYY"
109
+ binSnapping="month"
110
+ minDate="2009-05"
111
+ maxDate="2014-08"
112
+ bins="[100,5000,2000,100,5000,2000,100,5000,2000,100,5000,2000,100,5000,2000,100]"
113
+ style="--histogramDateRangeInputWidth: 50px;"
114
+ ></histogram-date-range>
115
+ </div>
116
+
117
+ <div class="container">
118
+ <div class="description">bins snapped to nearest year</div>
119
+ <histogram-date-range
120
+ width="175"
121
+ dateFormat="YYYY"
122
+ binSnapping="year"
123
+ minDate="2009"
124
+ maxDate="2018"
125
+ bins="[100,1000,10000,100,1000,10000,100,1000,10000,100]"
126
+ ></histogram-date-range>
127
+ </div>
128
+
129
+ <div class="container">
130
+ <div class="clipped text-centered">
131
+ <div class="description">inside clipping container</div>
132
+ <histogram-date-range
133
+ width="175"
134
+ dateFormat="MM/YYYY"
135
+ binSnapping="month"
136
+ minDate="01/2000"
137
+ maxDate="12/2005"
138
+ bins="[1,12,2,11,3,10,4,9,5,8,6,7]"
139
+ style="--histogramDateRangeInputWidth: 50px;"
140
+ ></histogram-date-range>
141
+ </div>
142
+ </div>
143
+
144
+ <div class="container">
145
+ <div class="description">
146
+ default range with custom styling and date format
147
+ </div>
148
+ <histogram-date-range
149
+ width="300"
150
+ height="50"
151
+ tooltipWidth="140"
152
+ dateFormat="DD MMM YYYY"
153
+ style="
154
+ --histogramDateRangeSliderColor: #d8b384;
155
+ --histogramDateRangeSelectedRangeColor: #f3f0d7;
156
+ --histogramDateRangeTooltipFontFamily: serif;
157
+ --histogramDateRangeInputFontFamily: serif;
158
+ --histogramDateRangeTooltipFontSize: 1rem;
159
+ --histogramDateRangeInputWidth: 85px;
160
+ "
161
+ minDate="05 May 1972"
162
+ maxDate="21 Dec 1980"
163
+ bins="[ 85, 25, 200, 0, 0, 34, 0, 2, 5, 10, 0, 56, 10, 45, 100, 70, 50 ]"
164
+ ></histogram-date-range>
165
+ </div>
166
+
167
+ <div class="container">
168
+ <div class="description">loading state toggle</div>
169
+ <histogram-date-range
170
+ id="loading"
171
+ minDate="1900"
172
+ maxDate="2021"
173
+ bins="[
174
+ 74, 67, 17, 66, 49, 93, 47, 61, 32, 46, 53, 2, 13, 45, 67, 17, 66,
175
+ 49, 93, 47, 61, 32, 32, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32
176
+ ]"
177
+ ></histogram-date-range>
178
+ <button id="loading-toggle">toggle loading</button>
179
+ </div>
180
+ <script>
181
+ document
182
+ .querySelector('#loading-toggle')
183
+ .addEventListener('click', () => {
184
+ const histogram = document.querySelector(
185
+ 'histogram-date-range#loading'
186
+ );
187
+ histogram.loading = !histogram.loading;
188
+ });
189
+ </script>
190
+
191
+ <div class="container">
192
+ <div class="description">data set up with js</div>
193
+ <histogram-date-range id="js-setup"></histogram-date-range>
194
+ </div>
195
+ <script>
196
+ document.addEventListener('DOMContentLoaded', function () {
197
+ const histogram = document.querySelector(
198
+ 'histogram-date-range#js-setup'
199
+ );
200
+ histogram.minDate = '1950';
201
+ histogram.maxDate = '2000';
202
+ // generate array of [0, 1, 2, ... 49]
203
+ histogram.bins = [...Array(50).keys()];
204
+ });
205
+ </script>
206
+
207
+ <div class="container">
208
+ <div class="description">
209
+ single bin
210
+ </div>
211
+ <histogram-date-range minDate="1926" maxDate="1926" bins="[8]">
212
+ </histogram-date-range>
213
+ </div>
214
+
215
+ <div class="container">
216
+ <div class="description">empty data</div>
217
+ <histogram-date-range missingDataMessage="no data..."></histoghistogram-date-range>
218
+ </div>
219
+
220
+ </body>
221
+ </html>
@@ -229,6 +229,7 @@ export declare class HistogramDateRange extends LitElement {
229
229
  get minLabelTemplate(): TemplateResult;
230
230
  get maxLabelTemplate(): TemplateResult;
231
231
  get tooltipTemplate(): TemplateResult;
232
+ private get histogramAccessibility();
232
233
  private get noDataTemplate();
233
234
  private get activityIndicatorTemplate();
234
235
  static styles: import("lit").CSSResult;
@@ -818,6 +818,25 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
818
818
  <div id="tooltip" style=${styles} popover>${this._tooltipContent}</div>
819
819
  `;
820
820
  }
821
+ get histogramAccessibility() {
822
+ let rangeText;
823
+ if (this.minSelectedDate && this.maxSelectedDate) {
824
+ rangeText = `from ${this.minSelectedDate} to ${this.maxSelectedDate}`;
825
+ }
826
+ else if (this.minSelectedDate) {
827
+ rangeText = `from ${this.minSelectedDate}`;
828
+ }
829
+ else if (this.maxSelectedDate) {
830
+ rangeText = `up to ${this.maxSelectedDate}`;
831
+ }
832
+ else {
833
+ rangeText = 'for all available dates';
834
+ }
835
+ const titleText = `Filter results distribution ${rangeText}`;
836
+ const descText = `This chart shows the distribution of search results ${rangeText}. The bars represent result counts for each time period within the selected date range.`.trim();
837
+ return html `<title id="histogram-title">${titleText}</title
838
+ ><desc id="histogram-desc">${descText}</desc>`;
839
+ }
821
840
  get noDataTemplate() {
822
841
  return html `
823
842
  <div class="missing-data-message">${this.missingDataMessage}</div>
@@ -852,9 +871,10 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
852
871
  <svg
853
872
  width="${this.width}"
854
873
  height="${this.height}"
874
+ aria-labelledby="histogram-title histogram-desc"
855
875
  @pointerleave="${this.drop}"
856
876
  >
857
- ${this.selectedRangeTemplate}
877
+ ${this.histogramAccessibility} ${this.selectedRangeTemplate}
858
878
  <svg id="histogram">${this.histogramTemplate}</svg>
859
879
  ${this.minSliderTemplate} ${this.maxSliderTemplate}
860
880
  </svg>