Control sortby based on series limit (#18950)
This commit is contained in:
parent
79a7a5d1b1
commit
f53f86f796
|
|
@ -336,6 +336,15 @@ const row_limit: SharedControlConfig<'SelectControl'> = {
|
|||
description: t('Limits the number of rows that get displayed.'),
|
||||
};
|
||||
|
||||
const order_desc: SharedControlConfig<'CheckboxControl'> = {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Sort Descending'),
|
||||
default: true,
|
||||
description: t('Whether to sort descending or ascending'),
|
||||
visibility: ({ controls }) =>
|
||||
Boolean(controls?.timeseries_limit_metric.value),
|
||||
};
|
||||
|
||||
const limit: SharedControlConfig<'SelectControl'> = {
|
||||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
|
|
@ -507,6 +516,7 @@ const sharedControls = {
|
|||
limit,
|
||||
timeseries_limit_metric: enableExploreDnd ? dnd_sort_by : sort_by,
|
||||
orderby: enableExploreDnd ? dnd_sort_by : sort_by,
|
||||
order_desc,
|
||||
series: enableExploreDnd ? dndSeries : series,
|
||||
entity: enableExploreDnd ? dndEntity : entity,
|
||||
x: enableExploreDnd ? dnd_x : x,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,11 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/core';
|
||||
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';
|
||||
import {
|
||||
ControlPanelConfig,
|
||||
sections,
|
||||
sharedControls,
|
||||
} from '@superset-ui/chart-controls';
|
||||
import {
|
||||
lineInterpolation,
|
||||
showBrush,
|
||||
|
|
@ -41,6 +45,38 @@ import {
|
|||
} from '../NVD3Controls';
|
||||
|
||||
const config: ControlPanelConfig = {
|
||||
controlOverrides: {
|
||||
limit: {
|
||||
rerender: ['timeseries_limit_metric', 'order_desc'],
|
||||
},
|
||||
timeseries_limit_metric: {
|
||||
label: t('Series Limit Sort By'),
|
||||
description: t(
|
||||
'Metric used to order the limit if a series limit is present. ' +
|
||||
'If undefined reverts to the first metric (where appropriate).',
|
||||
),
|
||||
visibility: ({ controls }) => Boolean(controls?.limit.value),
|
||||
mapStateToProps: (state, controlState) => {
|
||||
const timeserieslimitProps =
|
||||
sharedControls.timeseries_limit_metric.mapStateToProps?.(
|
||||
state,
|
||||
controlState,
|
||||
) || {};
|
||||
timeserieslimitProps.value = state.controls?.limit?.value
|
||||
? controlState.value
|
||||
: [];
|
||||
return timeserieslimitProps;
|
||||
},
|
||||
},
|
||||
order_desc: {
|
||||
label: t('Series Limit Sort Descending'),
|
||||
default: false,
|
||||
description: t(
|
||||
'Whether to sort descending or ascending if a series limit is present',
|
||||
),
|
||||
visibility: ({ controls }) => Boolean(controls?.limit.value),
|
||||
},
|
||||
},
|
||||
controlPanelSections: [
|
||||
sections.legacyTimeseriesTime,
|
||||
timeSeriesSection[0],
|
||||
|
|
|
|||
|
|
@ -346,19 +346,7 @@ export const timeSeriesSection: ControlPanelSectionConfig[] = [
|
|||
['groupby'],
|
||||
['limit'],
|
||||
['timeseries_limit_metric'],
|
||||
[
|
||||
{
|
||||
name: 'order_desc',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Sort Descending'),
|
||||
default: true,
|
||||
description: t('Whether to sort descending or ascending'),
|
||||
visibility: ({ controls }) =>
|
||||
Boolean(controls?.timeseries_limit_metric.value),
|
||||
},
|
||||
},
|
||||
],
|
||||
['order_desc'],
|
||||
[
|
||||
{
|
||||
name: 'contribution',
|
||||
|
|
|
|||
Loading…
Reference in New Issue