diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/CardinalityDistributionChart.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/CardinalityDistributionChart.component.tsx index 6ef72a81e93..11c2e4a9978 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/CardinalityDistributionChart.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/CardinalityDistributionChart.component.tsx @@ -13,13 +13,13 @@ import { Box, Card, Divider, Typography, useTheme } from '@mui/material'; import { isUndefined } from 'lodash'; -import { useMemo } from 'react'; +import { useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Bar, BarChart, CartesianGrid, - Legend, + Cell, ResponsiveContainer, Tooltip, TooltipProps, @@ -52,6 +52,7 @@ const CardinalityDistributionChart = ({ }: CardinalityDistributionChartProps) => { const theme = useTheme(); const { t } = useTranslation(); + const [selectedCategory, setSelectedCategory] = useState(null); const firstDayAllUnique = data.firstDayData?.cardinalityDistribution?.allValuesUnique ?? false; @@ -170,6 +171,52 @@ const CardinalityDistributionChart = ({ 'message.all-values-unique-no-distribution-available' ); + const handleCategoryClick = (categoryName: string) => { + setSelectedCategory((prev) => + prev === categoryName ? null : categoryName + ); + }; + + const CustomYAxisTick = (props: { + x?: number; + y?: number; + payload?: { value: string }; + }) => { + const { x, y, payload } = props; + if (!payload) { + return null; + } + + const categoryName = payload.value; + const isSelected = selectedCategory === categoryName; + const isHighlighted = selectedCategory && selectedCategory !== categoryName; + + return ( + + handleCategoryClick(categoryName)}> + {categoryName.length > 15 + ? `${categoryName.slice(0, 15)}...` + : categoryName} + + + ); + }; + return ( - + + width="100%"> + layout="vertical"> - value?.length > 15 - ? `${value.slice(0, 15)}...` - : value - } + tick={} tickLine={false} type="category" width={120} /> - + radius={[0, 8, 8, 0]}> + {graphData.map((entry) => { + const isSelected = + selectedCategory === entry.name; + const isHighlighted = + selectedCategory && + selectedCategory !== entry.name; + + return ( + + handleCategoryClick(entry.name) + } + /> + ); + })} + diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/CustomBarChart.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/CustomBarChart.tsx index 03e33d36770..91d8e98edcb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/CustomBarChart.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/CustomBarChart.tsx @@ -117,6 +117,7 @@ const CustomBarChart = ({ /> } cursor={{ + fill: theme.palette.grey[100], stroke: theme.palette.grey[200], strokeDasharray: '3 3', }} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/DataDistributionHistogram.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/DataDistributionHistogram.component.tsx index 80e81e499c6..be784c054c5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/DataDistributionHistogram.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/DataDistributionHistogram.component.tsx @@ -180,6 +180,7 @@ const DataDistributionHistogram = ({ /> } cursor={{ + fill: theme.palette.grey[100], stroke: theme.palette.grey[200], strokeDasharray: '3 3', }} diff --git a/openmetadata-ui/src/main/resources/ui/src/test/unit/mocks/recharts.mock.js b/openmetadata-ui/src/main/resources/ui/src/test/unit/mocks/recharts.mock.js index 26da05e90a6..4d940d3ec7a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/test/unit/mocks/recharts.mock.js +++ b/openmetadata-ui/src/main/resources/ui/src/test/unit/mocks/recharts.mock.js @@ -15,11 +15,17 @@ import React from 'react'; window.React = React; jest.mock('recharts', () => ({ - Bar: jest.fn().mockImplementation(() =>
Bar
), + Bar: jest.fn().mockImplementation(({ children }) => ( +
+

Bar

+ {children} +
+ )), Line: jest.fn().mockImplementation(() =>
Line
), Brush: jest.fn().mockImplementation(() =>
Brush
), Area: jest.fn().mockImplementation(() =>
Area
), Scatter: jest.fn().mockImplementation(() =>
Scatter
), + Cell: jest.fn().mockImplementation(() =>
Cell
), CartesianGrid: jest.fn().mockImplementation(() =>
CartesianGrid
), Legend: jest.fn().mockImplementation(() =>
Legend
), Tooltip: jest.fn().mockImplementation(() =>
Tooltip
),