From 4c53157b0e6d24ec1193e57565a73904b9cc9aa4 Mon Sep 17 00:00:00 2001 From: Lakhan Baheti <94619783+1akhanBaheti@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:15:07 +0530 Subject: [PATCH] fix: custom analytic grouped bar tooltip value as ID (#3003) * fix: tooltip value is coming as ID * fix lint named module --- .../custom-analytics/graph/custom-tooltip.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/web/components/analytics/custom-analytics/graph/custom-tooltip.tsx b/web/components/analytics/custom-analytics/graph/custom-tooltip.tsx index 3544ae46d..4a30a0170 100644 --- a/web/components/analytics/custom-analytics/graph/custom-tooltip.tsx +++ b/web/components/analytics/custom-analytics/graph/custom-tooltip.tsx @@ -24,7 +24,22 @@ export const CustomTooltip: React.FC = ({ datum, analytics, params }) => if (params.segment) { if (DATE_KEYS.includes(params.segment)) tooltipValue = renderMonthAndYear(datum.id); - else tooltipValue = datum.id; + else if (params.segment === "labels__id") { + const label = analytics.extras.label_details.find((l) => l.labels__id === datum.id); + tooltipValue = label && label.labels__name ? label.labels__name : "None"; + } else if (params.segment === "state_id") { + const state = analytics.extras.state_details.find((s) => s.state_id === datum.id); + tooltipValue = state && state.state__name ? state.state__name : "None"; + } else if (params.segment === "issue_cycle__cycle_id") { + const cycle = analytics.extras.cycle_details.find((c) => c.issue_cycle__cycle_id === datum.id); + tooltipValue = cycle && cycle.issue_cycle__cycle__name ? cycle.issue_cycle__cycle__name : "None"; + } else if (params.segment === "issue_module__module_id") { + const selectedModule = analytics.extras.module_details.find((m) => m.issue_module__module_id === datum.id); + tooltipValue = + selectedModule && selectedModule.issue_module__module__name + ? selectedModule.issue_module__module__name + : "None"; + } else tooltipValue = datum.id; } else { if (DATE_KEYS.includes(params.x_axis)) tooltipValue = datum.indexValue; else tooltipValue = datum.id === "count" ? "Issue count" : "Estimate";