Skip to content

Commit 64bd761

Browse files
committed
Merge branch 'feat/reactive-plotly-box' into feat/reactive-plotly-strip
2 parents fac08d2 + dca3105 commit 64bd761

3 files changed

Lines changed: 33 additions & 533 deletions

File tree

examples/third_party/plotly/strip_chart.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ def selected_rows(selection, data):
8080
if not selection:
8181
return empty
8282

83-
# Prefer sample_id embedded via customdata
84-
ids = [
85-
row["sample_id"]
86-
for row in selection
87-
if isinstance(row.get("sample_id"), str)
88-
]
83+
# Prefer sample_id embedded via customdata.
84+
# Fallback-path selections embed sample_id as customdata[0] (a
85+
# list/tuple), not as a parsed top-level key.
86+
ids = []
87+
for row in selection:
88+
if isinstance(row.get("sample_id"), str):
89+
ids.append(row["sample_id"])
90+
else:
91+
cd = row.get("customdata")
92+
if isinstance(cd, (list, tuple)) and cd and isinstance(cd[0], str):
93+
ids.append(cd[0])
8994
if ids:
9095
return (
9196
data[data["sample_id"].isin(ids)]

frontend/src/plugins/impl/plotly/selection.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,16 +361,33 @@ export function extractPoints(
361361
const trace = getTraceSource(point);
362362

363363
// FunnelArea: sector-based chart with no x/y coordinates.
364-
// Pick funnel-area-specific keys directly; hovertemplate parsing does not
365-
// apply since there are no axis values to substitute.
364+
// Pick funnel-area-specific keys, then merge any hovertemplate-parsed
365+
// fields (e.g. customdata columns) so user-defined fields are preserved.
366366
if (trace.type === "funnelarea") {
367-
return pick(point, FUNNEL_AREA_DATA_KEYS);
367+
const base = pick(point, FUNNEL_AREA_DATA_KEYS);
368+
const ht = Array.isArray(trace.hovertemplate)
369+
? trace.hovertemplate[0]
370+
: trace.hovertemplate;
371+
if (!ht) {
372+
return base;
373+
}
374+
parser = parser ? parser.update(ht) : createParser(ht);
375+
return { ...base, ...parser.parse(point) };
368376
}
369377

370378
// Funnel: bar-like chart with x/y plus per-stage percent metrics.
371-
// Return all funnel-specific keys so callers get percentInitial et al.
379+
// Pick funnel-specific keys, then merge hovertemplate-parsed fields so
380+
// callers get both percentInitial et al. and any user-defined columns.
372381
if (trace.type === "funnel") {
373-
return pick(point, FUNNEL_DATA_KEYS);
382+
const base = pick(point, FUNNEL_DATA_KEYS);
383+
const ht = Array.isArray(trace.hovertemplate)
384+
? trace.hovertemplate[0]
385+
: trace.hovertemplate;
386+
if (!ht) {
387+
return base;
388+
}
389+
parser = parser ? parser.update(ht) : createParser(ht);
390+
return { ...base, ...parser.parse(point) };
374391
}
375392

376393
const standardPointFields = withInferredXY(

0 commit comments

Comments
 (0)