Skip to content

Commit

Permalink
feat(plugin-chart-echarts): subject add sort by metric for Pie Chart (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
maloun96 authored and zhaoyongjie committed Nov 24, 2021
1 parent 477fb7b commit e2554b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import { buildQueryContext, QueryFormData } from '@superset-ui/core';

export default function buildQuery(formData: QueryFormData) {
const { metric } = formData;
const { metric, sort_by_metric } = formData;
return buildQueryContext(formData, baseQueryObject => [
{
...baseQueryObject,
orderby: [[metric, false]],
...(sort_by_metric && { orderby: [[metric, false]] }),
},
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,22 @@ const config: ControlPanelConfig = {
{
label: t('Query'),
expanded: true,
controlSetRows: [['groupby'], ['metric'], ['adhoc_filters'], ['row_limit']],
controlSetRows: [
['groupby'],
['metric'],
['adhoc_filters'],
['row_limit'],
[
{
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.'),
},
},
],
],
},
{
label: t('Chart Options'),
Expand Down

0 comments on commit e2554b3

Please sign in to comment.