File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
packages/cubejs-playground/src/QueryBuilderV2/components Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 1- import { ChartType , TimeDimensionGranularity } from '@cubejs-client/core' ;
1+ import {
2+ ChartType ,
3+ TimeDimensionGranularity ,
4+ granularityFor ,
5+ minGranularityForIntervals ,
6+ isPredefinedGranularity
7+ } from '@cubejs-client/core' ;
28import { UseCubeQueryResult } from '@cubejs-client/react' ;
39import { Skeleton , Tag , tasty } from '@cube-dev/ui-kit' ;
410import formatDate from 'date-fns/format' ;
@@ -113,7 +119,12 @@ function CartesianChart({
113119 return ( key as string ) . split ( '.' ) . length === 3 ;
114120 }
115121 ) as string ;
116- const granularity = granularityField ?. split ( '.' ) [ 2 ] ;
122+ let granularity = granularityField ?. split ( '.' ) [ 2 ] ;
123+
124+ if ( ! isPredefinedGranularity ( granularity ) ) {
125+ const granularityInfo = resultSet ?. loadResponse . results [ 0 ] . annotation . timeDimensions [ granularityField ] ?. granularity ;
126+ granularity = minGranularityForIntervals ( granularityInfo . interval , granularityInfo . offset || granularityFor ( granularityInfo . origin ) ) ;
127+ }
117128
118129 const formatDate = useMemo ( ( ) => {
119130 if ( dateFormat ) {
You can’t perform that action at this time.
0 commit comments