@@ -4,6 +4,7 @@ import { scaleOrdinal } from "d3-scale";
44import { CountableTimeInterval } from "d3-time" ;
55import { timeFormat , TimeLocaleObject , timeParse } from "d3-time-format" ;
66import { useMemo } from "react" ;
7+ import { match } from "ts-pattern" ;
78
89import type { BaseChartProps } from "@/charts/shared/ChartProps" ;
910import { TableColumn , TableFields } from "@/config-types" ;
@@ -16,6 +17,8 @@ import {
1617 isTemporalDimension ,
1718 Measure ,
1819 Observation ,
20+ TemporalDimension ,
21+ TemporalEntityDimension ,
1922} from "@/domain/data" ;
2023import { TimeUnit } from "@/graphql/query-hooks" ;
2124import { IconName } from "@/icons" ;
@@ -361,7 +364,7 @@ export const extractDataPickerOptionsFromDimension = ({
361364 dimension,
362365 parseDate,
363366} : {
364- dimension : Dimension ;
367+ dimension : TemporalDimension | TemporalEntityDimension ;
365368 parseDate : ( dateStr : string ) => Date | null ;
366369} ) => {
367370 const { isKeyDimension, label, values } = dimension ;
@@ -375,19 +378,26 @@ export const extractDataPickerOptionsFromDimension = ({
375378 values [ 0 ] . position as string ,
376379 values [ values . length - 1 ] . position as string ,
377380 ] ;
378- const options = isTemporalDimension ( dimension )
379- ? values . map ( ( d ) => {
381+ const dimensionType = dimension . __typename ;
382+ const options = match ( dimensionType )
383+ . with ( "TemporalDimension" , ( ) => {
384+ return values . map ( ( d ) => {
385+ const stringifiedValue = `${ d . value } ` ;
380386 return {
381- label : ` ${ d . value } ` ,
382- value : ` ${ d . value } ` ,
387+ label : stringifiedValue ,
388+ value : stringifiedValue ,
383389 } ;
384- } )
385- : values . map ( ( d ) => {
390+ } ) ;
391+ } )
392+ . with ( "TemporalEntityDimension" , ( ) => {
393+ return values . map ( ( d ) => {
386394 return {
387395 label : `${ d . label } ` ,
388396 value : `${ d . position } ` ,
389397 } ;
390398 } ) ;
399+ } )
400+ . exhaustive ( ) ;
391401
392402 return {
393403 minDate : parseDate ( minValue ) as Date ,
0 commit comments