(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
dependabot/npm_and_yarn/fast-xml-parser-4.4.1
Dmitry S 2 months ago
parent 61942f6f4b
commit bb0213ecbe

@ -78,6 +78,9 @@ export function isNumericLike(col: ColumnRec, use: UseCB = unwrap) {
return ['Numeric', 'Int', 'Any'].includes(colType); return ['Numeric', 'Int', 'Any'].includes(colType);
} }
function isCategoryType(pureType: string): boolean {
return !['Numeric', 'Int', 'Any', 'Date', 'DateTime'].includes(pureType);
}
interface ChartOptions { interface ChartOptions {
multiseries?: boolean; multiseries?: boolean;
@ -1125,7 +1128,7 @@ export const chartTypes: {[name: string]: ChartFunc} = {
bar(series: Series[], options: ChartOptions): PlotData { bar(series: Series[], options: ChartOptions): PlotData {
// If the X axis is not from numerical column, treat it as category. // If the X axis is not from numerical column, treat it as category.
const data = basicPlot(series, options, {type: 'bar'}); 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'; const xaxisName = options.orientation === 'h' ? 'yaxis' : 'xaxis';
if (useCategory && data.layout && data.layout[xaxisName]) { if (useCategory && data.layout && data.layout[xaxisName]) {
const axisConfig = data.layout[xaxisName]!; const axisConfig = data.layout[xaxisName]!;

Loading…
Cancel
Save