summaryrefslogtreecommitdiffstats
path: root/monitoring/ceph-mixin/dashboards/piechart_panel.libsonnet
diff options
context:
space:
mode:
Diffstat (limited to 'monitoring/ceph-mixin/dashboards/piechart_panel.libsonnet')
-rw-r--r--monitoring/ceph-mixin/dashboards/piechart_panel.libsonnet73
1 files changed, 73 insertions, 0 deletions
diff --git a/monitoring/ceph-mixin/dashboards/piechart_panel.libsonnet b/monitoring/ceph-mixin/dashboards/piechart_panel.libsonnet
new file mode 100644
index 000000000..68ff71954
--- /dev/null
+++ b/monitoring/ceph-mixin/dashboards/piechart_panel.libsonnet
@@ -0,0 +1,73 @@
+{
+ /**
+ * Creates a pie chart panel.
+ *
+ * @name pieChartPanel.new
+ *
+ * @param title The title of the pie chart panel.
+ * @param description (default `''`) Description of the panel
+ * @param datasource (optional) Datasource
+ * @param pieType (default `'pie'`) Type of pie chart (one of pie or donut)
+ *
+ * @method addTarget(target) Adds a target object.
+ */
+ new(
+ title,
+ description='',
+ datasource=null,
+ gridPos={},
+ displayMode='table',
+ placement='bottom',
+ showLegend=true,
+ displayLabels=[],
+ tooltip={},
+ pieType='pie',
+ values=[],
+ colorMode='auto',
+ overrides=[],
+ reduceOptions={},
+ ):: {
+ type: 'piechart',
+ [if description != null then 'description']: description,
+ title: title,
+ gridPos: gridPos,
+ datasource: datasource,
+ options: {
+ legend: {
+ calcs: [],
+ values: values,
+ displayMode: displayMode,
+ placement: placement,
+ showLegend: showLegend,
+ },
+ pieType: pieType,
+ tooltip: tooltip,
+ displayLabels: displayLabels,
+ reduceOptions: reduceOptions,
+ },
+ fieldConfig: {
+ defaults: {
+ color: { mode: colorMode },
+ mappings: [],
+ custom: {
+ hideFrom: {
+ legend: false,
+ tooltip: false,
+ viz: false,
+ },
+ },
+ },
+ overrides: overrides,
+ },
+ targets: [
+ ],
+ _nextTarget:: 0,
+ addTarget(target):: self {
+ // automatically ref id in added targets.
+ local nextTarget = super._nextTarget,
+ _nextTarget: nextTarget + 1,
+ targets+: [target { refId: std.char(std.codepoint('A') + nextTarget) }],
+ },
+ addTargets(targets):: std.foldl(function(p, t) p.addTarget(t), targets, self),
+ },
+}