@genspectrum/dashboard-components 0.6.3 → 0.6.5

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.
@@ -60,6 +60,8 @@ describe('YearMonthDay', () => {
60
60
  // seems to be a bug in dayjs: https://github.com/iamkun/dayjs/issues/2620
61
61
  expect(underTest.week.text).equal('2019-01');
62
62
  expect(underTest.text).equal('2020-01-01');
63
+ expect(underTest.firstDay.text).equal('2020-01-01');
64
+ expect(underTest.lastDay.text).equal('2020-01-01');
63
65
  });
64
66
  });
65
67
 
@@ -71,6 +73,7 @@ describe('YearWeek', () => {
71
73
  expect(underTest.isoWeekNumber).equal(2);
72
74
  expect(underTest.firstDay.text).equal('2020-01-06');
73
75
  expect(underTest.text).equal('2020-02');
76
+ expect(underTest.lastDay.text).equal('2020-01-12');
74
77
  });
75
78
  });
76
79
 
@@ -82,6 +85,7 @@ describe('YearMonth', () => {
82
85
  expect(underTest.monthNumber).equal(1);
83
86
  expect(underTest.text).equal('2020-01');
84
87
  expect(underTest.firstDay.text).equal('2020-01-01');
88
+ expect(underTest.lastDay.text).equal('2020-01-31');
85
89
  });
86
90
  });
87
91
 
@@ -93,5 +97,6 @@ describe('Year', () => {
93
97
  expect(underTest.text).equal('2020');
94
98
  expect(underTest.firstDay.text).equal('2020-01-01');
95
99
  expect(underTest.firstMonth.text).equal('2020-01');
100
+ expect(underTest.lastDay.text).equal('2020-12-31');
96
101
  });
97
102
  });
@@ -72,6 +72,10 @@ export class YearMonthDay {
72
72
  return this.text;
73
73
  }
74
74
 
75
+ englishName(): string {
76
+ return this.dayjs.format('dddd, MMMM D, YYYY');
77
+ }
78
+
75
79
  get firstDay(): YearMonthDay {
76
80
  return this;
77
81
  }
@@ -123,6 +127,10 @@ export class YearWeek {
123
127
  return this.text;
124
128
  }
125
129
 
130
+ englishName(): string {
131
+ return `Week ${this.isoWeekNumber}, ${this.isoYearNumber}`;
132
+ }
133
+
126
134
  get firstDay(): YearMonthDay {
127
135
  // "The first week of the year, hence, always contains 4 January." https://en.wikipedia.org/wiki/ISO_week_date
128
136
  const firstDay = dayjs()
@@ -135,12 +143,14 @@ export class YearWeek {
135
143
  }
136
144
 
137
145
  get lastDay(): YearMonthDay {
138
- const lastDay = dayjs()
146
+ const firstDay = dayjs()
139
147
  .year(this.isoYearNumber)
140
- .month(12)
141
- .date(31)
142
- .isoWeek(this.isoWeekNumber)
143
- .endOf('isoWeek');
148
+ .startOf('year')
149
+ .add((this.isoWeekNumber - 1) * 7, 'day')
150
+ .startOf('week')
151
+ .add(1, 'day');
152
+ const lastDay = firstDay.add(6, 'day');
153
+
144
154
  return this.cache.getYearMonthDay(lastDay.format('YYYY-MM-DD'));
145
155
  }
146
156
 
@@ -179,6 +189,10 @@ export class YearMonth {
179
189
  return this.text;
180
190
  }
181
191
 
192
+ englishName(): string {
193
+ return `${monthName(this.monthNumber)} ${this.yearNumber}`;
194
+ }
195
+
182
196
  get firstDay(): YearMonthDay {
183
197
  return this.cache.getYearMonthDay(dayjs(`${this.yearNumber}-${this.monthNumber}-01`).format('YYYY-MM-DD'));
184
198
  }
@@ -223,6 +237,10 @@ export class Year {
223
237
  return this.text;
224
238
  }
225
239
 
240
+ englishName(): string {
241
+ return this.year.toString();
242
+ }
243
+
226
244
  get firstMonth(): YearMonth {
227
245
  return this.cache.getYearMonth(`${this.year}-01`);
228
246
  }
@@ -255,6 +273,12 @@ export class Year {
255
273
  }
256
274
  }
257
275
 
276
+ function monthName(month: number): string {
277
+ return dayjs()
278
+ .month(month - 1)
279
+ .format('MMMM');
280
+ }
281
+
258
282
  export type Temporal = YearMonthDay | YearWeek | YearMonth | Year;
259
283
 
260
284
  export function generateAllDaysInRange(start: YearMonthDay, end: YearMonthDay): YearMonthDay[] {
@@ -17,6 +17,17 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
17
17
  *
18
18
  * The grid view shows the proportion for each mutation over date ranges.
19
19
  *
20
+ * The grid limits the number of rows columns for browser performance reasons.
21
+ * Too much data might make the browser unresponsive.
22
+ *
23
+ * The number of columns is limited to 200.
24
+ * If this number are exceeded, an error message will be shown.
25
+ * It is your responsibility to make sure that this does not happen.
26
+ * Depending on the selected date range in the `lapisFilter`, you can adapt the granularity accordingly
27
+ * (e.g. use months instead of days).
28
+ *
29
+ * The number of rows is limited to 100.
30
+ * If there are more, the component will only show 100 mutations and notify the user.
20
31
  */
21
32
  @customElement('gs-mutations-over-time')
22
33
  export class MutationsOverTimeComponent extends PreactLitAdapterWithGridJsStyles {