Skip to content

Add start_index option to HeatMapWithTime. - #2348

Open
KhadeerBasha1232 wants to merge 1 commit into
python-visualization:mainfrom
KhadeerBasha1232:heatmapwithtime-start-index
Open

KhadeerBasha1232 wants to merge 1 commit into
python-visualization:mainfrom
KhadeerBasha1232:heatmapwithtime-start-index

Conversation

@KhadeerBasha1232

@KhadeerBasha1232 KhadeerBasha1232 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Add start_index to HeatMapWithTime

Closes #1243

HeatMapWithTime always opened on the first time step, because the template hardcoded currentTime: new Date(1). This adds a start_index parameter that picks the step the slider shows when the map loads:

HeatMapWithTime(data, index=hours, start_index=5)  # opens on the 6th step

Details

  • start_index is a 0-based position in data, matching how Python lists are indexed. Negative values count from the end, so -1 opens on the last step.
  • Out-of-range values raise a ValueError that names the allowed range.
  • The default is 0, so existing maps render exactly as before.
  • Empty data is not validated, so behaviour there is unchanged.

Tests

  • Parametrized tests check the rendered currentTime for 0, 5 and -1, and that 10 and -11 raise for 10 time steps.
  • The existing template test now uses start_index too.
  • I also checked a rendered map in a browser: with start_index=5, the slider opens on the 6th label and the heatmap shows that step's data.

CI note

The pre-commit.ci failure isn't from this change. Black wants two blank lines between two tests in tests/test_features.py, which also fails on main since #2307 and #2346 were merged. #2350 fixes it, and I'll rebase this PR once that's merged. All the test runs (Ubuntu, macOS, Windows × Python 3.11/3.14) pass.

Let users choose which time step the slider shows when the map opens,
instead of always starting at the first one. Negative values count from
the end, and out-of-range values raise a ValueError.

Closes python-visualization#1243

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
pypi — e78d558c Deployed Nov 16, 2026 by KhadeerBasha1232 via packages #2095
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is it possible to set the "index position" of the slider for a HeatMapWithTime?

1 participant