-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Timeseries): Respect time grain #31765
base: master
Are you sure you want to change the base?
Changes from 2 commits
45e7ed0
9ad7e6b
1f306de
748e8a7
0ecf4b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ import { | |
SMART_DATE_ID, | ||
SMART_DATE_VERBOSE_ID, | ||
TimeFormatter, | ||
TimeGranularity, | ||
ValueFormatter, | ||
} from '@superset-ui/core'; | ||
|
||
|
@@ -76,24 +77,40 @@ export const getYAxisFormatter = ( | |
|
||
export function getTooltipTimeFormatter( | ||
format?: string, | ||
timeGrain?: TimeGranularity, | ||
): TimeFormatter | StringConstructor { | ||
if ( | ||
timeGrain === TimeGranularity.QUARTER || | ||
timeGrain === TimeGranularity.MONTH || | ||
timeGrain === TimeGranularity.YEAR | ||
) { | ||
return getTimeFormatter(undefined, timeGrain); | ||
} | ||
if (format === SMART_DATE_ID) { | ||
return getSmartDateDetailedFormatter(); | ||
return getTimeFormatter(SMART_DATE_DETAILED_ID, timeGrain); | ||
} | ||
Comment on lines
89
to
91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect Override of Smart Date FormatTell me moreWhat is the issue?When SMART_DATE_ID format is specified, the code overrides it with SMART_DATE_DETAILED_ID, which contradicts the user's explicit format choice. Why this mattersUsers selecting SMART_DATE_ID format will unexpectedly receive a different formatting style than requested, potentially causing confusion and inconsistency in the application's behavior. Suggested changeRespect the user's format choice by modifying the code to: if (format === SMART_DATE_ID) {
return getTimeFormatter(SMART_DATE_ID, timeGrain);
} Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews. |
||
if (format) { | ||
return getTimeFormatter(format); | ||
return getTimeFormatter(format, timeGrain); | ||
} | ||
return String; | ||
} | ||
|
||
export function getXAxisFormatter( | ||
format?: string, | ||
timeGrain?: TimeGranularity, | ||
): TimeFormatter | StringConstructor | undefined { | ||
if ( | ||
timeGrain === TimeGranularity.QUARTER || | ||
timeGrain === TimeGranularity.MONTH || | ||
timeGrain === TimeGranularity.YEAR | ||
) { | ||
return getTimeFormatter(undefined, timeGrain); | ||
} | ||
if (format === SMART_DATE_ID || !format) { | ||
return undefined; | ||
} | ||
if (format) { | ||
return getTimeFormatter(format); | ||
return getTimeFormatter(format, timeGrain); | ||
} | ||
return String; | ||
} |
This comment was marked as resolved.
Sorry, something went wrong.