Skip to content

Commit af2da45

Browse files
committed
chore: Fix the type errors
1 parent e2e04bd commit af2da45

File tree

8 files changed

+40
-19
lines changed

8 files changed

+40
-19
lines changed

frontend/src/components/execution/values/boxWhiskerShape.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { scaleLinear } from "d3-scale";
22
import { Cross } from "recharts";
3-
import type { ProcessedGroupedDataEntry } from "@/components/execution/values/types.ts";
3+
import type { ProcessedGroupedDataEntry } from "./types";
44

55
interface BoxWhiskerShapeProps {
66
prefix: string;
@@ -38,8 +38,14 @@ export function BoxWhiskerShape({
3838
return null; // Don't render if data or scale is missing
3939
}
4040

41-
const { min, lowerQuartile, median, upperQuartile, max, values } =
42-
payload.groups[prefix];
41+
const {
42+
min,
43+
lowerQuartile,
44+
median,
45+
upperQuartile,
46+
max,
47+
values,
48+
} = payload.groups[prefix];
4349

4450
// Calculate pixel coordinates for each value
4551
const scale = scaleLinear(yDomain, [props.background?.height, 0]);
@@ -54,7 +60,7 @@ export function BoxWhiskerShape({
5460
const boxX = x; // Box starts at the calculated x
5561

5662
function scatterValues(color: string, strokeWidth = 1) {
57-
return values.map((v) => (
63+
return values.map((v: number) => (
5864
<Cross
5965
key={v}
6066
strokeWidth={strokeWidth}

frontend/src/components/execution/values/filterAddPopover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PlusCircle } from "lucide-react";
22
import { type ComponentProps, useEffect, useState } from "react";
3-
import type { Facet } from "@/client/types.gen";
3+
import { Facet } from "@/components/execution/values/types";
44
import { Button } from "@/components/ui/button.tsx";
55
import { Label } from "@/components/ui/label.tsx";
66
import {

frontend/src/components/execution/values/filterControls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { RowSelectionState } from "@tanstack/react-table";
22
import { PlusCircle, X } from "lucide-react";
33
import type { Dispatch, SetStateAction } from "react";
4-
import type { Facet } from "@/client";
4+
import { Facet } from "@/components/execution/values/types";
55
import { FilterAddPopover } from "@/components/execution/values/filterAddPopover.tsx";
66
import { Badge } from "@/components/ui/badge";
77
import { Button } from "@/components/ui/button";

frontend/src/components/execution/values/groupedBoxWhiskerChart.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
BoxPlot,
1414
GroupedRawDataEntry,
1515
ProcessedGroupedDataEntry,
16-
} from "./types.ts"; // Import new types
16+
} from "./types"; // Import new types
1717

1818
// Helper to generate distinct colors (replace with a proper palette if needed)
1919
const defaultColors = [
@@ -55,7 +55,6 @@ export const calculateBoxPlotData = (values: number[]): BoxPlot => {
5555

5656
const min = sortedData[0];
5757
const max = sortedData[n - 1];
58-
const average = sortedData.reduce((a, b) => a + b, 0) / n;
5958

6059
const median = calculateMedian(sortedData);
6160

@@ -82,8 +81,7 @@ export const calculateBoxPlotData = (values: number[]): BoxPlot => {
8281
median,
8382
upperQuartile,
8483
max,
85-
average,
86-
values,
84+
values: sortedData, // Add values back to BoxPlot
8785
};
8886
};
8987

@@ -115,7 +113,7 @@ export const GroupedBoxWhiskerChart = ({
115113
const processedData = useMemo((): ProcessedGroupedDataEntry[] => {
116114
return data.map((entry) => {
117115
const processedEntry: ProcessedGroupedDataEntry = {
118-
category: entry.category,
116+
name: entry.name,
119117
groups: {},
120118
};
121119
for (const group of entry.groups) {
@@ -174,7 +172,7 @@ export const GroupedBoxWhiskerChart = ({
174172
// barGap={4} // Gap between bars within the same category
175173
>
176174
<CartesianGrid strokeDasharray="3 3" vertical={false} />
177-
<XAxis dataKey="category" />
175+
<XAxis dataKey="name" />
178176
<YAxis domain={yDomain} allowDataOverflow={true} />
179177
{/*<Tooltip*/}
180178
{/* content={<CustomGroupedTooltip groupMeta={groupMeta} />}*/}
@@ -186,7 +184,7 @@ export const GroupedBoxWhiskerChart = ({
186184
<Bar
187185
key={groupName}
188186
dataKey={(d: ProcessedGroupedDataEntry) => {
189-
return d.groups[groupName]?.average;
187+
return d.groups[groupName]?.median;
190188
}}
191189
name={groupName}
192190
fill={groupMeta.colors[groupName]}

frontend/src/components/execution/values/types.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,22 @@ export type MetricValueCollection = {
1616
count: number;
1717
facets: Facet[];
1818
};
19+
20+
export type BoxPlot = {
21+
min: number;
22+
lowerQuartile: number;
23+
median: number;
24+
upperQuartile: number;
25+
max: number;
26+
values: number[];
27+
};
28+
29+
export type GroupedRawDataEntry = {
30+
name: string;
31+
groups: { label: string; values: number[] }[];
32+
};
33+
34+
export type ProcessedGroupedDataEntry = {
35+
name: string;
36+
groups: { [key: string]: BoxPlot };
37+
};

frontend/src/components/execution/values/valuesDataTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from "@tanstack/react-table";
1212
import { Eye, MoreHorizontal } from "lucide-react";
1313
import { useMemo, useState } from "react";
14-
import type { Facet, MetricValue } from "@/client";
14+
import { Facet, MetricValue } from "@/components/execution/values/types";
1515
import { DataTableColumnHeader } from "@/components/dataTable/columnHeader.tsx";
1616
import { InnerDataTable } from "@/components/dataTable/innerDataTable.tsx";
1717
import { Button } from "@/components/ui/button.tsx";

frontend/src/components/execution/values/valuesFigure.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Axis3D, Download, Group } from "lucide-react";
22
import { useMemo, useState } from "react";
3-
import type { Facet, MetricValue } from "@/client";
4-
import type { GroupedRawDataEntry } from "@/components/execution/values/types.ts";
3+
import type { Facet, MetricValue, GroupedRawDataEntry } from "@/components/execution/values/types";
54
import { Button } from "@/components/ui/button.tsx";
65
import { FacetSelect } from "./facetSelect";
76
import { GroupedBoxWhiskerChart } from "./groupedBoxWhiskerChart";
@@ -33,7 +32,6 @@ export function ValuesFigure({
3332
}
3433

3534
const chartData: GroupedRawDataEntry[] = xFacet.values.map((x) => {
36-
/// Find the values for a given x-axis group
3735
const matches = values
3836
.filter(
3937
(value) =>
@@ -53,7 +51,7 @@ export function ValuesFigure({
5351
}));
5452

5553
return {
56-
category: x,
54+
name: x,
5755
groups,
5856
};
5957
});

frontend/src/hooks/useValuesProcessor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { RowSelectionState } from "@tanstack/react-table";
22
import { type SetStateAction, useMemo, useState } from "react";
3-
import type { MetricValue } from "@/client";
3+
import type { MetricValue } from "@/components/execution/values/types";
44

55
// Define types used by the hook
66
export type ProcessedMetricValue = MetricValue & { rowId: string };

0 commit comments

Comments
 (0)