@internetarchive/histogram-date-range 0.1.8 → 0.1.9

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/README.md CHANGED
@@ -1,104 +1,104 @@
1
- # \<histogram-date-range>
2
-
3
- Check out the [interactive demo](https://internetarchive.github.io/iaux-histogram-date-range/demo/).
4
-
5
- This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
6
-
7
- Travis:
8
- [![Build Status](https://travis-ci.com/internetarchive/iaux-histogram-date-range.svg?branch=main)](https://travis-ci.com/internetarchive/iaux-histogram-date-range)
9
- CodeCov: [![codecov](https://codecov.io/gh/internetarchive/iaux-histogram-date-range/branch/main/graph/badge.svg)](https://codecov.io/gh/internetarchive/iaux-histogram-date-range)
10
-
11
- ## Installation
12
-
13
- ```bash
14
- npm i @internetarchive/histogram-date-range
15
- ```
16
-
17
- ## Usage
18
-
19
- ```html
20
- <script type="module">
21
- import 'histogram-date-range/dist/src/histogram-date-range.js';
22
- </script>
23
- <histogram-date-range
24
- width="300"
25
- height="50"
26
- tooltipWidth="140"
27
- dateFormat="DD MMM YYYY"
28
- style="
29
- --histogramDateRangeTooltipFontSize: 1rem;
30
- --histogramDateRangeInputWidth: 85px;
31
- "
32
- minDate="1400"
33
- maxDate="2021"
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
- ```
43
-
44
- ## Linting with ESLint, Prettier, and Types
45
-
46
- To scan the project for linting errors, run
47
-
48
- ```bash
49
- npm run lint
50
- ```
51
-
52
- You can lint with ESLint and Prettier individually as well
53
-
54
- ```bash
55
- npm run lint:eslint
56
- ```
57
-
58
- ```bash
59
- npm run lint:prettier
60
- ```
61
-
62
- To automatically fix many linting errors, run
63
-
64
- ```bash
65
- npm run format
66
- ```
67
-
68
- You can format using ESLint and Prettier individually as well
69
-
70
- ```bash
71
- npm run format:eslint
72
- ```
73
-
74
- ```bash
75
- npm run format:prettier
76
- ```
77
-
78
- ## Testing with Web Test Runner
79
-
80
- To run the suite of Web Test Runner tests, run
81
-
82
- ```bash
83
- npm run test
84
- ```
85
-
86
- To run the tests in watch mode (for &lt;abbr title=&#34;test driven development&#34;&gt;TDD&lt;/abbr&gt;, for example), run
87
-
88
- ```bash
89
- npm run test:watch
90
- ```
91
-
92
- ## Tooling configs
93
-
94
- For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
95
-
96
- If you customize the configuration a lot, you can consider moving them to individual files.
97
-
98
- ## Local Demo with `web-dev-server`
99
-
100
- ```bash
101
- npm start
102
- ```
103
-
104
- To run a local development server that serves the basic demo located in `demo/index.html`
1
+ # \<histogram-date-range>
2
+
3
+ Check out the [interactive demo](https://internetarchive.github.io/iaux-histogram-date-range/demo/).
4
+
5
+ This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
6
+
7
+ Travis:
8
+ [![Build Status](https://travis-ci.com/internetarchive/iaux-histogram-date-range.svg?branch=main)](https://travis-ci.com/internetarchive/iaux-histogram-date-range)
9
+ CodeCov: [![codecov](https://codecov.io/gh/internetarchive/iaux-histogram-date-range/branch/main/graph/badge.svg)](https://codecov.io/gh/internetarchive/iaux-histogram-date-range)
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm i @internetarchive/histogram-date-range
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```html
20
+ <script type="module">
21
+ import 'histogram-date-range/dist/src/histogram-date-range.js';
22
+ </script>
23
+ <histogram-date-range
24
+ width="300"
25
+ height="50"
26
+ tooltipWidth="140"
27
+ dateFormat="DD MMM YYYY"
28
+ style="
29
+ --histogramDateRangeTooltipFontSize: 1rem;
30
+ --histogramDateRangeInputWidth: 85px;
31
+ "
32
+ minDate="1400"
33
+ maxDate="2021"
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
+ ```
43
+
44
+ ## Linting with ESLint, Prettier, and Types
45
+
46
+ To scan the project for linting errors, run
47
+
48
+ ```bash
49
+ npm run lint
50
+ ```
51
+
52
+ You can lint with ESLint and Prettier individually as well
53
+
54
+ ```bash
55
+ npm run lint:eslint
56
+ ```
57
+
58
+ ```bash
59
+ npm run lint:prettier
60
+ ```
61
+
62
+ To automatically fix many linting errors, run
63
+
64
+ ```bash
65
+ npm run format
66
+ ```
67
+
68
+ You can format using ESLint and Prettier individually as well
69
+
70
+ ```bash
71
+ npm run format:eslint
72
+ ```
73
+
74
+ ```bash
75
+ npm run format:prettier
76
+ ```
77
+
78
+ ## Testing with Web Test Runner
79
+
80
+ To run the suite of Web Test Runner tests, run
81
+
82
+ ```bash
83
+ npm run test
84
+ ```
85
+
86
+ To run the tests in watch mode (for &lt;abbr title=&#34;test driven development&#34;&gt;TDD&lt;/abbr&gt;, for example), run
87
+
88
+ ```bash
89
+ npm run test:watch
90
+ ```
91
+
92
+ ## Tooling configs
93
+
94
+ For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
95
+
96
+ If you customize the configuration a lot, you can consider moving them to individual files.
97
+
98
+ ## Local Demo with `web-dev-server`
99
+
100
+ ```bash
101
+ npm start
102
+ ```
103
+
104
+ To run a local development server that serves the basic demo located in `demo/index.html`
package/demo/index.css CHANGED
@@ -1,23 +1,23 @@
1
- html {
2
- font-size: 10px;
3
- font-family: sans-serif;
4
- }
5
- body {
6
- background: white;
7
- }
8
- .container {
9
- margin-top: 20px;
10
- display: grid;
11
- justify-content: center;
12
- }
13
- .description {
14
- margin: 10px auto;
15
- }
16
- .received-events {
17
- position: absolute;
18
- top: 0;
19
- }
20
- button {
21
- font-size: 100%;
22
- margin: 10px auto;
1
+ html {
2
+ font-size: 10px;
3
+ font-family: sans-serif;
4
+ }
5
+ body {
6
+ background: white;
7
+ }
8
+ .container {
9
+ margin-top: 20px;
10
+ display: grid;
11
+ justify-content: center;
12
+ }
13
+ .description {
14
+ margin: 10px auto;
15
+ }
16
+ .received-events {
17
+ position: absolute;
18
+ top: 0;
19
+ }
20
+ button {
21
+ font-size: 100%;
22
+ margin: 10px auto;
23
23
  }
package/demo/index.html CHANGED
@@ -1,159 +1,159 @@
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">small year range and few bins</div>
77
- <histogram-date-range width="175" tooltipwidth="120"
78
- minDate="2008" maxDate="2016" bins="[76104,866978,1151617,986331,218672,107410,3324]">
79
- </histogram-date-range>
80
- </div>
81
-
82
- <div class="container">
83
- <div class="description">
84
- default range with custom styling and date format
85
- </div>
86
- <histogram-date-range
87
- width="300"
88
- height="50"
89
- tooltipWidth="140"
90
- dateFormat="DD MMM YYYY"
91
- style="
92
- --histogramDateRangeSliderColor: #d8b384;
93
- --histogramDateRangeSelectedRangeColor: #f3f0d7;
94
- --histogramDateRangeTooltipFontFamily: serif;
95
- --histogramDateRangeInputFontFamily: serif;
96
- --histogramDateRangeTooltipFontSize: 1rem;
97
- --histogramDateRangeInputWidth: 85px;
98
- "
99
- minDate="05 May 1972"
100
- maxDate="21 Dec 1980"
101
- bins="[ 85, 25, 200, 0, 0, 34, 0, 2, 5, 10, 0, 56, 10, 45, 100, 70, 50 ]"
102
- ></histogram-date-range>
103
- </div>
104
-
105
- <div class="container">
106
- <div class="description">loading state toggle</div>
107
- <histogram-date-range
108
- id="loading"
109
- minDate="1900"
110
- maxDate="2021"
111
- bins="[
112
- 74, 67, 17, 66, 49, 93, 47, 61, 32, 46, 53, 2, 13, 45, 67, 17, 66,
113
- 49, 93, 47, 61, 32, 32, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32
114
- ]"
115
- ></histogram-date-range>
116
- <button id="loading-toggle">toggle loading</button>
117
- </div>
118
- <script>
119
- document
120
- .querySelector('#loading-toggle')
121
- .addEventListener('click', () => {
122
- const histogram = document.querySelector(
123
- 'histogram-date-range#loading'
124
- );
125
- histogram.loading = !histogram.loading;
126
- });
127
- </script>
128
-
129
- <div class="container">
130
- <div class="description">data set up with js</div>
131
- <histogram-date-range id="js-setup"></histogram-date-range>
132
- </div>
133
- <script>
134
- document.addEventListener('DOMContentLoaded', function () {
135
- const histogram = document.querySelector(
136
- 'histogram-date-range#js-setup'
137
- );
138
- histogram.minDate = '1950';
139
- histogram.maxDate = '2000';
140
- // generate array of [0, 1, 2, ... 49]
141
- histogram.bins = [...Array(50).keys()];
142
- });
143
- </script>
144
-
145
- <div class="container">
146
- <div class="description">
147
- single bin
148
- </div>
149
- <histogram-date-range minDate="1926" maxDate="1926" bins="[8]">
150
- </histogram-date-range>
151
- </div>
152
-
153
- <div class="container">
154
- <div class="description">empty data</div>
155
- <histogram-date-range missingDataMessage="no data..."></histoghistogram-date-range>
156
- </div>
157
-
158
- </body>
159
- </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">small year range and few bins</div>
77
+ <histogram-date-range width="175" tooltipwidth="120"
78
+ minDate="2008" maxDate="2016" bins="[76104,866978,1151617,986331,218672,107410,3324]">
79
+ </histogram-date-range>
80
+ </div>
81
+
82
+ <div class="container">
83
+ <div class="description">
84
+ default range with custom styling and date format
85
+ </div>
86
+ <histogram-date-range
87
+ width="300"
88
+ height="50"
89
+ tooltipWidth="140"
90
+ dateFormat="DD MMM YYYY"
91
+ style="
92
+ --histogramDateRangeSliderColor: #d8b384;
93
+ --histogramDateRangeSelectedRangeColor: #f3f0d7;
94
+ --histogramDateRangeTooltipFontFamily: serif;
95
+ --histogramDateRangeInputFontFamily: serif;
96
+ --histogramDateRangeTooltipFontSize: 1rem;
97
+ --histogramDateRangeInputWidth: 85px;
98
+ "
99
+ minDate="05 May 1972"
100
+ maxDate="21 Dec 1980"
101
+ bins="[ 85, 25, 200, 0, 0, 34, 0, 2, 5, 10, 0, 56, 10, 45, 100, 70, 50 ]"
102
+ ></histogram-date-range>
103
+ </div>
104
+
105
+ <div class="container">
106
+ <div class="description">loading state toggle</div>
107
+ <histogram-date-range
108
+ id="loading"
109
+ minDate="1900"
110
+ maxDate="2021"
111
+ bins="[
112
+ 74, 67, 17, 66, 49, 93, 47, 61, 32, 46, 53, 2, 13, 45, 67, 17, 66,
113
+ 49, 93, 47, 61, 32, 32, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32
114
+ ]"
115
+ ></histogram-date-range>
116
+ <button id="loading-toggle">toggle loading</button>
117
+ </div>
118
+ <script>
119
+ document
120
+ .querySelector('#loading-toggle')
121
+ .addEventListener('click', () => {
122
+ const histogram = document.querySelector(
123
+ 'histogram-date-range#loading'
124
+ );
125
+ histogram.loading = !histogram.loading;
126
+ });
127
+ </script>
128
+
129
+ <div class="container">
130
+ <div class="description">data set up with js</div>
131
+ <histogram-date-range id="js-setup"></histogram-date-range>
132
+ </div>
133
+ <script>
134
+ document.addEventListener('DOMContentLoaded', function () {
135
+ const histogram = document.querySelector(
136
+ 'histogram-date-range#js-setup'
137
+ );
138
+ histogram.minDate = '1950';
139
+ histogram.maxDate = '2000';
140
+ // generate array of [0, 1, 2, ... 49]
141
+ histogram.bins = [...Array(50).keys()];
142
+ });
143
+ </script>
144
+
145
+ <div class="container">
146
+ <div class="description">
147
+ single bin
148
+ </div>
149
+ <histogram-date-range minDate="1926" maxDate="1926" bins="[8]">
150
+ </histogram-date-range>
151
+ </div>
152
+
153
+ <div class="container">
154
+ <div class="description">empty data</div>
155
+ <histogram-date-range missingDataMessage="no data..."></histoghistogram-date-range>
156
+ </div>
157
+
158
+ </body>
159
+ </html>
@@ -1,19 +1,19 @@
1
- import { LitElement, TemplateResult } from 'lit';
2
- import '../../src/histogram-date-range';
3
- interface DataSource {
4
- minDate: unknown;
5
- maxDate: unknown;
6
- minSelectedDate: unknown;
7
- maxSelectedDate: unknown;
8
- bins: number[];
9
- }
10
- /**
11
- * This is mainly to test the histogram-date-range within
12
- * a lit-element.
13
- */
14
- export declare class AppRoot extends LitElement {
15
- dataSource: DataSource;
16
- render(): TemplateResult;
17
- private randomize;
18
- }
19
- export {};
1
+ import { LitElement, TemplateResult } from 'lit';
2
+ import '../../src/histogram-date-range';
3
+ interface DataSource {
4
+ minDate: unknown;
5
+ maxDate: unknown;
6
+ minSelectedDate: unknown;
7
+ maxSelectedDate: unknown;
8
+ bins: number[];
9
+ }
10
+ /**
11
+ * This is mainly to test the histogram-date-range within
12
+ * a lit-element.
13
+ */
14
+ export declare class AppRoot extends LitElement {
15
+ dataSource: DataSource;
16
+ render(): TemplateResult;
17
+ private randomize;
18
+ }
19
+ export {};