@genspectrum/dashboard-components 0.6.7 → 0.6.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.
@@ -983,14 +983,14 @@ declare global {
983
983
 
984
984
  declare global {
985
985
  interface HTMLElementTagNameMap {
986
- 'gs-aggregate-component': AggregateComponent;
986
+ 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
987
987
  }
988
988
  }
989
989
 
990
990
 
991
991
  declare global {
992
992
  interface HTMLElementTagNameMap {
993
- 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
993
+ 'gs-aggregate-component': AggregateComponent;
994
994
  }
995
995
  }
996
996
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genspectrum/dashboard-components",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "description": "GenSpectrum web components for building dashboards",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
@@ -9,6 +9,7 @@ import { type Deletion, type Substitution } from '../../utils/mutations';
9
9
  import { compareTemporal, type Temporal, YearMonthDay } from '../../utils/temporal';
10
10
  import { type ColorScale, getColorWithingScale, getTextColorForScale } from '../components/color-scale-selector';
11
11
  import Tooltip, { type TooltipPosition } from '../components/tooltip';
12
+ import { sortSubstitutionsAndDeletions } from '../shared/sort/sortSubstitutionsAndDeletions';
12
13
  import { formatProportion } from '../shared/table/formatProportion';
13
14
 
14
15
  export interface MutationsOverTimeGridProps {
@@ -20,7 +21,7 @@ const MAX_NUMBER_OF_GRID_ROWS = 100;
20
21
  const MUTATION_CELL_WIDTH_REM = 8;
21
22
 
22
23
  const MutationsOverTimeGrid: FunctionComponent<MutationsOverTimeGridProps> = ({ data, colorScale }) => {
23
- const allMutations = data.getFirstAxisKeys();
24
+ const allMutations = data.getFirstAxisKeys().sort(sortSubstitutionsAndDeletions);
24
25
  const shownMutations = allMutations.slice(0, MAX_NUMBER_OF_GRID_ROWS);
25
26
 
26
27
  const dates = data.getSecondAxisKeys().sort((a, b) => compareTemporal(a, b));
@@ -24,6 +24,7 @@ import type { ProportionInterval } from '../components/proportion-selector';
24
24
  import { ProportionSelectorDropdown } from '../components/proportion-selector-dropdown';
25
25
  import { ResizeContainer } from '../components/resize-container';
26
26
  import Tabs from '../components/tabs';
27
+ import { sortSubstitutionsAndDeletions } from '../shared/sort/sortSubstitutionsAndDeletions';
27
28
  import { useQuery } from '../useQuery';
28
29
 
29
30
  export type View = 'grid';
@@ -194,16 +195,19 @@ const Toolbar: FunctionComponent<ToolbarProps> = ({
194
195
  function getDownloadData(filteredData: MutationOverTimeDataGroupedByMutation) {
195
196
  const dates = filteredData.getSecondAxisKeys().sort((a, b) => compareTemporal(a, b));
196
197
 
197
- return filteredData.getFirstAxisKeys().map((mutation) => {
198
- return dates.reduce(
199
- (accumulated, date) => {
200
- const proportion = filteredData.get(mutation, date)?.proportion ?? 0;
201
- return {
202
- ...accumulated,
203
- [date.toString()]: proportion,
204
- };
205
- },
206
- { mutation: mutation.toString() },
207
- );
208
- });
198
+ return filteredData
199
+ .getFirstAxisKeys()
200
+ .sort(sortSubstitutionsAndDeletions)
201
+ .map((mutation) => {
202
+ return dates.reduce(
203
+ (accumulated, date) => {
204
+ const proportion = filteredData.get(mutation, date)?.proportion ?? 0;
205
+ return {
206
+ ...accumulated,
207
+ [date.toString()]: proportion,
208
+ };
209
+ },
210
+ { mutation: mutation.toString() },
211
+ );
212
+ });
209
213
  }
@@ -32,7 +32,7 @@ describe('sortSubstitutionsAndDeletions with no segments', () => {
32
32
  describe('sortSubstitutionsAndDeletions with segments', () => {
33
33
  test('should sort for segment first', () => {
34
34
  const a = new Substitution('AA1', 'A', 'B', 123);
35
- const b = new Substitution('BB1', 'A', 'B', 234);
35
+ const b = new Substitution('BB1', 'A', 'B', 123);
36
36
 
37
37
  expect(sortSubstitutionsAndDeletions(a, b)).toBeLessThan(0);
38
38
  expect(sortSubstitutionsAndDeletions(b, a)).toBeGreaterThan(0);
@@ -2,7 +2,7 @@ import { Deletion, type Substitution } from '../../../utils/mutations';
2
2
 
3
3
  export const sortSubstitutionsAndDeletions = (a: Substitution | Deletion, b: Substitution | Deletion) => {
4
4
  if (a.segment !== b.segment) {
5
- compareSegments(a.segment, b.segment);
5
+ return compareSegments(a.segment, b.segment);
6
6
  }
7
7
 
8
8
  if (a.position !== b.position) {