Skip to content

Commit

Permalink
(core) Fix regression that caused Date/DateTime series to be treated …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
dsagal committed Jul 29, 2024
1 parent 61942f6 commit bb0213e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/client/components/ChartView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]!;
Expand Down

0 comments on commit bb0213e

Please sign in to comment.