From f4a37fdfae443ebed0a1478ebfd3c8f6a5b86bc2 Mon Sep 17 00:00:00 2001 From: Ram Sharan Rimal Date: Thu, 12 Sep 2024 11:02:23 -0500 Subject: [PATCH 1/3] pass comparision parameter in block map. --- app/scripts/components/common/blocks/block-map.tsx | 12 +++++++++++- docs/content/MDX_BLOCKS.md | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/scripts/components/common/blocks/block-map.tsx b/app/scripts/components/common/blocks/block-map.tsx index 8da70929e..4e5783ee4 100644 --- a/app/scripts/components/common/blocks/block-map.tsx +++ b/app/scripts/components/common/blocks/block-map.tsx @@ -112,6 +112,8 @@ interface MapBlockProps { datasets: VedaDatum; dateTime?: string; compareDateTime?: string; + compareDataSetId?: string; + compareLayerId?: string; center?: [number, number]; zoom?: number; compareLabel?: string; @@ -146,6 +148,8 @@ function MapBlock(props: MapBlockProps) { layerId, dateTime, compareDateTime, + compareDataSetId, + compareLayerId, compareLabel, center, zoom, @@ -166,7 +170,13 @@ function MapBlock(props: MapBlockProps) { const layersToFetch = useMemo(() => { const [baseMapStaticData] = reconcileDatasets([layerId], datasetLayers, []); let totalLayers = [baseMapStaticData]; - const baseMapStaticCompareData = baseMapStaticData.data.compare; + const baseMapStaticCompareData = + !!compareDataSetId && !!compareLayerId + ? { + datasetId: compareDataSetId, + layerId: compareLayerId + } + : baseMapStaticData.data.compare; if (baseMapStaticCompareData && 'layerId' in baseMapStaticCompareData) { const compareLayerId = baseMapStaticCompareData.layerId; const [compareMapStaticData] = reconcileDatasets( diff --git a/docs/content/MDX_BLOCKS.md b/docs/content/MDX_BLOCKS.md index 25faf04e8..aea34751d 100644 --- a/docs/content/MDX_BLOCKS.md +++ b/docs/content/MDX_BLOCKS.md @@ -484,6 +484,8 @@ Syntax for Chart used in Wide Figure Block looks like this. Check how the data i | datasetId | string | `''` | `id` defined in dataset mdx. | | layerId | string | `''` | `id` for layer to display. The layer should be a part of the dataset above. | | dateTime | string | `''` | Optional. This string should follow `yyyy-mm-dd` format. When omitted, the very first available dateTime for the dataset will be displayed | +| compareDataSetId | string | `''` | `id` The `id` defined in the dataset MDX. Include this only if a comparison with the dataset defined by `datasetId` is needed. | +| compareLayerId | string | `''` | `id` The `id` for the comparison layer to display. This layer must be part of the comparison dataset specified by `compareDataSetId` . | | compareDateTime | string | `''` | Optional. This string should follow `yyyy-mm-dd` format. A date should only be specified if you wish to display the comparison slider | | compareLabel | string | `''` | Text to display over the map when the comparison is active. If is for example used to indicate what dates are being compared. If not provided it will default to the value specified in the [dataset layer configuration](./frontmatter/layer.md#compare) | | projectionId | string | `mercator` | The id of the [projection](./frontmatter/layer.md#projections) to load. | From 5110c017e26062d9b3967a178f3e1a506bc1e8a5 Mon Sep 17 00:00:00 2001 From: Ram Sharan Rimal Date: Thu, 12 Sep 2024 12:09:19 -0500 Subject: [PATCH 2/3] minor fixes in naming --- app/scripts/components/common/blocks/block-map.tsx | 8 ++++---- docs/content/MDX_BLOCKS.md | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/scripts/components/common/blocks/block-map.tsx b/app/scripts/components/common/blocks/block-map.tsx index 4e5783ee4..a9920d0ff 100644 --- a/app/scripts/components/common/blocks/block-map.tsx +++ b/app/scripts/components/common/blocks/block-map.tsx @@ -112,7 +112,7 @@ interface MapBlockProps { datasets: VedaDatum; dateTime?: string; compareDateTime?: string; - compareDataSetId?: string; + compareDatasetId?: string; compareLayerId?: string; center?: [number, number]; zoom?: number; @@ -148,7 +148,7 @@ function MapBlock(props: MapBlockProps) { layerId, dateTime, compareDateTime, - compareDataSetId, + compareDatasetId, compareLayerId, compareLabel, center, @@ -171,9 +171,9 @@ function MapBlock(props: MapBlockProps) { const [baseMapStaticData] = reconcileDatasets([layerId], datasetLayers, []); let totalLayers = [baseMapStaticData]; const baseMapStaticCompareData = - !!compareDataSetId && !!compareLayerId + !!(compareDatasetId && compareLayerId) ? { - datasetId: compareDataSetId, + datasetId: compareDatasetId, layerId: compareLayerId } : baseMapStaticData.data.compare; diff --git a/docs/content/MDX_BLOCKS.md b/docs/content/MDX_BLOCKS.md index aea34751d..bc852fc2c 100644 --- a/docs/content/MDX_BLOCKS.md +++ b/docs/content/MDX_BLOCKS.md @@ -484,8 +484,8 @@ Syntax for Chart used in Wide Figure Block looks like this. Check how the data i | datasetId | string | `''` | `id` defined in dataset mdx. | | layerId | string | `''` | `id` for layer to display. The layer should be a part of the dataset above. | | dateTime | string | `''` | Optional. This string should follow `yyyy-mm-dd` format. When omitted, the very first available dateTime for the dataset will be displayed | -| compareDataSetId | string | `''` | `id` The `id` defined in the dataset MDX. Include this only if a comparison with the dataset defined by `datasetId` is needed. | -| compareLayerId | string | `''` | `id` The `id` for the comparison layer to display. This layer must be part of the comparison dataset specified by `compareDataSetId` . | +| compareDatasetId | string | `''` | `id` The `id` defined in the dataset MDX. Include this only if a comparison with the dataset defined by `datasetId` is needed. | +| compareLayerId | string | `''` | `id` The `id` for the comparison layer to display. This layer must be part of the comparison dataset specified by `compareDatasetId` . | | compareDateTime | string | `''` | Optional. This string should follow `yyyy-mm-dd` format. A date should only be specified if you wish to display the comparison slider | | compareLabel | string | `''` | Text to display over the map when the comparison is active. If is for example used to indicate what dates are being compared. If not provided it will default to the value specified in the [dataset layer configuration](./frontmatter/layer.md#compare) | | projectionId | string | `mercator` | The id of the [projection](./frontmatter/layer.md#projections) to load. | From aadff5802d5ed6242fbc886efb93652d7f2ce539 Mon Sep 17 00:00:00 2001 From: Ram Sharan Rimal Date: Thu, 12 Sep 2024 12:32:15 -0500 Subject: [PATCH 3/3] minor fix --- app/scripts/components/common/blocks/block-map.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/components/common/blocks/block-map.tsx b/app/scripts/components/common/blocks/block-map.tsx index a9920d0ff..9c2a944e6 100644 --- a/app/scripts/components/common/blocks/block-map.tsx +++ b/app/scripts/components/common/blocks/block-map.tsx @@ -171,7 +171,7 @@ function MapBlock(props: MapBlockProps) { const [baseMapStaticData] = reconcileDatasets([layerId], datasetLayers, []); let totalLayers = [baseMapStaticData]; const baseMapStaticCompareData = - !!(compareDatasetId && compareLayerId) + (!!compareDatasetId && !!compareLayerId) ? { datasetId: compareDatasetId, layerId: compareLayerId