@genspectrum/dashboard-components 0.3.1 → 0.3.2

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.
@@ -1740,7 +1740,7 @@
1740
1740
  "type": {
1741
1741
  "text": "StoryObj<Required<PrevalenceOverTimeProps>>"
1742
1742
  },
1743
- "default": "{ ...Template, args: { numerator: [ { displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01' } }, { displayName: 'JN.1', lapisFilter: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' } }, ], denominator: { country: 'USA', dateFrom: '2023-01-01' }, granularity: 'month', smoothingWindow: 0, views: ['bar', 'line', 'bubble', 'table'], confidenceIntervalMethods: ['wilson'], width: '100%', height: '700px', headline: 'Prevalence over time', }, parameters: { fetchMock: { mocks: [ { matcher: { name: 'numeratorEG', url: AGGREGATED_ENDPOINT, body: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01', fields: ['date'], }, }, response: { status: 200, body: numeratorEG, }, }, { matcher: { name: 'numeratorJN1', url: AGGREGATED_ENDPOINT, body: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01', fields: ['date'], }, }, response: { status: 200, body: numeratorJN1, }, }, { matcher: { name: 'denominator', url: AGGREGATED_ENDPOINT, body: { country: 'USA', dateFrom: '2023-01-01', fields: ['date'], }, }, response: { status: 200, body: denominator, }, }, ], }, }, }"
1743
+ "default": "{ ...Template, args: { numerator: [ { displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01' } }, { displayName: 'JN.1', lapisFilter: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' } }, ], denominator: { country: 'USA', dateFrom: '2023-01-01' }, granularity: 'month', smoothingWindow: 0, views: ['bar', 'line', 'bubble', 'table'], confidenceIntervalMethods: ['wilson'], width: '100%', height: '700px', headline: 'Prevalence over time', lapisDateField: 'date', }, parameters: { fetchMock: { mocks: [ { matcher: { name: 'numeratorEG', url: AGGREGATED_ENDPOINT, body: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01', fields: ['date'], }, }, response: { status: 200, body: numeratorEG, }, }, { matcher: { name: 'numeratorJN1', url: AGGREGATED_ENDPOINT, body: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01', fields: ['date'], }, }, response: { status: 200, body: numeratorJN1, }, }, { matcher: { name: 'denominator', url: AGGREGATED_ENDPOINT, body: { country: 'USA', dateFrom: '2023-01-01', fields: ['date'], }, }, response: { status: 200, body: denominator, }, }, ], }, }, }"
1744
1744
  },
1745
1745
  {
1746
1746
  "kind": "variable",
@@ -1748,7 +1748,7 @@
1748
1748
  "type": {
1749
1749
  "text": "StoryObj<Required<PrevalenceOverTimeProps>>"
1750
1750
  },
1751
- "default": "{ ...Template, args: { numerator: { displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01' }, }, denominator: { country: 'USA', dateFrom: '2023-10-01' }, granularity: 'day', smoothingWindow: 7, views: ['bar', 'line', 'bubble', 'table'], confidenceIntervalMethods: ['wilson'], width: '100%', height: '700px', headline: 'Prevalence over time', }, parameters: { fetchMock: { mocks: [ { matcher: { name: 'numeratorOneVariant', url: AGGREGATED_ENDPOINT, body: { country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01', fields: ['date'], }, }, response: { status: 200, body: numeratorOneVariant, }, }, { matcher: { name: 'denominatorOneVariant', url: AGGREGATED_ENDPOINT, body: { country: 'USA', dateFrom: '2023-10-01', fields: ['date'], }, }, response: { status: 200, body: denominatorOneVariant, }, }, ], }, }, }"
1751
+ "default": "{ ...Template, args: { numerator: { displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01' }, }, denominator: { country: 'USA', dateFrom: '2023-10-01' }, granularity: 'day', smoothingWindow: 7, views: ['bar', 'line', 'bubble', 'table'], confidenceIntervalMethods: ['wilson'], width: '100%', height: '700px', headline: 'Prevalence over time', lapisDateField: 'date', }, parameters: { fetchMock: { mocks: [ { matcher: { name: 'numeratorOneVariant', url: AGGREGATED_ENDPOINT, body: { country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01', fields: ['date'], }, }, response: { status: 200, body: numeratorOneVariant, }, }, { matcher: { name: 'denominatorOneVariant', url: AGGREGATED_ENDPOINT, body: { country: 'USA', dateFrom: '2023-10-01', fields: ['date'], }, }, response: { status: 200, body: denominatorOneVariant, }, }, ], }, }, }"
1752
1752
  },
1753
1753
  {
1754
1754
  "kind": "variable",
@@ -1924,6 +1924,16 @@
1924
1924
  "default": "'700px'",
1925
1925
  "description": "The height of the component.\n\nVisit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.",
1926
1926
  "attribute": "height"
1927
+ },
1928
+ {
1929
+ "kind": "field",
1930
+ "name": "lapisDateField",
1931
+ "type": {
1932
+ "text": "string"
1933
+ },
1934
+ "default": "'date'",
1935
+ "description": "Required.\n\nThe LAPIS field that the data should be aggregated by.\nThe values will be used on the x-axis of the diagram.\nMust be a field of type `date` in LAPIS.",
1936
+ "attribute": "lapisDateField"
1927
1937
  }
1928
1938
  ],
1929
1939
  "attributes": [
@@ -2007,6 +2017,15 @@
2007
2017
  "default": "'700px'",
2008
2018
  "description": "The height of the component.\n\nVisit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.",
2009
2019
  "fieldName": "height"
2020
+ },
2021
+ {
2022
+ "name": "lapisDateField",
2023
+ "type": {
2024
+ "text": "string"
2025
+ },
2026
+ "default": "'date'",
2027
+ "description": "Required.\n\nThe LAPIS field that the data should be aggregated by.\nThe values will be used on the x-axis of the diagram.\nMust be a field of type `date` in LAPIS.",
2028
+ "fieldName": "lapisDateField"
2010
2029
  }
2011
2030
  ],
2012
2031
  "superclass": {
@@ -2054,7 +2073,7 @@
2054
2073
  "type": {
2055
2074
  "text": "StoryObj<Required<RelativeGrowthAdvantageProps>>"
2056
2075
  },
2057
- "default": "{ ...Template, args: { numerator: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateFrom: '2020-12-01', dateTo: '2021-03-01' }, denominator: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01' }, generationTime: 7, views: ['line'], width: '100%', height: '700px', headline: 'Relative growth advantage', }, parameters: { fetchMock: { mocks: [ { matcher: { name: 'numerator', url: AGGREGATED_ENDPOINT, body: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateFrom: '2020-12-01', dateTo: '2021-03-01', fields: ['date'], }, }, response: { status: 200, body: numerator, }, }, { matcher: { name: 'denominator', url: AGGREGATED_ENDPOINT, body: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01', fields: ['date'], }, }, response: { status: 200, body: denominator, }, }, ], }, }, }"
2076
+ "default": "{ ...Template, args: { numerator: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateFrom: '2020-12-01', dateTo: '2021-03-01' }, denominator: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01' }, generationTime: 7, views: ['line'], width: '100%', height: '700px', headline: 'Relative growth advantage', lapisDateField: 'date', }, parameters: { fetchMock: { mocks: [ { matcher: { name: 'numerator', url: AGGREGATED_ENDPOINT, body: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateFrom: '2020-12-01', dateTo: '2021-03-01', fields: ['date'], }, }, response: { status: 200, body: numerator, }, }, { matcher: { name: 'denominator', url: AGGREGATED_ENDPOINT, body: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01', fields: ['date'], }, }, response: { status: 200, body: denominator, }, }, ], }, }, }"
2058
2077
  }
2059
2078
  ],
2060
2079
  "exports": [
@@ -2154,6 +2173,16 @@
2154
2173
  "default": "'700px'",
2155
2174
  "description": "The height of the component.\n\nVisit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.",
2156
2175
  "attribute": "height"
2176
+ },
2177
+ {
2178
+ "kind": "field",
2179
+ "name": "lapisDateField",
2180
+ "type": {
2181
+ "text": "string"
2182
+ },
2183
+ "default": "'date'",
2184
+ "description": "Required.\n\nThe LAPIS field that the data should be aggregated by.\nThe values will be used on the x-axis of the diagram.\nMust be a field of type `date` in LAPIS.",
2185
+ "attribute": "lapisDateField"
2157
2186
  }
2158
2187
  ],
2159
2188
  "attributes": [
@@ -2219,6 +2248,15 @@
2219
2248
  "default": "'700px'",
2220
2249
  "description": "The height of the component.\n\nVisit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.",
2221
2250
  "fieldName": "height"
2251
+ },
2252
+ {
2253
+ "name": "lapisDateField",
2254
+ "type": {
2255
+ "text": "string"
2256
+ },
2257
+ "default": "'date'",
2258
+ "description": "Required.\n\nThe LAPIS field that the data should be aggregated by.\nThe values will be used on the x-axis of the diagram.\nMust be a field of type `date` in LAPIS.",
2259
+ "fieldName": "lapisDateField"
2222
2260
  }
2223
2261
  ],
2224
2262
  "superclass": {
@@ -6467,6 +6467,17 @@ class MapOperator {
6467
6467
  };
6468
6468
  }
6469
6469
  }
6470
+ class RenameFieldOperator extends MapOperator {
6471
+ constructor(child, oldFieldName, newFieldName) {
6472
+ super(
6473
+ child,
6474
+ (value) => ({
6475
+ ...value,
6476
+ [newFieldName]: value[oldFieldName]
6477
+ })
6478
+ );
6479
+ }
6480
+ }
6470
6481
  class SlidingOperator {
6471
6482
  constructor(child, windowSize, aggregate) {
6472
6483
  this.child = child;
@@ -6486,12 +6497,12 @@ class SlidingOperator {
6486
6497
  return { content };
6487
6498
  }
6488
6499
  }
6489
- function queryPrevalenceOverTime(numeratorFilter, denominatorFilter, granularity, smoothingWindow, lapis, signal) {
6500
+ function queryPrevalenceOverTime(numeratorFilter, denominatorFilter, granularity, smoothingWindow, lapis, lapisDateField, signal) {
6490
6501
  const numeratorFilters = makeArray(numeratorFilter);
6491
- const denominatorData = fetchAndPrepare(denominatorFilter, granularity, smoothingWindow);
6502
+ const denominatorData = fetchAndPrepare(denominatorFilter, granularity, smoothingWindow, lapisDateField);
6492
6503
  const subQueries = numeratorFilters.map(async (namedLapisFilter) => {
6493
6504
  const { displayName, lapisFilter } = namedLapisFilter;
6494
- const numeratorData = fetchAndPrepare(lapisFilter, granularity, smoothingWindow);
6505
+ const numeratorData = fetchAndPrepare(lapisFilter, granularity, smoothingWindow, lapisDateField);
6495
6506
  const divide = new DivisionOperator(
6496
6507
  numeratorData,
6497
6508
  denominatorData,
@@ -6515,9 +6526,10 @@ function makeArray(arrayOrSingleItem) {
6515
6526
  }
6516
6527
  return [arrayOrSingleItem];
6517
6528
  }
6518
- function fetchAndPrepare(filter, granularity, smoothingWindow) {
6519
- const fetchData = new FetchAggregatedOperator(filter, ["date"]);
6520
- const mapData = new MapOperator(fetchData, (d2) => mapDateToGranularityRange(d2, granularity));
6529
+ function fetchAndPrepare(filter, granularity, smoothingWindow, lapisDateField) {
6530
+ const fetchData = new FetchAggregatedOperator(filter, [lapisDateField]);
6531
+ const dataWithFixedDateKey = new RenameFieldOperator(fetchData, lapisDateField, "date");
6532
+ const mapData = new MapOperator(dataWithFixedDateKey, (d2) => mapDateToGranularityRange(d2, granularity));
6521
6533
  const groupByData = new GroupByAndSumOperator(mapData, "dateRange", "count");
6522
6534
  const fillData = new FillMissingOperator(
6523
6535
  groupByData,
@@ -6637,7 +6649,8 @@ const PrevalenceOverTime = ({
6637
6649
  confidenceIntervalMethods,
6638
6650
  width,
6639
6651
  height,
6640
- headline = "Prevalence over time"
6652
+ headline = "Prevalence over time",
6653
+ lapisDateField
6641
6654
  }) => {
6642
6655
  const size = { height, width };
6643
6656
  return /* @__PURE__ */ u$1(ErrorBoundary, { size, headline, children: /* @__PURE__ */ u$1(ResizeContainer, { size, children: /* @__PURE__ */ u$1(Headline, { heading: headline, children: /* @__PURE__ */ u$1(
@@ -6648,7 +6661,8 @@ const PrevalenceOverTime = ({
6648
6661
  granularity,
6649
6662
  smoothingWindow,
6650
6663
  views,
6651
- confidenceIntervalMethods
6664
+ confidenceIntervalMethods,
6665
+ lapisDateField
6652
6666
  }
6653
6667
  ) }) }) });
6654
6668
  };
@@ -6658,11 +6672,12 @@ const PrevalenceOverTimeInner = ({
6658
6672
  granularity,
6659
6673
  smoothingWindow,
6660
6674
  views,
6661
- confidenceIntervalMethods
6675
+ confidenceIntervalMethods,
6676
+ lapisDateField
6662
6677
  }) => {
6663
6678
  const lapis = P(LapisUrlContext);
6664
6679
  const { data, error, isLoading } = useQuery(
6665
- () => queryPrevalenceOverTime(numerator, denominator, granularity, smoothingWindow, lapis),
6680
+ () => queryPrevalenceOverTime(numerator, denominator, granularity, smoothingWindow, lapis, lapisDateField),
6666
6681
  [lapis, numerator, denominator, granularity, smoothingWindow]
6667
6682
  );
6668
6683
  if (isLoading) {
@@ -6808,6 +6823,7 @@ let PrevalenceOverTimeComponent = class extends PreactLitAdapterWithGridJsStyles
6808
6823
  this.headline = "Prevalence over time";
6809
6824
  this.width = "100%";
6810
6825
  this.height = "700px";
6826
+ this.lapisDateField = "date";
6811
6827
  }
6812
6828
  render() {
6813
6829
  return /* @__PURE__ */ u$1(
@@ -6821,7 +6837,8 @@ let PrevalenceOverTimeComponent = class extends PreactLitAdapterWithGridJsStyles
6821
6837
  confidenceIntervalMethods: this.confidenceIntervalMethods,
6822
6838
  width: this.width,
6823
6839
  height: this.height,
6824
- headline: this.headline
6840
+ headline: this.headline,
6841
+ lapisDateField: this.lapisDateField
6825
6842
  }
6826
6843
  );
6827
6844
  }
@@ -6853,6 +6870,9 @@ __decorateClass$6([
6853
6870
  __decorateClass$6([
6854
6871
  n2({ type: String })
6855
6872
  ], PrevalenceOverTimeComponent.prototype, "height", 2);
6873
+ __decorateClass$6([
6874
+ n2({ type: String })
6875
+ ], PrevalenceOverTimeComponent.prototype, "lapisDateField", 2);
6856
6876
  PrevalenceOverTimeComponent = __decorateClass$6([
6857
6877
  t$2("gs-prevalence-over-time")
6858
6878
  ], PrevalenceOverTimeComponent);
@@ -6963,11 +6983,13 @@ const tooltip = () => {
6963
6983
  }
6964
6984
  };
6965
6985
  };
6966
- async function queryRelativeGrowthAdvantage(numerator, denominator, generationTime, lapis, signal) {
6967
- const fetchNumerator = new FetchAggregatedOperator(numerator, ["date"]);
6968
- const fetchDenominator = new FetchAggregatedOperator(denominator, ["date"]);
6969
- const mapNumerator = new MapOperator(fetchNumerator, toYearMonthDay);
6970
- const mapDenominator = new MapOperator(fetchDenominator, toYearMonthDay);
6986
+ async function queryRelativeGrowthAdvantage(numerator, denominator, generationTime, lapis, lapisDateField, signal) {
6987
+ const fetchNumerator = new FetchAggregatedOperator(numerator, [lapisDateField]);
6988
+ const fetchDenominator = new FetchAggregatedOperator(denominator, [lapisDateField]);
6989
+ const mapToFixedDateKeyNumerator = new RenameFieldOperator(fetchNumerator, lapisDateField, "date");
6990
+ const mapToFixedDateKeyDenominator = new RenameFieldOperator(fetchDenominator, lapisDateField, "date");
6991
+ const mapNumerator = new MapOperator(mapToFixedDateKeyNumerator, toYearMonthDay);
6992
+ const mapDenominator = new MapOperator(mapToFixedDateKeyDenominator, toYearMonthDay);
6971
6993
  const [numeratorData, denominatorData] = await Promise.all([
6972
6994
  mapNumerator.evaluate(lapis, signal),
6973
6995
  mapDenominator.evaluate(lapis, signal)
@@ -7048,7 +7070,8 @@ const RelativeGrowthAdvantage = ({
7048
7070
  numerator,
7049
7071
  denominator,
7050
7072
  generationTime,
7051
- headline = "Relative growth advantage"
7073
+ headline = "Relative growth advantage",
7074
+ lapisDateField
7052
7075
  }) => {
7053
7076
  const size = { height, width };
7054
7077
  return /* @__PURE__ */ u$1(ErrorBoundary, { size, headline, children: /* @__PURE__ */ u$1(ResizeContainer, { size, children: /* @__PURE__ */ u$1(Headline, { heading: headline, children: /* @__PURE__ */ u$1(
@@ -7057,7 +7080,8 @@ const RelativeGrowthAdvantage = ({
7057
7080
  views,
7058
7081
  numerator,
7059
7082
  denominator,
7060
- generationTime
7083
+ generationTime,
7084
+ lapisDateField
7061
7085
  }
7062
7086
  ) }) }) });
7063
7087
  };
@@ -7065,12 +7089,13 @@ const RelativeGrowthAdvantageInner = ({
7065
7089
  numerator,
7066
7090
  denominator,
7067
7091
  generationTime,
7068
- views
7092
+ views,
7093
+ lapisDateField
7069
7094
  }) => {
7070
7095
  const lapis = P(LapisUrlContext);
7071
7096
  const [yAxisScaleType, setYAxisScaleType] = p("linear");
7072
7097
  const { data, error, isLoading } = useQuery(
7073
- () => queryRelativeGrowthAdvantage(numerator, denominator, generationTime, lapis),
7098
+ () => queryRelativeGrowthAdvantage(numerator, denominator, generationTime, lapis, lapisDateField),
7074
7099
  [lapis, numerator, denominator, generationTime, views]
7075
7100
  );
7076
7101
  if (isLoading) {
@@ -7182,6 +7207,7 @@ let RelativeGrowthAdvantageComponent = class extends PreactLitAdapter {
7182
7207
  this.headline = "Relative growth advantage";
7183
7208
  this.width = "100%";
7184
7209
  this.height = "700px";
7210
+ this.lapisDateField = "date";
7185
7211
  }
7186
7212
  render() {
7187
7213
  return /* @__PURE__ */ u$1(
@@ -7193,7 +7219,8 @@ let RelativeGrowthAdvantageComponent = class extends PreactLitAdapter {
7193
7219
  views: this.views,
7194
7220
  width: this.width,
7195
7221
  height: this.height,
7196
- headline: this.headline
7222
+ headline: this.headline,
7223
+ lapisDateField: this.lapisDateField
7197
7224
  }
7198
7225
  );
7199
7226
  }
@@ -7219,6 +7246,9 @@ __decorateClass$5([
7219
7246
  __decorateClass$5([
7220
7247
  n2({ type: String })
7221
7248
  ], RelativeGrowthAdvantageComponent.prototype, "height", 2);
7249
+ __decorateClass$5([
7250
+ n2({ type: String })
7251
+ ], RelativeGrowthAdvantageComponent.prototype, "lapisDateField", 2);
7222
7252
  RelativeGrowthAdvantageComponent = __decorateClass$5([
7223
7253
  t$2("gs-relative-growth-advantage")
7224
7254
  ], RelativeGrowthAdvantageComponent);