(props: Props)
| 54 | export default PiePanelWrapper |
| 55 | |
| 56 | const 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 |
nothing calls this directly
no test coverage detected