-
Notifications
You must be signed in to change notification settings - Fork 13k
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: adding XAxis to BigNumberTrend #21577
Changes from 3 commits
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 |
---|---|---|
|
@@ -20,10 +20,11 @@ import { | |
FeatureFlag, | ||
isFeatureEnabled, | ||
QueryFormData, | ||
QueryResponse, | ||
t, | ||
validateNonEmpty, | ||
} from '@superset-ui/core'; | ||
import { ControlPanelState, ControlState } from '../types'; | ||
import { ControlPanelState, ControlState, Dataset } from '../types'; | ||
|
||
const getAxisLabel = ( | ||
formData: QueryFormData, | ||
|
@@ -32,7 +33,7 @@ const getAxisLabel = ( | |
? { label: t('Y-axis'), description: t('Dimension to use on y-axis.') } | ||
: { label: t('X-axis'), description: t('Dimension to use on x-axis.') }; | ||
|
||
export const xAxisControlConfig = { | ||
export const xAxisMixin = { | ||
label: (state: ControlPanelState) => getAxisLabel(state?.form_data).label, | ||
multi: false, | ||
description: (state: ControlPanelState) => | ||
|
@@ -51,3 +52,29 @@ export const xAxisControlConfig = { | |
}, | ||
default: undefined, | ||
}; | ||
|
||
export const temporalXAxisMixin = { | ||
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. As this is a mixin, we maybe the type could be narrowed down to something like Also, I'm wondering if we should make this a function 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. Thanks for the review and very useful case for this mixin. I changed this variable from the |
||
label: t('TEMPORAL X-AXIS'), | ||
mapStateToProps: ({ datasource }: ControlPanelState) => { | ||
if (datasource?.columns[0]?.hasOwnProperty('column_name')) { | ||
const temporalColumns = | ||
(datasource as Dataset)?.columns?.filter(c => c.is_dttm) ?? []; | ||
return { | ||
options: temporalColumns, | ||
default: | ||
(datasource as Dataset)?.main_dttm_col || | ||
temporalColumns[0]?.column_name || | ||
null, | ||
isTemporal: true, | ||
}; | ||
} | ||
const sortedQueryColumns = (datasource as QueryResponse)?.columns?.sort( | ||
query => (query?.is_dttm ? -1 : 1), | ||
); | ||
return { | ||
options: sortedQueryColumns, | ||
default: sortedQueryColumns[0]?.name || null, | ||
isTemporal: true, | ||
}; | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy/paste from
dndGranularitySqlaControl