From f57bef5317f47dfc59a5bac64eddf78cf1a695a2 Mon Sep 17 00:00:00 2001 From: Paul Pestov <10750176+paulpestov@users.noreply.github.com> Date: Tue, 7 Nov 2023 23:04:11 +0100 Subject: [PATCH] fix: display tooltips in workflow metric charts --- .../timeline/MetricAverageChart.vue | 11 ++-------- src/components/timeline/MetricChart.vue | 8 +++++++- src/helpers/metric-chart-tooltip-content.ts | 20 +++++++++++++++++++ src/i18n.ts | 8 ++++++++ src/locales/de.json | 3 ++- src/locales/en.json | 3 ++- src/main.js | 8 +------- 7 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 src/helpers/metric-chart-tooltip-content.ts create mode 100644 src/i18n.ts diff --git a/src/components/timeline/MetricAverageChart.vue b/src/components/timeline/MetricAverageChart.vue index 92e2df6..fd246ca 100644 --- a/src/components/timeline/MetricAverageChart.vue +++ b/src/components/timeline/MetricAverageChart.vue @@ -5,7 +5,7 @@ import TimelineChart from "@/components/timeline/TimelineChart.vue" import type {EvaluationResultsDocumentWide, EvaluationRun, TimelineChartDataPoint, Workflow} from "@/types" import { getMaxValueOfMetric } from '@/helpers/metrics' import {useI18n} from "vue-i18n"; -import {createReadableMetricValue} from "@/helpers/utils"; +import { metricChartTooltipContent } from "@/helpers/metric-chart-tooltip-content"; const { t } = useI18n() @@ -61,14 +61,7 @@ function getTimelineData(runs: EvaluationRun[], metric: string): TimelineChartDa } function tooltipContent(d: TimelineChartDataPoint) { - return ` -
- ${t('date')}: ${d.date.getDate()}.${d.date.getMonth()}.${d.date.getFullYear()} -
-
- ${t(props.metric)}: ${createReadableMetricValue(props.metric, d.value)} -
- ` + return metricChartTooltipContent(d, props.metric) } diff --git a/src/components/timeline/MetricChart.vue b/src/components/timeline/MetricChart.vue index 78581eb..789a98c 100644 --- a/src/components/timeline/MetricChart.vue +++ b/src/components/timeline/MetricChart.vue @@ -4,6 +4,8 @@ import api from "@/helpers/api" import TimelineChart from "@/components/timeline/TimelineChart.vue" import { getMaxValueOfMetric } from '@/helpers/metrics' import type { EvaluationResultsDocumentWide, EvaluationRun } from "@/types" +import { TimelineChartDataPoint } from "@/types" +import { metricChartTooltipContent } from "@/helpers/metric-chart-tooltip-content" const props = defineProps(['gtId', 'workflowId', 'metric', 'startDate', 'endDate']) const runs = ref([]) @@ -36,10 +38,14 @@ function getTimelineData(runs: EvaluationRun[], metric: keyof EvaluationResultsD }) } +function tooltipContent(d: TimelineChartDataPoint) { + return metricChartTooltipContent(d, props.metric) +} +