Skip to content

Commit b9536c5

Browse files
Fix issue when click on pie chart shows in popover NaN instead of value (#24413)
* Fix issue when click on pie chart shows in popover NaN instead of value * Add changelog * fix issue with metric value
1 parent 31b3cfc commit b9536c5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type = "fixed"
2+
message = "Fix issue when click on pie chart shows in popover NaN instead of value."
3+
4+
issues = ["23853"]
5+
pulls = ["24413"]

graylog2-web-interface/src/views/components/visualizations/OnClickPopover/PieOnClickPopoverDropdown.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import type { ValueGroups, OnClickPopoverDropdownProps } from 'views/components/
2727
const PieOnClickPopoverDropdown = ({ clickPoint, config, setFieldData }: OnClickPopoverDropdownProps) => {
2828
const { rowPivotValues, columnPivotValues, metricValue } = useMemo<ValueGroups>(() => {
2929
if (!clickPoint || !config) return {};
30+
3031
const traceColor = getHoverSwatchColor(clickPoint);
3132
const splitNames: Array<string | number> = (clickPoint.data.originalName ?? clickPoint.data.name).split(
3233
keySeparator,
@@ -57,17 +58,19 @@ const PieOnClickPopoverDropdown = ({ clickPoint, config, setFieldData }: OnClick
5758
metricValue: {
5859
value: clickPoint.value,
5960
field: metric,
60-
text: `${String(clickPoint.text ?? clickPoint?.value)}`,
61+
text: `${String(clickPoint?.value)}`,
6162
traceColor,
6263
},
6364
};
6465
}, [clickPoint, config]);
6566

6667
const formatedPercentageValue = useMemo(() => {
67-
const { value, unit } = getPrettifiedValue(clickPoint?.percent, { abbrev: 'd%', unitType: 'percent' });
68+
if (!clickPoint.percent) return clickPoint.text;
69+
70+
const { value, unit } = getPrettifiedValue(clickPoint.percent, { abbrev: 'd%', unitType: 'percent' });
6871

6972
return formatValueWithUnitLabel(value, unit?.abbrev);
70-
}, [clickPoint?.percent]);
73+
}, [clickPoint.percent, clickPoint.text]);
7174

7275
return (
7376
<Popover.Dropdown title={formatedPercentageValue}>

0 commit comments

Comments
 (0)