Skip to content

Commit 7cfe838

Browse files
authored
Merge pull request #447 from cBioPortal/studyview-chart-titles
Study View: chart titles centred on one line, a long one ellipsized (STS-HD-1)
2 parents 612d24a + aef88b5 commit 7cfe838

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎app/globals.css‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,12 @@ main.analysis-main { max-width: min(132rem, 100%); }
688688
.row.baseline { align-items: baseline; }
689689
.row.g5 { gap: 0.5rem; }
690690
.facettitle { font-size: var(--t-md); font-weight: 600; }
691+
/* a chart's title as the portal's (STS-HD-1): one line, centred, a long one cut with an ellipsis
692+
(the whole of it is in the tooltip); padded on both sides alike so the chart menu, placed over
693+
the card's corner, neither covers it nor pulls it off centre */
694+
.facetgrid > .card > .facettitle { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 1.75rem; }
695+
/* what the chart counts, on a line of its own under the title, so a long title never hides it */
696+
.facetgrid > .card > .facettitle > .meta { display: block; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
691697

692698
/* ---------------- view-card tables (app/lab/kinds/<kind>.tsx) ---------------- */
693699
.vscroll { overflow-x: auto; }

‎app/lab/explore-sections.tsx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ export function DerivedFacets({ ctx }: { ctx: ExploreCtx }) {
617617
as the clinical facets do, rather than show a number that
618618
cannot be reconciled with the draft. */}
619619
<div className="facettitle" data-tip={d.note}>
620-
{d.label} <span className="meta">· {d.covered.toLocaleString()} patients
620+
{d.label} <span className="meta">{d.covered.toLocaleString()} patients
621621
{(d as any).disjunctive ? " · not narrowed by its own filter" : ""}</span>
622622
</div>
623623
<div className="vallist">
@@ -895,12 +895,12 @@ function ClinicalFacet({ c, ctx }: { c: NonNullable<ExploreCtx["explore"]>["clin
895895
const unit = c.per === "sample" ? " samples" : " patients";
896896
return (
897897
<div
898-
className="facettitle" data-tip={[c.displayName && c.displayName !== c.attribute ? c.attribute : "", c.description]
899-
.filter(Boolean).join(" — ") || undefined}>
898+
className="facettitle" data-tip={[c.displayName || c.attribute, c.displayName && c.displayName !== c.attribute ? c.attribute : "", c.description]
899+
.filter(Boolean).join(" — ")}>
900900
{isCustomAttr(c.attribute) && <span className="customtag" data-tip={c.description}>custom</span>}
901901
{c.displayName || c.attribute}{" "}
902902
<span className="meta">
903-
{(c.per === "sample" ? "· sample-level · " : "· ") + shown.toLocaleString() + unit}
903+
{(c.per === "sample" ? "sample-level · " : "") + shown.toLocaleString() + unit}
904904
{disj ? " · not narrowed by its own filter" : ""}
905905
</span>
906906
{(() => {
@@ -1185,7 +1185,7 @@ export function GeneFacets({ ctx }: { ctx: ExploreCtx }) {
11851185
<div key={f.gene + f.type} data-genefacet={f.gene + "|" + f.type} className="card">
11861186
<div className="facettitle">
11871187
{f.gene}: {f.type === "CNA" ? "copy-number alterations" : "somatic mutations"}
1188-
<span className="meta"> · sample-level · {f.total.toLocaleString()} samples</span>
1188+
<span className="meta">sample-level · {f.total.toLocaleString()} samples</span>
11891189
<ChartMenu label={f.gene} actions={[summaryDownload(f.gene + ": " + (f.type === "CNA" ? "copy-number alterations" : "somatic mutations"), "sample",
11901190
states.map((st) => ({ value: st.label, count: st.n })), 0, undefined, ctx.setExMsg)]} />
11911191
</div>
@@ -1230,7 +1230,7 @@ export function TreatmentTables({ ctx }: { ctx: ExploreCtx }) {
12301230
const on = new Set(appliedTreatmentKeys(draft, level));
12311231
return (
12321232
<div className="card" data-treatments={level}>
1233-
<div className="facettitle">{title}<span className="meta"> · {meta}</span></div>
1233+
<div className="facettitle">{title}<span className="meta">{meta}</span></div>
12341234
{leftOut}
12351235
{rows.length ? <ValueList unit={unit} hint={level === "patient" ? "keep the patients treated with any checked treatment" : "keep the samples taken before or after any checked treatment"}
12361236
extra={level === "sample" ? { head: "Pre / Post", tip: "taken before (Pre) or after (Post) the patient's first treatment with it" } : undefined}
@@ -1264,7 +1264,7 @@ export function MutationTypeFacets({ ctx }: { ctx: ExploreCtx }) {
12641264
<div key={f.gene} data-mutationtypes={f.gene} className="card">
12651265
<div className="facettitle">
12661266
{f.gene}: mutation types
1267-
{counted && <span className="meta" data-tip="Freq is of every selected sample, as the portal's table writes it, not of the samples profiled for the gene"> · sample-level · Freq of {f.total.toLocaleString()} samples{f.disjunctive ? " · counted without its own filter" : ""}</span>}
1267+
{counted && <span className="meta" data-tip="Freq is of every selected sample, as the portal's table writes it, not of the samples profiled for the gene">sample-level · Freq of {f.total.toLocaleString()} samples{f.disjunctive ? " · counted without its own filter" : ""}</span>}
12681268
</div>
12691269
{applied.excluded > 0 && <p className="note flush mt-1">
12701270
{applied.excluded === 1 ? "A filter excludes" : applied.excluded + " filters exclude"} {f.gene} mutation types; this table is counted without {applied.excluded === 1 ? "it" : "them"}.

‎test/e2e/explore.cjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,13 @@ async function explore({ ok, BASE, page, browser }) {
592592
const counts = (await pt.locator(".valrow .vn").allInnerTexts()).map((t) => Number(t.replace(/,/g, "")));
593593
const ordered = counts.every((n, i) => i === 0 || counts[i - 1] >= n);
594594
const pick = (await pt.locator(".valrow .vname").allInnerTexts())[0];
595-
const before = (await st.locator(".facettitle").innerText()).trim();
595+
const before = (await st.locator(".facettitle").textContent()).trim(); // as the wait below reads it
596596
await pt.locator(".valrow").first().click();
597597
await pt.getByRole("button", { name: "Apply filter" }).click();
598598
await page.waitForFunction((a) => document.body.innerText.includes("treated with " + a), pick, { timeout: 240000 });
599599
await page.waitForFunction((b) => (document.querySelector("[data-treatments='sample'] .facettitle")?.textContent || "").trim() !== b, before, { timeout: 240000 });
600600
const pinned = await pt.locator(".valrow.on .vname").allInnerTexts();
601-
const after = (await st.locator(".facettitle").innerText()).trim();
601+
const after = (await st.locator(".facettitle").textContent()).trim();
602602
txDetail = JSON.stringify({ rows: counts.length, pick, pinned, before, after });
603603
txOk = counts.length > 1 && ordered && pinned.length === 1 && pinned[0] === pick && after !== before;
604604
} catch (e) { txDetail = String(e.message).split("\n")[0]; }

0 commit comments

Comments
 (0)