MCPcopy
hub / github.com/deepops-ai/deepops / PiePanel

Function PiePanel

ui/src/views/dashboard/plugins/panel/pie/Pie.tsx:56–217  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

54export default PiePanelWrapper
55
56const PiePanel = (props: Props) => {
57 const { panel, height, width } = props
58 const [chart, setChart] = useState(null)
59 const { colorMode } = useColorMode()
60 if (!isSeriesData(props.data)) {
61 return (<Center height="100%">Data format not support!</Center>)
62 }
63
64 const isMobileScreen = width < MobileVerticalBreakpointNum
65 const [options, onEvents] = useMemo(() => {
66 // const d = data.length > 0 ? data[0] : []
67
68 const data: PiePluginData = []
69 const color = []
70 const colors = paletteMap[props.panel.styles.palette] ?? palettes
71 const d = props.data.flat()
72 d.forEach((series,i) => {
73 const v = calcValueOnSeriesData(series, props.panel.plugins.pie.value.calc)
74 const override: OverrideItem = findOverride(props.panel, series.name)
75 const nameOverride = findRuleInOverride(override, PieRules.SeriesName)
76 data.push({
77 name: !isEmpty(nameOverride) ? nameOverride : series.name,
78 value: v,
79 })
80
81 let c
82 if (panel.plugins.pie.enableThresholds) {
83 let max = 0
84 if (panel.plugins.pie.thresholds.mode == ThresholdsMode.Percentage) {
85 max = calcValueOnSeriesData(series, ValueCalculationType.Max)
86 }
87 const threshold = getThreshold(v, panel.plugins.pie.thresholds, max)
88 if (threshold) {
89 c = threshold.color
90 }
91 }
92
93 if (!c) {
94 c = colors[i % colors.length]
95 }
96
97
98 const colorOverride = findRuleInOverride(override, PieRules.SeriesColor)
99 if (colorOverride) c = colorOverride
100 color.push(paletteColorNameToHex(c))
101 })
102
103
104 const onEvents = genDynamicFunction(panel.plugins.pie.onClickEvent);
105
106
107
108 const lp = parseLegendPlacement(panel)
109
110
111
112 const transformLabel = genDynamicFunction(panel.plugins.pie.label.transformName);
113

Callers

nothing calls this directly

Calls 11

isSeriesDataFunction · 0.90
calcValueOnSeriesDataFunction · 0.90
findOverrideFunction · 0.90
findRuleInOverrideFunction · 0.90
isEmptyFunction · 0.90
getThresholdFunction · 0.90
paletteColorNameToHexFunction · 0.90
genDynamicFunctionFunction · 0.90
formatUnitFunction · 0.90
commonInteractionEventFunction · 0.90
parseLegendPlacementFunction · 0.85

Tested by

no test coverage detected