@@ -93,7 +86,9 @@
{whereFilter}
{dimensionThresholdFilters}
{instanceId}
+ {tableWidth}
{timeRange}
+ {firstColumnWidth}
sortedAscending={$sortedAscending}
sortType={$sortType}
filterExcludeMode={$isFilterExcludeMode(dimension.name)}
@@ -106,8 +101,6 @@
{timeControlsReady}
selectedValues={$selectedDimensionValues(dimension.name)}
isBeingCompared={$isBeingComparedReadable(dimension.name)}
- columnWidths={$columnWidths}
- {estimateAndUpdateLeaderboardWidths}
formatter={$activeMeasureFormatter}
{setPrimaryDimension}
{toggleSort}
diff --git a/web-common/src/features/dashboards/leaderboard/LeaderboardRow.svelte b/web-common/src/features/dashboards/leaderboard/LeaderboardRow.svelte
index c8003e96ad9..9adccae0a71 100644
--- a/web-common/src/features/dashboards/leaderboard/LeaderboardRow.svelte
+++ b/web-common/src/features/dashboards/leaderboard/LeaderboardRow.svelte
@@ -13,18 +13,15 @@
import LeaderboardItemFilterIcon from "./LeaderboardItemFilterIcon.svelte";
import LeaderboardTooltipContent from "./LeaderboardTooltipContent.svelte";
import LongBarZigZag from "./LongBarZigZag.svelte";
+ import {
+ DEFAULT_COL_WIDTH,
+ deltaColumn,
+ valueColumn,
+ } from "./leaderboard-widths";
export let itemData: LeaderboardItemData;
export let dimensionName: string;
export let tableWidth: number;
- export let columnWidths: {
- dimension: number;
- value: number;
- percentOfTotal: number;
- delta: number;
- deltaPercent: number;
- };
- export let gutterWidth: number;
export let borderTop = false;
export let borderBottom = false;
export let isSummableMeasure: boolean;
@@ -42,19 +39,37 @@
export let formatter:
| ((_value: number | undefined) => undefined)
| ((value: string | number) => string);
+ export let firstColumnWidth: number;
let hovered = false;
+ let valueRect = new DOMRect(0, 0, DEFAULT_COL_WIDTH);
+ let deltaRect = new DOMRect(0, 0, DEFAULT_COL_WIDTH);
$: ({
- dimensionValue: label,
+ dimensionValue,
selectedIndex,
pctOfTotal,
- value: measureValue,
- prevValue: comparisonValue,
+ value,
+ prevValue,
+ deltaAbs,
+ deltaRel,
+ uri,
} = itemData);
$: selected = selectedIndex >= 0;
+ $: formattedValue = value ? formatter(value) : null;
+ $: formattedDeltaRel = deltaRel
+ ? formatMeasurePercentageDifference(deltaRel)
+ : null;
+ $: formattedDelta = deltaAbs ? formatter(deltaAbs) : null;
+
+ $: deltaElementWidth = deltaRect.width;
+ $: valueElementWith = valueRect.width;
+
+ $: valueColumn.update(valueElementWith);
+ $: deltaColumn.update(deltaElementWidth);
+
// Super important special case: if there is not at least one "active" (selected) value,
// we need to set *all* items to be included, because by default if a user has not
// selected any values, we assume they want all values included in all calculations.
@@ -63,19 +78,18 @@
: false;
$: previousValueString =
- comparisonValue !== undefined && comparisonValue !== null
- ? formatter(comparisonValue)
+ prevValue !== undefined && prevValue !== null
+ ? formatter(prevValue)
: undefined;
- $: formattedValue = measureValue ? formatter(measureValue) : null;
+ $: negativeChange = deltaAbs !== null && deltaAbs < 0;
- $: negativeChange = itemData.deltaAbs !== null && itemData.deltaAbs < 0;
-
- $: href = makeHref(itemData.uri);
+ $: href = makeHref(uri);
$: percentOfTotal = isSummableMeasure && pctOfTotal ? pctOfTotal : 0;
- $: barLength = (tableWidth - gutterWidth) * percentOfTotal;
+ $: barLength = tableWidth * percentOfTotal;
+ $: showZigZag = barLength > tableWidth;
$: barColor = excluded
? "rgb(243 244 246)"
@@ -83,32 +97,17 @@
? "var(--color-primary-200)"
: "var(--color-primary-100)";
- $: secondCellBarLength = clamp(
- 0,
- barLength - columnWidths.dimension,
- columnWidths.value,
- );
+ $: secondCellBarLength = clamp(0, barLength - firstColumnWidth, $valueColumn);
$: thirdCellBarLength = isTimeComparisonActive
- ? clamp(
- 0,
- barLength - columnWidths.dimension - columnWidths.value,
- columnWidths.delta,
- )
+ ? clamp(0, barLength - firstColumnWidth - $valueColumn, $deltaColumn)
: isValidPercentOfTotal
- ? clamp(
- 0,
- barLength - columnWidths.dimension - columnWidths.value,
- columnWidths.percentOfTotal,
- )
+ ? clamp(0, barLength - firstColumnWidth - $valueColumn, DEFAULT_COL_WIDTH)
: 0;
$: fourthCellBarLength = isTimeComparisonActive
? clamp(
0,
- barLength -
- columnWidths.dimension -
- columnWidths.value -
- columnWidths.delta,
- columnWidths.deltaPercent,
+ barLength - firstColumnWidth - $valueColumn - $deltaColumn,
+ DEFAULT_COL_WIDTH,
)
: 0;
@@ -131,8 +130,6 @@
${fourthCellBarLength}px, transparent ${fourthCellBarLength}px)`
: undefined;
- $: showZigZag = barLength > tableWidth - gutterWidth;
-
// uri template or "true" string literal or undefined
function makeHref(uriTemplateOrBoolean: string | boolean | null) {
if (!uriTemplateOrBoolean) {
@@ -141,7 +138,7 @@
const uri =
uriTemplateOrBoolean === true
- ? label
+ ? dimensionValue
: uriTemplateOrBoolean.replace(/\s/g, "");
const hasProtocol = /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(uri);
@@ -171,15 +168,16 @@
on:mouseenter={() => (hovered = true)}
on:mouseleave={() => (hovered = false)}
on:click={modified({
- shift: () => shiftClickHandler(label),
+ shift: () => shiftClickHandler(dimensionValue),
click: (e) =>
toggleDimensionValueSelection(
dimensionName,
- label,
+ dimensionValue,
false,
e.ctrlKey || e.metaKey,
),
})}
+ class="relative"
>
-
+
{#if previousValueString && hovered}
|
+
-
+
+
+
+
{#if showZigZag && !isTimeComparisonActive && !isValidPercentOfTotal}
{/if}
|
- {#if isTimeComparisonActive}
+
+ {#if isTimeComparisonActive || isValidPercentOfTotal}
-
- |
-
-
- {#if showZigZag}
-
+ {#if isTimeComparisonActive}
+
+
+
+ {:else}
+
+ {#if showZigZag}
+
+ {/if}
{/if}
|
- {:else if isValidPercentOfTotal}
-
-
+ {/if}
+
+ {#if isTimeComparisonActive}
+ |
+
{#if showZigZag}
{/if}
@@ -266,7 +270,7 @@
|