Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist current #g.xx graph settings across page reloads #12

Closed
simonw opened this issue Jul 6, 2018 · 2 comments
Closed

Persist current #g.xx graph settings across page reloads #12

simonw opened this issue Jul 6, 2018 · 2 comments

Comments

@simonw
Copy link
Owner

simonw commented Jul 6, 2018

e.g. here: https://fivethirtyeight.datasettes.com/fivethirtyeight-ac35616?sql=select+user%2C+state%2C+sum%28retweets%29+as+rt+from+%5Btwitter-ratio%2Fsenators%5D+group+by+user%2C+state+order+by+rt+desc+limit+20#g.mark=bar&g.x_column=user&g.x_type=ordinal&g.y_column=rt&g.y_type=quantitative&g.color_column=state

It should be possible to edit the SQL (to increase the limit for example), click "Run SQL" and have the current graph state apply to the new page.

This can be done by having JavaScript modify the form action and turn it into the following:

<form class="sql" 
  method="get" 
  action="/fivethirtyeight-ac35616#g.mark=bar&amp;g.x_column=user&amp;g.x_type=ordinal&amp;g.y_column=rt&amp;g.y_type=quantitative&amp;g.color_column=state"
>

Browsers will then maintain the fragment hash when the form is submitted.

@simonw
Copy link
Owner Author

simonw commented Jul 6, 2018

Ideally this would work for regular links too, e.g. the facet selection links on this page: https://fivethirtyeight.datasettes.com/fivethirtyeight-ac35616/antiquities-act%2Factions_under_antiquities_act?_facet=current_agency#g.mark=circle&g.x_column=states&g.x_type=nominal&g.y_column=year&g.y_type=nominal

Again, JavaScript could do this either by modifying those links in the DOM or by intercepting click events and turning them into navigations to that URL + the current fragment hash. I'm not sure which would work better.

@simonw simonw closed this as completed Jul 6, 2018
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

No branches or pull requests

1 participant