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

Region map should respect saved center and zoom #12883

Merged

Conversation

thomasneirynck
Copy link
Contributor

@thomasneirynck thomasneirynck commented Jul 14, 2017

Release Note: The location of the map is now stored correctly when saving a Region Map.

closes #12189.

@thomasneirynck thomasneirynck added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) v5.5.1 v5.6.0 v6.0.0 review labels Jul 14, 2017

const saveCurrentLocation = () => {
//to ensure we dirty the state of the viz. (not sure why this is required. Tilemap visualization does not require it)
$scope.vis.params.mapZoom = kibanaMap.getZoomLevel();
Copy link
Member

Choose a reason for hiding this comment

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

this should be stored to uiState as it is modified on dashboard (without editor)

Copy link
Member

Choose a reason for hiding this comment

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

oh i see its already stored in uiState ... why do you need this then ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right. I don't know, maybe I got in a weird state....

const uiState = $scope.vis.getUiState();
const zoomFromUiState = parseInt(uiState.get('mapZoom'));
const centerFromUIState = uiState.get('mapCenter');
options.zoom = !isNaN(zoomFromUiState) ? zoomFromUiState : $scope.vis.type.visConfig.defaults.mapZoom;
Copy link
Member

Choose a reason for hiding this comment

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

if you store the center and zoom in ui state this won't be needed

Copy link
Member

Choose a reason for hiding this comment

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

if its not in uiState you should just fallback to a fixed setting, no need to define it on visConfig

Copy link
Member

@ppisljar ppisljar Jul 19, 2017

Choose a reason for hiding this comment

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

const defaultOptions = {
   zoom: 2,
   mapCenter: [0, 0]
};

const options = _.defaultsDeep({}, {
  zoom: parseInt(uiState.get('mapZoom'),
  mapCenter: uiState.get('mapCenter'),
  ...minMaxZoom
}, defaultOptions);

in other visualizations we do something like this ...

selectedJoinField: selectedJoinField
selectedJoinField: selectedJoinField,
mapZoom: 2,
mapCenter: [0, 0]
Copy link
Member

Choose a reason for hiding this comment

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

if you put it in uiState you'll need to init it when you create your chart there (if its not yet present)

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

works nice ... some minor comments

@thomasneirynck
Copy link
Contributor Author

thomasneirynck commented Jul 18, 2017

you're right, saving in ui-state is sufficient. not sure why I missed it. besides, it struck me that we didn't need it in tilemap either. Removed the crufty statement

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

i think you missed my comment regarding storing things that are not configurable in editor in vis.params ...
i think you should not be storing map center and map zoom there, as this are uiState settings (right now they are both present in URL twice for this reason)

above in the comment i also suggested a diff approach (something all the other visualizations are doing)

@epixa epixa added v5.5.2 and removed v5.5.1 labels Jul 21, 2017
@thomasneirynck
Copy link
Contributor Author

thx, sorry I missed that improvement. Updated with latest commit.

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

LGTM

@stacey-gammon
Copy link
Contributor

It looks like one you edit the location in dashboard, it will no longer reset to the new saved map center value from the visualization. I guess this is expected, similar to the issue/"feature" with saved searches and overriding default columns/sort order (#9523)

I suppose this is an improvement then the prior implementation, but we may want to think more about how to sync the dashboard panel overridden state back with the original visualization.

@thomasneirynck
Copy link
Contributor Author

@stacey-gammon, yeah, this PR is not supposed to fix that.This one needs to fix primarily the original issue that Region Map does not save the current zoom/center when pressing the save-button.

but agreed that maintaning dashboard-state will need some resolution at some point. Not sure what the right way forward on that one is though...

@thomasneirynck thomasneirynck merged commit 5e9a4ec into elastic:master Jul 27, 2017
thomasneirynck added a commit to thomasneirynck/kibana that referenced this pull request Jul 27, 2017
thomasneirynck added a commit to thomasneirynck/kibana that referenced this pull request Jul 27, 2017
thomasneirynck added a commit to thomasneirynck/kibana that referenced this pull request Jul 27, 2017
@thomasneirynck
Copy link
Contributor Author

thomasneirynck commented Jul 27, 2017

Backports:
5.5: #13187
5.6/5.x: #13171
6.0: #13170
6.x: #13169

@ppisljar
Copy link
Member

regarding the dashboard comment above:
doesn't this behave the same was as the colors (should) ?

so in visualization you can define your center (or colors). when you put this viz on dashboard it will show as you set it. however you can now do additional changes (move it, change some colors) on the dashboard and save this. now you share this dashboard with somebody, he is gonna see the version you saved with dashboard. he can still move around and change the colors even. however the last colors and position are only stored for him specifically (until he hard refreshes ...)

or does center location behave differently somehow ?

@stacey-gammon
Copy link
Contributor

Kind of - the "until he hard refreshes" part depends. If the dashboard was saved after the map center/color changes were made, then it's stuck with the custom colors and map positions unless the visualization is removed and re-added. That's the only way to sync back to the original visualization.

But you are right, map center behaves just like the other overridable panel states, like color. It's just a confusing interaction IMO, that you can override state and never get it back. Especially when some of these actions can happen in view mode, then the user can go into edit mode, make an unrelated change, save, and now they are also stuck with the changes they made in view mode.

But this is a whole different can of worms, something the sharing team will have to figure out. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:fix review v5.5.2 v5.6.0 v6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When adding a region map to the Dashboard, it does not center correctly on the previously saved position
4 participants