Skip to content

Time slider#421

Merged
martinRenou merged 59 commits intogeojupyter:mainfrom
gjmooney:time_slider
Feb 13, 2025
Merged

Time slider#421
martinRenou merged 59 commits intogeojupyter:mainfrom
gjmooney:time_slider

Conversation

@gjmooney
Copy link
Collaborator

@gjmooney gjmooney commented Jan 31, 2025

Description

First attempt at adding a way to display features based on a time field.
Still very much a wip. Right now this works if the selected time feature is a date string (if that string is in one of a few formats).
It also 'works' if the feature is a number, but it's hard to distinguish between a timestamp and any other number, so this requires some vigilance from the user when selecting the feature to use.

I'm also not sure how the UI should look. @martinRenou suggested a double-ended slider to control start and end dates, unfortunately the slider in jupyter-ui-toolkit doesn't support that, but there's plenty of sliders that do. I'm open to any feedback on this.

Edit: Final iteration of UI:
finaltime2

Checklist

  • PR has a descriptive title and content.
  • PR description contains references to any issues the PR resolves, e.g. Resolves #XXX.
  • PR has one of the labels: documentation, bug, enhancement, feature, maintenance
  • Checks are passing.
    Failing lint checks can be resolved with:
    • pre-commit run --all-files
    • jlpm run lint

📚 Documentation preview: https://jupytergis--421.org.readthedocs.build/en/421/
💡 JupyterLite preview: https://jupytergis--421.org.readthedocs.build/en/421/lite

@github-actions
Copy link
Contributor

Binder 👈 Launch a Binder on branch gjmooney/jupytergis/time_slider

@martinRenou
Copy link
Member

martinRenou commented Jan 31, 2025

Amazing work!

I'm also not sure how the UI should look. @martinRenou suggested a double-ended slider to control start and end dates

I guess I'm only confused about the meaning of the slider position right now. It looks like the blue part (highlighted part) of the slider is the data range we DO NOT show, while the gray part is what we show, which I find a tiny bit confusing.
Is it the QGIS time slider behavior, if it has any?

I would easily make sense of a range slider since it's clear that you'd show only the features within this time range.

@gjmooney
Copy link
Collaborator Author

Amazing work!

I'm also not sure how the UI should look. @martinRenou suggested a double-ended slider to control start and end dates

I guess I'm only confused about the meaning of the slider position right now. It looks like the blue part (highlighted part) of the slider is the data range we DO NOT show, while the gray part is what we show, which I find a tiny bit confusing. Is it the QGIS time slider behavior, if it has any?

I would easily make sense of a range slider since it's clear that you'd show only the features within this time range.

For reference, this is what the QGIS version looks like:
timeqgis

@mfisher87
Copy link
Member

Awesome!!!

It would be wonderful to have a play/pause (and framerate) control :) Do you think that should be a separate PR?

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2025

Integration tests report: appsharing.space

@gjmooney gjmooney added the enhancement New feature or request label Feb 5, 2025
@gjmooney gjmooney marked this pull request as ready for review February 6, 2025 11:51
@gjmooney gjmooney force-pushed the time_slider branch 2 times, most recently from 67a97ce to 3618cb9 Compare February 6, 2025 14:27
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That looks amazing

I played a bit with it, some things I noticed:

Toggling the time controls panel makes the bottom toolbar disappear

Screencast.From.2025-02-07.09-51-53.mp4

The time controls panel does not update itself upon layer selection

To reproduce:

  • Open the earthquakes.jGIS doc
  • Do not select any layer yet
  • Open the time controls panel (it should say "You need to select a layer")
  • Select a layer

-> The time controls panel does not update itself automatically

Probably related to the one above, the time controls panel button in the toolbar should be disabled if there is no selection OR if the current selection is a multi-selection OR if the selected object is a source, not a layer

It seems I cannot even make the time slider work on earthquakes.jGIS, even though the feature "time" is selected. Nothing shows up

Screencast.From.2025-02-07.09-59-00.mp4

newSource = new VectorSource({
features: featureCollection
});
console.log('finish');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('finish');

@gjmooney
Copy link
Collaborator Author

gjmooney commented Feb 7, 2025

Thanks! That looks amazing

I played a bit with it, some things I noticed:

The time controls panel does not update itself upon layer selection

-> The time controls panel does not update itself automatically

I swear this used to work 😿

Probably related to the one above, the time controls panel button in the toolbar should be disabled if there is no selection OR if the current selection is a multi-selection OR if the selected object is a source, not a layer

👍

It seems I cannot even make the time slider work on earthquakes.jGIS, even though the feature "time" is selected. Nothing shows up

This was because the range for the earthquake data is only a month, if you went to days for the step it would've worked. I added a check to only display steps that make sense with the data.

All these should be resolved now.
timefix

@martinRenou
Copy link
Member

So now my last question is, did you find a correlation between earthquakes and pirate attacks? 😆

@gjmooney
Copy link
Collaborator Author

gjmooney commented Feb 7, 2025

So now my last question is, did you find a correlation between earthquakes and pirate attacks? 😆

Turns out pirates are actually an earthquake deterrent.

Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks amazing really, but I still have comments/suggestions 😄

When there is only one selectable feature, should we automatically select it?

"348d85fa-3a71-447f-8a64-e283ec47cc7c": {
"name": "Custom GeoJSON Layer Source",
"parameters": {
"path": "../../examples/eq.json"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious to know why the path changed, we may have a bug somewhere around the file selector. This path change makes it fail when I try to load that file in JupyterLite, it should stay:

Suggested change
"path": "../../examples/eq.json"
"path": "eq.json"

@martinRenou martinRenou added this to the 0.4.0 milestone Feb 7, 2025
@gjmooney
Copy link
Collaborator Author

gjmooney commented Feb 7, 2025

Animation works in lite now, this slider is weird.

timelite

@gjmooney
Copy link
Collaborator Author

gjmooney commented Feb 7, 2025

please update snapshots

const playAnimation = () => {
// Clear any existing interval first
if (intervalRef.current) {
clearInterval(intervalRef.current);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen this interval thingy, I'm more familiar with the requestAnimationFrame, could it be more reliable for browser animation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's related to that. The html version of slider has valuesasnumber, valuenow, and current-value attributes in lite, but in lab it has value and current-value (I don't know why they change). The callback in the interval changes currentValue in the component correctly, but for some reason only setting the valueAsNumber prop works in lab (setting value instead of valueAsNumber make the slider out of sync with the actual value), but in lite the slider is based on the value prop.

That's a long way of saying the interval was happening correctly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, could JupyterLite be providing an outdated version of the ui-toolkit that provides that slider?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like lite is using 0.16.7 and we're on 0.16.6, but they should both resolve to 0.16.7

@gjmooney
Copy link
Collaborator Author

gjmooney commented Feb 7, 2025

please update snapshots

1 similar comment
@gjmooney
Copy link
Collaborator Author

please update snapshots

Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more things I noticed while testing:

  • The feature on which to run the time controls should be selected automatically when opening the controls (first one from the list)
  • If we remove the layer on which the time controls are running, we should close the time controls
  • If I open the time controls, play with the animation a bit, then change the symbology of the vector layer to e.g. a heatmap, the time controls stop working

@gjmooney
Copy link
Collaborator Author

Some more things I noticed while testing:

* The feature on which to run the time controls should be selected automatically when opening the controls (first one from the list)

* If we remove the layer on which the time controls are running, we should close the time controls

* If I open the time controls, play with the animation a bit, then change the symbology of the vector layer to e.g. a heatmap, the time controls stop working

The first two are done. For now I just made the controller close when changing to a heatmap. I'm trying to get the slider to work with heatmap layers, but no luck with that so far.

Copy link
Member

@mfisher87 mfisher87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩 Wow, there's a lot here. How'd you get this done so fast? 😅 Amazing work 🤩

Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Quite a lot of work done here :D

@martinRenou martinRenou merged commit 142a554 into geojupyter:main Feb 13, 2025
13 checks passed
@gjmooney gjmooney deleted the time_slider branch February 13, 2025 13:11
HaudinFlorence pushed a commit to HaudinFlorence/jupytergis that referenced this pull request Jan 28, 2026
* Refactor getFeature stuff

* Add toolbar item

* Add temporal boolean

* Start adding time slider thing

* Continue

* New example

* wip

* Add date-fns and examples

* wip

* Saving

* I think it works

* wip

* Still works

* Clean up slider

* Add CSS class

* Emit signal on feature select

* Examples

* Use awareness to hold time boolean

* UI tweak

* UI rework

* Refactor filters logic

* Make the icon toggleable

* Refactor adding filter in slider component

* Do time filtering in memory

* Save

* CSS

* Clean up

* Fix state check

* Add FPS control

* Update commands

* yarrr

* Fix layer selecting

* Only display steps that make sense

* Enable/Disabel toolbar button based on selection

* Clean up

* Fix CSS for mainview

* Add raster layer check

* Clean up

* Actually use state

* Clear filter when closing

* Fix animate in lite

* Add borders

* Remove status bar border and restore screenshots

* Remove filter from example

* Select default feature

* Pass commands to mainview

* Close on layer deleteion or type change

* Set default step correctly

* Suggestions

* Heatmap wip

* Remove feature from schema

* Enable for heatmap layers

* Close

* Heatmaps work?

* Tweak

* State restore wip

* Set filter states in mainview

* Fixed

* Clean up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants