Skip to content

Commit

Permalink
feat(plugin-chart-word-cloud): subject Add order by desc on metric (a…
Browse files Browse the repository at this point in the history
…pache#939)

* feat(plugin-chart-word-cloud): subject Add order by desc

* Add checkbox to control order by
  • Loading branch information
maloun96 authored and zhaoyongjie committed Nov 26, 2021
1 parent df47d95 commit bf2a80c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { WordCloudFormData } from '../types';

export default function buildQuery(formData: WordCloudFormData) {
// Set the single QueryObject's groupby field with series in formData
const { metric, sort_by_metric } = formData;

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

0 comments on commit bf2a80c

Please sign in to comment.