Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Adding various other missing params to configure for pie_chart_panel.libsonnet #276

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion grafonnet/pie_chart_panel.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
* @param title The title of the pie chart panel.
* @param description (default `''`) Description of the panel
* @param span (optional) Width of the panel
* @param breakPoint (optional) breakPoint
* @param cacheTimeout (optional) cacheTimeout
* @param combine_label (default `'Others'`)
* @param combine_threshold (default `0`)
* @param decimals (default `null`) Number of decimal places to show
* @param timeFrom (default `null`)
* @param timeShift (default `null`)
* @param legend_header (optional) legend header
* @param legend_sort (default `'avg'`)
* @param legend_sortDesc (default `true`) sort descending
* @param format (default `'short'`) unit
* @param min_span (optional) Min span
* @param datasource (optional) Datasource
* @param aliasColors (optional) Define color mappings
Expand All @@ -28,6 +39,17 @@
title,
description='',
span=null,
breakPoint=null,
cacheTimeout=null,
combine_label='Others',
combine_threshold=0,
decimals=null,
timeFrom=null,
timeShift=null,
legend_header='',
legend_sort='avg',
legend_sortDesc=true,
format='short',
min_span=null,
datasource=null,
height=null,
Expand All @@ -45,6 +67,16 @@
[if description != null then 'description']: description,
pieType: pieType,
title: title,
breakPoint: breakPoint,
cacheTimeout: cacheTimeout,
decimals: decimals,
format: format,
combine: {
label: combine_label,
threshold: combine_threshold,
},
timeFrom: timeFrom,
timeShift: timeShift,
aliasColors: aliasColors,
[if span != null then 'span']: span,
[if min_span != null then 'minSpan']: min_span,
Expand All @@ -55,9 +87,12 @@
valueName: valueName,
datasource: datasource,
legend: {
[if legend_header != null then 'header']: legend_header,
sort: legend_sort,
sortDesc: legend_sortDesc,
show: showLegend,
values: true,
percentage: showLegendPercentage,
[if showLegendPercentage != null then 'percentage']: showLegendPercentage,
},
legendType: legendType,
targets: [
Expand Down
39 changes: 39 additions & 0 deletions tests/pie_chart_panel/test_compiled.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,22 @@
"4xx": "#F2C96D",
"5xx": "#BF1B00"
},
"breakPoint": null,
"cacheTimeout": null,
"combine": {
"label": "Others",
"threshold": 0
},
"datasource": "$PROMETHEUS",
"decimals": null,
"description": "description",
"format": "short",
"legend": {
"header": "",
"percentage": true,
"show": true,
"sort": "avg",
"sortDesc": true,
"values": true
},
"legendType": "Right side",
Expand All @@ -19,34 +30,60 @@
"repeatDirection": "h",
"span": 12,
"targets": [ ],
"timeFrom": null,
"timeShift": null,
"title": "test",
"type": "grafana-piechart-panel",
"valueName": "current"
},
"basic": {
"aliasColors": { },
"breakPoint": null,
"cacheTimeout": null,
"combine": {
"label": "Others",
"threshold": 0
},
"datasource": null,
"decimals": null,
"description": "",
"format": "short",
"legend": {
"header": "",
"percentage": true,
"show": true,
"sort": "avg",
"sortDesc": true,
"values": true
},
"legendType": "Right side",
"pieType": "pie",
"span": 12,
"targets": [ ],
"timeFrom": null,
"timeShift": null,
"title": "test",
"type": "grafana-piechart-panel",
"valueName": "current"
},
"targets": {
"aliasColors": { },
"breakPoint": null,
"cacheTimeout": null,
"combine": {
"label": "Others",
"threshold": 0
},
"datasource": null,
"decimals": null,
"description": "",
"format": "short",
"legend": {
"header": "",
"percentage": true,
"show": true,
"sort": "avg",
"sortDesc": true,
"values": true
},
"legendType": "Right side",
Expand All @@ -62,6 +99,8 @@
"refId": "B"
}
],
"timeFrom": null,
"timeShift": null,
"title": "with targets",
"type": "grafana-piechart-panel",
"valueName": "current"
Expand Down