Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format N/A values separately in histograms #1169

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions web/blueprint/src/lib/components/schemaView/Histogram.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export let field: LilacField;
export let counts: Array<[LeafValue, number]>;
export let bins: Record<string, [number | null, number | null]> | null;
$: maxCount = Math.max(...counts.map(([_, count]) => count));
$: maxCount = Math.max(...counts.filter(val => val[0] != null).map(([_, count]) => count));

// Sort the counts by the index of their value in the named bins.
$: binKeys = bins != null ? (Object.keys(bins) as LeafValue[]) : [];
Expand Down Expand Up @@ -37,8 +37,9 @@
<div class="histogram">
{#each sortedCounts as [value, count]}
{@const groupName = formatValueOrBin(value)}
{@const barWidth = `${(count / maxCount) * 100}%`}
{@const barWidth = `${Math.min(1, count / maxCount) * 100}%`}
{@const formattedCount = formatValue(count)}
{@const backgroundColor = value != null ? 'bg-indigo-200' : 'bg-gray-200'}

<button
class="flex items-center p-0 text-left text-xs text-black hover:bg-gray-200"
Expand All @@ -51,7 +52,7 @@
<div
title={formattedCount}
style:width={barWidth}
class="histogram-label histogram-bar my-px bg-indigo-200 pl-2 text-xs leading-5"
class="histogram-label histogram-bar my-px {backgroundColor} pl-2 text-xs leading-5"
>
{formattedCount}
</div>
Expand Down
Loading