Repository navigation
Description
Problem
heatmapZFiniteExtent (flexviz/adapters/js/plotly/traces.js) reads z as rows of cells. A heatmap has that shape. A choropleth (geo_histogram2d) has a flat z, one value per drawn cell. The inner loop then throws TypeError: (row || []) is not iterable.
Two callers pass a choropleth z when a geo_histogram2d is the target of an overlay cross-filter:
syncHeatmapOverlayColorScale, for an autocolor_rangewith a linearcolor_norm. The error stops the render: the map shows only the background layer, and the figure logsflexviz render failed for figure ….heatmapHasRenderableCells, whichfvFinalizeHeatmapOverlayColorbarscalls after the render. Withcolor_norm="log"(PR feat(heatmap): add color_norm with a log option to histogram2d and geo_histogram2d #95), the render gets past the sync, because the log norm sets its own range. Then this call throws an uncaught error. Both layers draw, but the colorbar stays on the background layer.
Reachability
Public API only: a dashboard with a geo_histogram2d and another figure, overlay mode, and a selection on the other figure. Reproduced in a browser on feat/heatmap-color-norm (f396838), with a linear and with a log norm. The linear auto-range path is the same code on main.
Fix
Let heatmapZFiniteExtent read both shapes, so that every caller works:
// z is 2-D for a heatmap and flat for a choropleth.
const rows = Array.isArray(z && z[0]) ? z : [z || []];
for (const row of rows) {Checked in a scratch copy of the branch: with this change, both norms draw both layers, the colorbar moves to the filtered layer, and the console has no errors.
Regression test
For tests/test_browser.py, for example in TestHeatmapColorNormBrowser (it uses _color_norm_url from PR #95). It fails on f396838 for both norms, because the colorbar never moves to the filtered layer. It passes with the fix.
Browser test
@pytest.mark.parametrize("color_norm", ["linear", "log"])
def test_geo_histogram2d_overlay_target_renders_both_layers(
self, page: Page, server_port: int, color_norm
):
errors: list[str] = []
page.on("pageerror", lambda exc: errors.append(str(exc)))
page.on(
"console",
lambda msg: (
errors.append(msg.text) if "render failed" in msg.text else None
),
)
df = pl.DataFrame(
{
"ts": list(range(500)),
"val": [float(i) for i in range(500)],
"lat": [float(i % 25) for i in range(500)],
"lon": [float((i * 7) % 25) for i in range(500)],
}
)
def build(dash):
dash.add_figure(title="Source").add_line(x="ts", y="val", n_points=200)
dash.add_figure(title="Map").add_geo_histogram2d(
lat="lat", lon="lon", lat_bins=5, lon_bins=5, color_norm=color_norm
)
url = _color_norm_url(
server_port, f"_browser_geo_overlay_{color_norm}", df, build
)
page.goto(url)
_wait_for_init(page, "plotly")
page.click("#fv-btn-cfmode")
page.evaluate("""() => {
const figUids = DASHBOARD_SPEC.figures.map(f => f.uid);
DASHBOARD_SPEC.state.selections = [{
source_figure_uid: figUids[0],
predicates: [{ clauses: [{ column: 'ts', range: [100, 200] }] }],
}];
return postDashboardUpdate({
type: 'selection',
selections: DASHBOARD_SPEC.state.selections,
force_update: true,
});
}""")
# The colorbar moves to the filtered layer once the overlay render ends.
page.wait_for_function(
"""() => {
const gd = document.querySelectorAll('.js-plotly-plot')[1];
const fg = gd.data.find(t => t.uid.endsWith('__fv_layer_fg'));
return fg && fg.showscale === true;
}""",
timeout=10_000,
)
assert errors == []
Activity
jvdd commentedon Sep 26, 2026
Reproduced on unmodified
main(471c09b), not only on the PR #95 branch. Setup: a line figure and ageo_histogram2d(4x4 bins), overlay mode, then a selection on the line (tsin [50, 150]). The map keeps only its__fv_layer_bgtrace. The console logsflexviz render failed for figure … TypeError: (row || []) is not iterable at heatmapZFiniteExtent. The error is logged as a warning, so it stays silent: a map that is an overlay target never shows the filtered layer.jvdd commentedon Sep 29, 2026
Fixed by #103.