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

Commit

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

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

* Add checkbox to control order by
  • Loading branch information
maloun96 authored Feb 8, 2021
1 parent a7daa91 commit 58ab28e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions plugins/plugin-chart-word-cloud/src/plugin/buildQuery.ts
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]] }),
},
]);
}
17 changes: 16 additions & 1 deletion plugins/plugin-chart-word-cloud/src/plugin/controlPanel.ts
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

1 comment on commit 58ab28e

@vercel
Copy link

@vercel vercel bot commented on 58ab28e Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.