diff --git a/apps/dashboard/src/components/report-chart/area/chart.tsx b/apps/dashboard/src/components/report-chart/area/chart.tsx
index 02e61159..1645197b 100644
--- a/apps/dashboard/src/components/report-chart/area/chart.tsx
+++ b/apps/dashboard/src/components/report-chart/area/chart.tsx
@@ -2,8 +2,8 @@
import { useRechartDataModel } from '@/hooks/useRechartDataModel';
import { useVisibleSeries } from '@/hooks/useVisibleSeries';
-import { api } from '@/trpc/client';
import type { IChartData } from '@/trpc/client';
+import { api } from '@/trpc/client';
import { cn } from '@/utils/cn';
import { getChartColor } from '@/utils/theme';
import { isSameDay, isSameHour, isSameMonth } from 'date-fns';
@@ -14,7 +14,6 @@ import {
CartesianGrid,
ComposedChart,
Legend,
- Line,
ReferenceLine,
ResponsiveContainer,
Tooltip,
@@ -23,6 +22,7 @@ import {
} from 'recharts';
import { useXAxisProps, useYAxisProps } from '../common/axis';
+import { SolidToDashedGradient } from '../common/linear-gradient';
import { ReportChartTooltip } from '../common/report-chart-tooltip';
import { ReportTable } from '../common/report-table';
import { SerieIcon } from '../common/serie-icon';
@@ -47,7 +47,6 @@ export function Chart({ data }: Props) {
isEditMode,
options: { hideXAxis, hideYAxis },
} = useReportChartContext();
- const dataLength = data.series[0]?.data?.length || 0;
const references = api.reference.getChartReferences.useQuery(
{
projectId,
@@ -69,20 +68,6 @@ export function Chart({ data }: Props) {
const lastIntervalPercent =
((rechartData.length - 2) * 100) / (rechartData.length - 1);
- const gradientTwoColors = (
- id: string,
- col1: string,
- col2: string,
- percentChange: number,
- ) => (
-
-
-
-
-
-
- );
-
const lastSerieDataItem = last(series[0]?.data || [])?.date || new Date();
const useDashedLastLine = (() => {
if (interval === 'hour') {
@@ -102,7 +87,7 @@ export function Chart({ data }: Props) {
const CustomLegend = useCallback(() => {
return (
-
+
{series.map((serie) => (
@@ -157,104 +141,56 @@ export function Chart({ data }: Props) {
))}
- {series.length > 1 && (
-
}
- />
- )}
+
} />
} />
{series.map((serie) => {
const color = getChartColor(serie.index);
return (
- {isAreaStyle && (
-
-
-
-
- )}
- {gradientTwoColors(
- `hideAllButLastInterval_${serie.id}`,
- 'rgba(0,0,0,0)',
- color,
- lastIntervalPercent,
- )}
- {gradientTwoColors(
- `hideJustLastInterval_${serie.id}`,
- color,
- 'rgba(0,0,0,0)',
- lastIntervalPercent,
+
+
+
+
+ {useDashedLastLine && (
+
)}
-
- {isAreaStyle && (
-
- )}
- {useDashedLastLine && (
- <>
-
-
- >
- )}
{previous && (
-
)}
diff --git a/apps/dashboard/src/components/report-chart/common/linear-gradient.tsx b/apps/dashboard/src/components/report-chart/common/linear-gradient.tsx
new file mode 100644
index 00000000..376cf2b3
--- /dev/null
+++ b/apps/dashboard/src/components/report-chart/common/linear-gradient.tsx
@@ -0,0 +1,69 @@
+interface GradientProps {
+ percentage: number;
+ baseColor: string;
+ id: string;
+}
+
+export const SolidToDashedGradient: React.FC
= ({
+ percentage,
+ baseColor,
+ id,
+}) => {
+ const stops = generateSolidToDashedLinearGradient(percentage, baseColor);
+
+ return (
+
+ {stops.map((stop, index) => (
+
+ ))}
+
+ );
+};
+
+// Helper function moved to the same file
+const generateSolidToDashedLinearGradient = (
+ percentage: number,
+ baseColor: string,
+) => {
+ // Start with solid baseColor up to percentage
+ const stops = [
+ { offset: '0%', color: baseColor, opacity: 1 },
+ { offset: `${percentage}%`, color: baseColor, opacity: 1 },
+ ];
+
+ // Calculate the remaining space for dashes
+ const remainingSpace = 100 - percentage;
+ const dashWidth = remainingSpace / 20; // 10 dashes = 20 segments (dash + gap)
+
+ // Generate 10 dashes
+ for (let i = 0; i < 10; i++) {
+ const startOffset = percentage + i * 2 * dashWidth;
+
+ // Add dash and gap with sharp transitions
+ stops.push(
+ // Start of dash
+ { offset: `${startOffset}%`, color: baseColor, opacity: 1 },
+ // End of dash
+ { offset: `${startOffset + dashWidth}%`, color: baseColor, opacity: 1 },
+ // Start of gap (immediate transition)
+ {
+ offset: `${startOffset + dashWidth}%`,
+ color: 'transparent',
+ opacity: 0,
+ },
+ // End of gap
+ {
+ offset: `${startOffset + 2 * dashWidth}%`,
+ color: 'transparent',
+ opacity: 0,
+ },
+ );
+ }
+
+ return stops;
+};
diff --git a/apps/dashboard/src/components/report-chart/histogram/chart.tsx b/apps/dashboard/src/components/report-chart/histogram/chart.tsx
index 5349b4c6..1f3b5736 100644
--- a/apps/dashboard/src/components/report-chart/histogram/chart.tsx
+++ b/apps/dashboard/src/components/report-chart/histogram/chart.tsx
@@ -60,7 +60,7 @@ export function Chart({ data }: Props) {
<>
-
+
} cursor={} />
-
+
{series.map((serie) => {
return (
-
-
-
-
-
-
{previous && (
)}
);
diff --git a/apps/dashboard/src/components/report-chart/line/chart.tsx b/apps/dashboard/src/components/report-chart/line/chart.tsx
index 96b7c74b..9573e5ac 100644
--- a/apps/dashboard/src/components/report-chart/line/chart.tsx
+++ b/apps/dashboard/src/components/report-chart/line/chart.tsx
@@ -23,6 +23,7 @@ import {
} from 'recharts';
import { useXAxisProps, useYAxisProps } from '../common/axis';
+import { SolidToDashedGradient } from '../common/linear-gradient';
import { ReportChartTooltip } from '../common/report-chart-tooltip';
import { ReportTable } from '../common/report-table';
import { SerieIcon } from '../common/serie-icon';
@@ -69,20 +70,6 @@ export function Chart({ data }: Props) {
const lastIntervalPercent =
((rechartData.length - 2) * 100) / (rechartData.length - 1);
- const gradientTwoColors = (
- id: string,
- col1: string,
- col2: string,
- percentChange: number,
- ) => (
-
-
-
-
-
-
- );
-
const lastSerieDataItem = last(series[0]?.data || [])?.date || new Date();
const useDashedLastLine = (() => {
if (interval === 'hour') {
@@ -102,7 +89,7 @@ export function Chart({ data }: Props) {
const CustomLegend = useCallback(() => {
return (
-
+
{series.map((serie) => (
- {series.length > 1 && (
-
}
- />
- )}
+ {series.length > 1 &&
} />}
} />
{series.map((serie) => {
const color = getChartColor(serie.index);
@@ -185,17 +167,12 @@ export function Chart({ data }: Props) {
/>
)}
- {gradientTwoColors(
- `hideAllButLastInterval_${serie.id}`,
- 'rgba(0,0,0,0)',
- color,
- lastIntervalPercent,
- )}
- {gradientTwoColors(
- `hideJustLastInterval_${serie.id}`,
- color,
- 'rgba(0,0,0,0)',
- lastIntervalPercent,
+ {useDashedLastLine && (
+
)}
@@ -221,31 +198,6 @@ export function Chart({ data }: Props) {
fillOpacity={0.1}
/>
)}
- {useDashedLastLine && (
- <>
-
-
- >
- )}
{previous && (