From e994fc08027cadcfdeee96e4e003bc82035819db Mon Sep 17 00:00:00 2001 From: gordern <458957068@qq.com> Date: Mon, 10 May 2021 22:08:09 +0800 Subject: [PATCH] fix(plugin-chart-echarts): add orderby to funnel chart (#1099) * fix(plugin-chart-echarts): add orderby fix https://github.com/apache/superset/issues/14534 * feat(plugin-chart-echarts): set orderby default value is true --- .../plugin-chart-echarts/src/Funnel/buildQuery.ts | 2 ++ .../plugin-chart-echarts/src/Funnel/controlPanel.tsx | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Funnel/buildQuery.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Funnel/buildQuery.ts index 257fc15faea..8b47fb5e725 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Funnel/buildQuery.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Funnel/buildQuery.ts @@ -19,9 +19,11 @@ import { buildQueryContext, QueryFormData } from '@superset-ui/core'; export default function buildQuery(formData: QueryFormData) { + const { metric, sort_by_metric } = formData; return buildQueryContext(formData, baseQueryObject => [ { ...baseQueryObject, + ...(sort_by_metric && { orderby: [[metric, false]] }), }, ]); } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx index 5a8c88eb822..cfa20985c17 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx @@ -57,6 +57,17 @@ const config: ControlPanelConfig = { }, }, ], + [ + { + name: 'sort_by_metric', + config: { + default: true, + type: 'CheckboxControl', + label: t('Sort by metric'), + description: t('Whether to sort results by the selected metric in descending order.'), + }, + }, + ], ], }, {