From ded566b2fe5479475d5f90ea9da5d6313719325f Mon Sep 17 00:00:00 2001 From: sjaanus Date: Tue, 29 Jul 2025 16:07:05 +0300 Subject: [PATCH] Colors --- .../CreationArchiveChart.tsx | 29 ++++++++++++------- .../CreationArchiveTooltip.tsx | 13 ++++----- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/frontend/src/component/insights/componentsChart/CreationArchiveChart/CreationArchiveChart.tsx b/frontend/src/component/insights/componentsChart/CreationArchiveChart/CreationArchiveChart.tsx index b39249ab1f..3a73fb4634 100644 --- a/frontend/src/component/insights/componentsChart/CreationArchiveChart/CreationArchiveChart.tsx +++ b/frontend/src/component/insights/componentsChart/CreationArchiveChart/CreationArchiveChart.tsx @@ -142,7 +142,7 @@ export const CreationArchiveChart: FC = ({ const flagTypeDatasets = Array.from(allFlagTypes).map( (flagType, index) => ({ - label: `Created: ${flagType}`, + label: flagType, data: weeks, backgroundColor: flagTypeColors[index % flagTypeColors.length], borderColor: flagTypeColors[index % flagTypeColors.length], @@ -157,6 +157,8 @@ export const CreationArchiveChart: FC = ({ }), ); + const flagTypeNames = Array.from(allFlagTypes); + return { datasets: [ { @@ -164,10 +166,7 @@ export const CreationArchiveChart: FC = ({ data: weeks, backgroundColor: theme.palette.background.application, borderColor: theme.palette.background.application, - type: 'bar' as const, parsing: { yAxisKey: 'archivedFlags', xAxisKey: 'date' }, - yAxisID: 'y', - stack: 'archived', order: 2, }, ...flagTypeDatasets, @@ -176,7 +175,6 @@ export const CreationArchiveChart: FC = ({ data: weeks, borderColor: theme.palette.primary.light, backgroundColor: theme.palette.primary.light, - fill: false, type: 'line' as const, parsing: { yAxisKey: 'archivePercentage', @@ -186,6 +184,7 @@ export const CreationArchiveChart: FC = ({ order: 1, }, ], + flagTypeNames, // Add this to the return object }; }, [creationArchiveData, theme]); @@ -201,6 +200,11 @@ export const CreationArchiveChart: FC = ({ const data = notEnoughData || isLoading ? placeholderData : aggregateOrProjectData; + // Get flag type names for legend filtering + const flagTypeNames = isAggregate + ? (aggregateHealthData as any).flagTypeNames || [] + : []; + return ( <> = ({ position: 'bottom' as const, labels: { filter: (legendItem) => { - // Hide individual created flag type labels - return !legendItem.text?.startsWith( - 'Created:', + return !flagTypeNames.includes( + legendItem.text || '', ); }, generateLabels: (chart) => { @@ -226,7 +229,9 @@ export const CreationArchiveChart: FC = ({ ); const filtered = original.filter( (item) => - !item.text?.startsWith('Created:'), + !flagTypeNames.includes( + item.text || '', + ), ); // Add custom "Created Flags" legend item @@ -294,8 +299,10 @@ export const CreationArchiveChart: FC = ({ height={100} width={250} /> - {tooltip?.dataPoints?.some((point) => - point.dataset.label?.startsWith('Created:'), + {tooltip?.dataPoints?.some( + (point) => + point.dataset.label !== 'Archived flags' && + point.dataset.label !== 'Flags archived / Flags created', ) ? ( ) : tooltip?.dataPoints?.some( diff --git a/frontend/src/component/insights/componentsChart/CreationArchiveChart/CreationArchiveTooltip.tsx b/frontend/src/component/insights/componentsChart/CreationArchiveChart/CreationArchiveTooltip.tsx index f34f809ea5..333627494d 100644 --- a/frontend/src/component/insights/componentsChart/CreationArchiveChart/CreationArchiveTooltip.tsx +++ b/frontend/src/component/insights/componentsChart/CreationArchiveChart/CreationArchiveTooltip.tsx @@ -28,30 +28,29 @@ export const CreationArchiveTooltip: FC = ({ return null; } - // Filter for created flag type datasets only - const createdFlagDataPoints = tooltip.dataPoints.filter((point) => - point.dataset.label?.startsWith('Created:'), + // Filter for flag type datasets (exclude archived flags and percentage line) + const createdFlagDataPoints = tooltip.dataPoints.filter( + (point) => + point.dataset.label !== 'Archived flags' && + point.dataset.label !== 'Flags archived / Flags created', ); if (createdFlagDataPoints.length === 0) { return null; } - // Get the data from the first point (they all have the same raw data) const rawData = createdFlagDataPoints[0]?.raw as any; if (!rawData?.createdFlagsByType) { return null; } - // Get flag type names from the chart datasets const flagTypeNames = createdFlagDataPoints.map( - (point) => point.dataset.label?.replace('Created: ', '') || '', + (point) => point.dataset.label || '', ); const flagTypeColors = getFlagTypeColors(theme); - // Create entries for each flag type with count > 0 const flagTypeEntries = Object.entries(rawData.createdFlagsByType) .filter(([, count]) => (count as number) > 0) .map(([flagType, count], index) => ({