From 6dcf7f35b37aaab89697ecfc583ac7b76a6f92fd Mon Sep 17 00:00:00 2001 From: Marco Korinth Date: Thu, 2 May 2024 10:24:03 +0200 Subject: [PATCH 1/3] feat: adjust font size of axis labels --- frontend/src/js/preview/Diagram.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/js/preview/Diagram.tsx b/frontend/src/js/preview/Diagram.tsx index 98597a46c1..78ee345de7 100644 --- a/frontend/src/js/preview/Diagram.tsx +++ b/frontend/src/js/preview/Diagram.tsx @@ -8,7 +8,6 @@ import { parseDate, parseStdDate } from "../common/helpers/dateHelper"; import { hexToRgbA } from "../entity-history/TimeStratifiedChart"; import { Theme, useTheme } from "@emotion/react"; -import { Chart } from "chart.js"; import { useTranslation } from "react-i18next"; import { formatNumber, @@ -121,7 +120,10 @@ export default function Diagram({ plugins: { title: { display: true, - font: Chart.defaults.font, + font: { + weight: "normal", + size: 14, + }, position: "bottom", text: stat.label, }, @@ -146,6 +148,10 @@ export default function Diagram({ const yScaleTitle = { display: true, text: t("preview.chartYLabel"), + font: { + weight: "normal", + size: 14, + }, }; if (previewStatsIsBarStats(stat)) { From 026d8728b894d6564ff1fbf807cbdc7fe90051d8 Mon Sep 17 00:00:00 2001 From: Marco Korinth Date: Thu, 2 May 2024 10:59:52 +0200 Subject: [PATCH 2/3] feat: add secondaryId to preview headline --- frontend/src/js/preview/HeadlineStats.tsx | 7 ++++++- frontend/src/js/preview/Preview.tsx | 20 +++++++++++++++++--- frontend/src/js/tooltip/TooltipEntries.tsx | 13 ++++++++++++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/frontend/src/js/preview/HeadlineStats.tsx b/frontend/src/js/preview/HeadlineStats.tsx index 45f4420a43..33edc810cc 100644 --- a/frontend/src/js/preview/HeadlineStats.tsx +++ b/frontend/src/js/preview/HeadlineStats.tsx @@ -17,15 +17,20 @@ const SxTooltipEntries = styled(TooltipEntries)` export type HeadlineStatsProps = { statistics: PreviewStatisticsResponse | null; + idLabel: string; }; -export default function HeadlineStats({ statistics }: HeadlineStatsProps) { +export default function HeadlineStats({ + statistics, + idLabel, +}: HeadlineStatsProps) { return ( ); diff --git a/frontend/src/js/preview/Preview.tsx b/frontend/src/js/preview/Preview.tsx index 9339722bcf..7f1726d2b2 100644 --- a/frontend/src/js/preview/Preview.tsx +++ b/frontend/src/js/preview/Preview.tsx @@ -1,12 +1,12 @@ import styled from "@emotion/styled"; -import { useState } from "react"; +import { useMemo, useState } from "react"; import { useHotkeys } from "react-hotkeys-hook"; import { useTranslation } from "react-i18next"; import { useDispatch, useSelector } from "react-redux"; import { StateT } from "../app/reducers"; -import { PreviewStatistics } from "../api/types"; +import { PreviewStatistics, SecondaryId } from "../api/types"; import { TransparentButton } from "../button/TransparentButton"; import FaIcon from "../icon/FaIcon"; @@ -79,6 +79,9 @@ const SxSelectBox = styled(SelectBox)` export default function Preview() { const preview = useSelector((state) => state.preview); + const loadedSecondaryIds = useSelector( + (state) => state.conceptTrees.secondaryIds, + ); const dispatch = useDispatch(); const { t } = useTranslation(); const [selectBoxOpen, setSelectBoxOpen] = useState(false); @@ -86,6 +89,17 @@ export default function Preview() { const [popOver, setPopOver] = useState(null); const onClose = () => dispatch(closePreview()); const statistics = preview.statisticsData; + const idLabel = useMemo(() => { + const primaryIdLabel = t("tooltip.entitiesFound", { count: 2 }); + if (preview.queryData?.secondaryId) { + const secondaryIdLabel = loadedSecondaryIds.find( + (x) => x.id === preview.queryData?.secondaryId, + )?.label; + return `${primaryIdLabel} und ${secondaryIdLabel}`; + } else { + return `${t("queryEditor.secondaryIdStandard")} (${primaryIdLabel})`; + } + }, [preview.queryData, loadedSecondaryIds, t]); useHotkeys("esc", () => { if (!selectBoxOpen && !popOver) onClose(); @@ -110,7 +124,7 @@ export default function Preview() { isOpen={selectBoxOpen} setIsOpen={setSelectBoxOpen} /> - + {statistics ? ( { matchingEntries?: number | null; matchingEntities?: number | null; dateRange?: DateRangeT; + idLabel?: string; } const TooltipEntries = (props: Props) => { const { t } = useTranslation(); - const { matchingEntries, matchingEntities, dateRange } = props; + const { matchingEntries, matchingEntities, dateRange, idLabel } = props; const isZero = props.matchingEntries === 0; const isZeroEntities = props.matchingEntities === 0; @@ -101,6 +103,15 @@ const TooltipEntries = (props: Props) => { return ( + {idLabel && ( + <> + + + {idLabel} + {t("queryEditor.secondaryId")} + + + )} From 5a1172b4271b54300c829fd658177e9e06508460 Mon Sep 17 00:00:00 2001 From: Marco Korinth Date: Thu, 2 May 2024 12:28:54 +0200 Subject: [PATCH 3/3] feat: localize secondaryId label --- frontend/src/js/preview/Preview.tsx | 2 +- frontend/src/localization/de.json | 3 ++- frontend/src/localization/en.json | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/js/preview/Preview.tsx b/frontend/src/js/preview/Preview.tsx index 7f1726d2b2..577baa5b2a 100644 --- a/frontend/src/js/preview/Preview.tsx +++ b/frontend/src/js/preview/Preview.tsx @@ -95,7 +95,7 @@ export default function Preview() { const secondaryIdLabel = loadedSecondaryIds.find( (x) => x.id === preview.queryData?.secondaryId, )?.label; - return `${primaryIdLabel} und ${secondaryIdLabel}`; + return t("preview.idLabel", { primaryIdLabel, secondaryIdLabel }); } else { return `${t("queryEditor.secondaryIdStandard")} (${primaryIdLabel})`; } diff --git a/frontend/src/localization/de.json b/frontend/src/localization/de.json index fc2c9ecf28..49a6c61b8e 100644 --- a/frontend/src/localization/de.json +++ b/frontend/src/localization/de.json @@ -411,7 +411,8 @@ "name": "Name", "value": "Wert", "densityPlot": "Dichtediagramm", - "chartYLabel": "Anzahl" + "chartYLabel": "Anzahl", + "idLabel": "{{primaryIdLabel}} und {{secondaryIdLabel}}" }, "login": { "headline": "Anfragen und Analyse", diff --git a/frontend/src/localization/en.json b/frontend/src/localization/en.json index 33b55de4d0..7312d8db67 100644 --- a/frontend/src/localization/en.json +++ b/frontend/src/localization/en.json @@ -411,7 +411,8 @@ "name": "Name", "value": "Value", "densityPlot": "Density Plot", - "chartYLabel": "Count" + "chartYLabel": "Count", + "idLabel": "{{primaryIdLabel}} and {{secondaryIdLabel}}" }, "login": { "headline": "Queries and Analyses",