2024-02-26 09:32:19 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 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=[],
|
2024-03-27 08:16:24 +00:00
|
|
|
colorMode='auto',
|
|
|
|
overrides=[],
|
|
|
|
reduceOptions={},
|
2024-02-26 09:32:19 +00:00
|
|
|
):: {
|
|
|
|
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,
|
2024-03-27 08:16:24 +00:00
|
|
|
reduceOptions: reduceOptions,
|
2024-02-26 09:32:19 +00:00
|
|
|
},
|
|
|
|
fieldConfig: {
|
|
|
|
defaults: {
|
|
|
|
color: { mode: colorMode },
|
|
|
|
mappings: [],
|
|
|
|
custom: {
|
|
|
|
hideFrom: {
|
|
|
|
legend: false,
|
|
|
|
tooltip: false,
|
|
|
|
viz: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-03-27 08:16:24 +00:00
|
|
|
overrides: overrides,
|
2024-02-26 09:32:19 +00:00
|
|
|
},
|
|
|
|
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),
|
|
|
|
},
|
|
|
|
}
|