Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Comparisons: Only render comparisons in top stats when both query and data supports it (#4732)
Karl-Aksel Puulmann35851e90846b
diff --git a/assets/js/dashboard/stats/graph/top-stats.js b/assets/js/dashboard/stats/graph/top-stats.jsindex 3cc6c52e61..24b9d02e04 100644--- a/assets/js/dashboard/stats/graph/top-stats.js+++ b/assets/js/dashboard/stats/graph/top-stats.js@@ -31,13 +31,15 @@ export default function TopStats({ data, onMetricUpdate, tooltipBoundary }) {const lastLoadTimestamp = useLastLoadContext()const site = useSiteContext()+ const isComparison = query.comparison && data && data.comparing_from+function tooltip(stat) {let statName = stat.name.toLowerCase()statName = stat.value === 1 ? statName.slice(0, -1) : statNamereturn (<div>- {query.comparison && (+ {isComparison && (<div className="whitespace-nowrap">{topStatNumberLong(stat.graph_metric, stat.value)} vs.{' '}{topStatNumberLong(stat.graph_metric, stat.comparison_value)}{' '}@@ -50,7 +52,7 @@ export default function TopStats({ data, onMetricUpdate, tooltipBoundary }) {</div>)}- {!query.comparison && (+ {!isComparison && (<div className="whitespace-nowrap">{topStatNumberLong(stat.graph_metric, stat.value)} {statName}</div>@@ -147,7 +149,7 @@ export default function TopStats({ data, onMetricUpdate, tooltipBoundary }) {>{topStatNumberShort(stat.graph_metric, stat.value)}</p>- {query.comparison && stat.change != null ? (+ {!isComparison && stat.change != null ? (<ChangeArrowmetric={stat.graph_metric}change={stat.change}@@ -155,14 +157,14 @@ export default function TopStats({ data, onMetricUpdate, tooltipBoundary }) {/>) : null}</span>- {query.comparison ? (+ {isComparison ? (<p className="text-xs dark:text-gray-100">{formatDateRange(site, data.from, data.to)}</p>) : null}</div>- {query.comparison ? (+ {isComparison ? (<div><p className="font-bold text-xl text-gray-500 dark:text-gray-400">{topStatNumberShort(stat.graph_metric, stat.comparison_value)}