diff --git a/frontend/src/component/admin/network/NetworkTrafficUsage/NetworkTrafficUsage.tsx b/frontend/src/component/admin/network/NetworkTrafficUsage/NetworkTrafficUsage.tsx index bc5b4e489e..041f9b9eab 100644 --- a/frontend/src/component/admin/network/NetworkTrafficUsage/NetworkTrafficUsage.tsx +++ b/frontend/src/component/admin/network/NetworkTrafficUsage/NetworkTrafficUsage.tsx @@ -298,7 +298,7 @@ const NewNetworkTrafficUsage: FC = () => { diff --git a/frontend/src/component/common/Chart/customHighlightPlugin.ts b/frontend/src/component/common/Chart/customHighlightPlugin.ts index 0dc2854a11..f0c35153e3 100644 --- a/frontend/src/component/common/Chart/customHighlightPlugin.ts +++ b/frontend/src/component/common/Chart/customHighlightPlugin.ts @@ -1,6 +1,6 @@ import type { Chart } from 'chart.js'; -export const customHighlightPlugin = (width = 46, bottomOverflow = 34) => ({ +export const customHighlightPlugin = (bottomOverflow = 34) => ({ id: 'customLine', beforeDraw: (chart: Chart) => { if (chart.tooltip?.opacity && chart.tooltip.x) { @@ -17,10 +17,14 @@ export const customHighlightPlugin = (width = 46, bottomOverflow = 34) => ({ gradient.addColorStop(0, 'rgba(129, 122, 254, 0)'); gradient.addColorStop(1, 'rgba(129, 122, 254, 0.12)'); ctx.fillStyle = gradient; + + const barWidth = + (chart.width / (chart.data.labels?.length ?? 1)) * + (chart.options.datasets?.bar?.categoryPercentage ?? 1); ctx.roundRect( - x - width / 2, + x - barWidth / 2, yAxis.top, - width, + barWidth, yAxis.bottom - yAxis.top + bottomOverflow, 5, );