From 3470c62cce75edc3d64f1ccacf30ce57789674ba Mon Sep 17 00:00:00 2001 From: "Wei-Chun, Chang" Date: Thu, 14 Nov 2024 01:01:22 +0800 Subject: [PATCH 1/2] Add title and legend in inside chart Signed-off-by: Wei-Chun, Chang --- js/app/page.tsx | 4 +- js/src/components/charts/HistogramChart.tsx | 40 +++++++++---------- .../histogram/HistogramDiffResultView.tsx | 20 +++------- 3 files changed, 25 insertions(+), 39 deletions(-) diff --git a/js/app/page.tsx b/js/app/page.tsx index d82d9985..c1076aec 100644 --- a/js/app/page.tsx +++ b/js/app/page.tsx @@ -9,7 +9,6 @@ import { Box, Flex, Link, - Text, Spacer, Icon, LinkProps, @@ -53,7 +52,6 @@ import { RunResultPane } from "@/components/run/RunResultPane"; import { VscGitPullRequest } from "react-icons/vsc"; import { RunList } from "@/components/run/RunList"; - function getCookie(key: string) { var b = document.cookie.match("(^|;)\\s*" + key + "\\s*=\\s*([^;]+)"); return b ? b.pop() : ""; @@ -320,7 +318,7 @@ function Main() { > {_isHistoryOpen && } - - - - Base - - - Current - - - - - + ); } @@ -150,13 +141,20 @@ export function getHistogramChartOptions( hideAxis = false, { ...configOverrides }: ChartOptions<"bar"> = {} ): ChartOptions<"bar"> { - const { datasets, type, samples = 0, binEdges } = data; + const { title, datasets, type, samples = 0, binEdges } = data; const [base, current] = datasets; const isDatetime = type === "datetime"; return { responsive: true, maintainAspectRatio: false, plugins: { + title: { + display: true, + text: title, + font: { + size: 20, + }, + }, tooltip: { mode: "index", // position: 'nearest', diff --git a/js/src/components/histogram/HistogramDiffResultView.tsx b/js/src/components/histogram/HistogramDiffResultView.tsx index 0d67db5c..c22516ee 100644 --- a/js/src/components/histogram/HistogramDiffResultView.tsx +++ b/js/src/components/histogram/HistogramDiffResultView.tsx @@ -1,13 +1,6 @@ import { HistogramDiffParams, HistogramDiffResult } from "@/lib/api/profile"; import { RunResultViewProps } from "../run/types"; -import { - HStack, - Box, - Flex, - Spacer, - Heading, - forwardRef, -} from "@chakra-ui/react"; +import { HStack, Box, Flex, Spacer, forwardRef } from "@chakra-ui/react"; import { HistogramChart } from "../charts/HistogramChart"; import { ScreenshotBox } from "../screenshot/ScreenshotBox"; @@ -30,17 +23,14 @@ function _HistogramDiffResultView( } return ( - + - - Model {params.model}.{params.column_name} - - - {/* Base */} + Date: Thu, 14 Nov 2024 01:25:11 +0800 Subject: [PATCH 2/2] Align title color Signed-off-by: Wei-Chun, Chang --- .../components/top-k/TopKDiffResultView.tsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/js/src/components/top-k/TopKDiffResultView.tsx b/js/src/components/top-k/TopKDiffResultView.tsx index 94963d9b..c505cc28 100644 --- a/js/src/components/top-k/TopKDiffResultView.tsx +++ b/js/src/components/top-k/TopKDiffResultView.tsx @@ -1,21 +1,14 @@ import { TopKDiffParams, TopKDiffResult } from "@/lib/api/profile"; import { RunResultViewProps } from "../run/types"; import { - Box, Flex, HStack, Heading, Spacer, - Text, - VStack, - Divider, Link, forwardRef, } from "@chakra-ui/react"; -import { - TopKSummaryBarChart, - TopKSummaryList, -} from "../charts/TopKSummaryList"; +import { TopKSummaryBarChart } from "../charts/TopKSummaryList"; import { useState } from "react"; import { ScreenshotBox } from "../screenshot/ScreenshotBox"; @@ -34,7 +27,13 @@ const _TopKDiffResultView = ({ run }: TopKDiffResultViewProp, ref: any) => { return ( - + Model {params.model}.{params.column_name} @@ -62,4 +61,4 @@ const _TopKDiffResultView = ({ run }: TopKDiffResultViewProp, ref: any) => { ); }; -export const TopKDiffResultView = forwardRef(_TopKDiffResultView); \ No newline at end of file +export const TopKDiffResultView = forwardRef(_TopKDiffResultView);