From bfa3f2be03b846603bd9ff56845d91446f4d010d Mon Sep 17 00:00:00 2001 From: vikrantgupta25 Date: Fri, 13 Sep 2024 12:12:14 +0530 Subject: [PATCH] feat: add units for pie chart --- .../src/container/NewWidget/RightContainer/constants.ts | 2 +- frontend/src/container/PanelWrapper/PiePanelWrapper.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/container/NewWidget/RightContainer/constants.ts b/frontend/src/container/NewWidget/RightContainer/constants.ts index 171f6b81d3..03cee96d21 100644 --- a/frontend/src/container/NewWidget/RightContainer/constants.ts +++ b/frontend/src/container/NewWidget/RightContainer/constants.ts @@ -74,7 +74,7 @@ export const panelTypeVsYAxisUnit: { [key in PANEL_TYPES]: boolean } = { [PANEL_TYPES.VALUE]: true, [PANEL_TYPES.TABLE]: false, [PANEL_TYPES.LIST]: false, - [PANEL_TYPES.PIE]: false, + [PANEL_TYPES.PIE]: true, [PANEL_TYPES.BAR]: true, [PANEL_TYPES.HISTOGRAM]: false, [PANEL_TYPES.TRACE]: false, diff --git a/frontend/src/container/PanelWrapper/PiePanelWrapper.tsx b/frontend/src/container/PanelWrapper/PiePanelWrapper.tsx index a176247781..47d83672c6 100644 --- a/frontend/src/container/PanelWrapper/PiePanelWrapper.tsx +++ b/frontend/src/container/PanelWrapper/PiePanelWrapper.tsx @@ -4,6 +4,7 @@ import { Color } from '@signozhq/design-tokens'; import { Group } from '@visx/group'; import { Pie } from '@visx/shape'; import { useTooltip, useTooltipInPortal } from '@visx/tooltip'; +import { getYAxisFormattedValue } from 'components/Graph/yAxisConfig'; import { themeColors } from 'constants/theme'; import { useIsDarkMode } from 'hooks/useDarkMode'; import { generateColor } from 'lib/uPlotLib/utils/generateColor'; @@ -129,7 +130,12 @@ function PiePanelWrapper({ showTooltip({ tooltipData: { label, - value: arc.data.value, + // do not update the unit in the data as the arc allotment is based on value + // and treats 4K smaller than 40 + value: getYAxisFormattedValue( + arc.data.value, + widget?.yAxisUnit || '', + ), color: arc.data.color, key: label, },