diff --git a/frontend/src/component/admin/network/NetworkTrafficUsage/NetworkTrafficUsage.tsx b/frontend/src/component/admin/network/NetworkTrafficUsage/NetworkTrafficUsage.tsx index fa483f18e80b..1246cafe4c76 100644 --- a/frontend/src/component/admin/network/NetworkTrafficUsage/NetworkTrafficUsage.tsx +++ b/frontend/src/component/admin/network/NetworkTrafficUsage/NetworkTrafficUsage.tsx @@ -292,7 +292,7 @@ export const NetworkTrafficUsage: VFC = () => { diff --git a/frontend/src/component/common/Chart/customHighlightPlugin.ts b/frontend/src/component/common/Chart/customHighlightPlugin.ts index d742b8fb6d76..0dc2854a1143 100644 --- a/frontend/src/component/common/Chart/customHighlightPlugin.ts +++ b/frontend/src/component/common/Chart/customHighlightPlugin.ts @@ -1,9 +1,8 @@ import type { Chart } from 'chart.js'; -export const customHighlightPlugin = { +export const customHighlightPlugin = (width = 46, bottomOverflow = 34) => ({ id: 'customLine', beforeDraw: (chart: Chart) => { - const width = 46; if (chart.tooltip?.opacity && chart.tooltip.x) { const x = chart.tooltip.caretX; const yAxis = chart.scales.y; @@ -22,11 +21,11 @@ export const customHighlightPlugin = { x - width / 2, yAxis.top, width, - yAxis.bottom - yAxis.top + 34, + yAxis.bottom - yAxis.top + bottomOverflow, 5, ); ctx.fill(); ctx.restore(); } }, -}; +}); diff --git a/frontend/src/component/personalDashboard/FlagMetricsChart.tsx b/frontend/src/component/personalDashboard/FlagMetricsChart.tsx index a7ae43d34b43..8487b8fe1baf 100644 --- a/frontend/src/component/personalDashboard/FlagMetricsChart.tsx +++ b/frontend/src/component/personalDashboard/FlagMetricsChart.tsx @@ -23,6 +23,7 @@ import { createPlaceholderBarChartOptions, } from './createChartOptions'; import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; +import { customHighlightPlugin } from '../common/Chart/customHighlightPlugin'; const defaultYes = [ 45_000_000, 28_000_000, 28_000_000, 25_000_000, 50_000_000, 27_000_000, @@ -79,7 +80,10 @@ export const PlaceholderFlagMetricsChart = () => { const useMetricsEnvironments = (project: string, flagName: string) => { const [environment, setEnvironment] = useState(null); const { feature } = useFeature(project, flagName); - const activeEnvironments = feature.environments; + const activeEnvironments = feature.environments.map((env) => ({ + name: env.name, + type: env.type, + })); const firstProductionEnvironment = activeEnvironments.find( (env) => env.type === 'production', ); @@ -90,7 +94,7 @@ const useMetricsEnvironments = (project: string, flagName: string) => { } else if (activeEnvironments.length > 0) { setEnvironment(activeEnvironments[0].name); } - }, [flagName]); + }, [flagName, JSON.stringify(activeEnvironments)]); return { environment, setEnvironment, activeEnvironments }; }; @@ -188,6 +192,7 @@ export const FlagMetricsChart: FC<{ diff --git a/frontend/src/component/personalDashboard/createChartOptions.ts b/frontend/src/component/personalDashboard/createChartOptions.ts index 6203223687de..450e399990d2 100644 --- a/frontend/src/component/personalDashboard/createChartOptions.ts +++ b/frontend/src/component/personalDashboard/createChartOptions.ts @@ -82,6 +82,11 @@ export const createBarChartOptions = ( return { plugins: { legend: plugins?.legend, + // required to avoid the highlight plugin highlighting empty annotation + annotation: { + clip: false, + annotations: {}, + }, tooltip: { backgroundColor: theme.palette.background.paper, titleColor: theme.palette.text.primary,