Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

feat(plugin-chart-echarts): SORT BY METRIC add checkbox to Gauge #1113

Merged
merged 11 commits into from
May 15, 2021
Merged
2 changes: 2 additions & 0 deletions plugins/plugin-chart-echarts/src/Gauge/buildQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
import { buildQueryContext, QueryFormData } from '@superset-ui/core';

export default function buildQuery(formData: QueryFormData) {
const { metric, sort_by_metric } = formData;
return buildQueryContext(formData, baseQueryObject => [
{
...baseQueryObject,
groupby: formData.groupby || [],
...(sort_by_metric && { orderby: [[metric, false]] }),
},
]);
}
10 changes: 10 additions & 0 deletions plugins/plugin-chart-echarts/src/Gauge/controlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'sort_by_metric',
config: {
type: 'CheckboxControl',
label: t('Sort by metric'),
description: t('Whether to sort results by the selected metric in descending order.'),
},
},
],
],
},
{
Expand Down