From bb0213ecbe413e15c75b9186ac5a7fdfa3c1b9b5 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Mon, 29 Jul 2024 11:45:45 -0700 Subject: [PATCH] (core) Fix regression that caused Date/DateTime series to be treated as categorical data Test Plan: Tested manually with a Date and DateTime column type. Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D4305 --- app/client/components/ChartView.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/client/components/ChartView.ts b/app/client/components/ChartView.ts index 37ac7574..51e36b77 100644 --- a/app/client/components/ChartView.ts +++ b/app/client/components/ChartView.ts @@ -78,6 +78,9 @@ export function isNumericLike(col: ColumnRec, use: UseCB = unwrap) { return ['Numeric', 'Int', 'Any'].includes(colType); } +function isCategoryType(pureType: string): boolean { + return !['Numeric', 'Int', 'Any', 'Date', 'DateTime'].includes(pureType); +} interface ChartOptions { multiseries?: boolean; @@ -1125,7 +1128,7 @@ export const chartTypes: {[name: string]: ChartFunc} = { bar(series: Series[], options: ChartOptions): PlotData { // If the X axis is not from numerical column, treat it as category. const data = basicPlot(series, options, {type: 'bar'}); - const useCategory = series[0]?.pureType && !['Numeric', 'Int', 'Any'].includes(series[0].pureType); + const useCategory = series[0]?.pureType && isCategoryType(series[0].pureType); const xaxisName = options.orientation === 'h' ? 'yaxis' : 'xaxis'; if (useCategory && data.layout && data.layout[xaxisName]) { const axisConfig = data.layout[xaxisName]!;