Skip to content

autoResize not working #20

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

Open
kjschiroo opened this issue May 30, 2019 · 8 comments
Open

autoResize not working #20

kjschiroo opened this issue May 30, 2019 · 8 comments

Comments

@kjschiroo
Copy link

autoResize doesn't appear to be working, and it looks like it might be a two part issue.

In this commit the code went from using the function generated by debounce as the event listener, to accidentally throwing that function away. The result here is that this.react never ends up getting called because the generated debouncing function never got called.

I would suspect that this snippet would fix that aspect of the problem

this.__resizeListener = debounce(() => {
  this.internalLayout.datarevision++
  this.react()
}, 200)

however javascript isn't my strongest language.

The second part of it is that even once this change is made and react gets called, it still doesn't appear to successfully resize the image. I haven't ruled out that just being part of my specific setup though. Thoughts?

@kjschiroo
Copy link
Author

Falling back to 0.2.0 does work in my setup.

@spacemudd
Copy link

I had some issues regarding the responsiveness, this works for me on latest:

options: {
            responsive: true,
          }

@glorat
Copy link

glorat commented Jan 9, 2020

autoResize doesn't appear to be working, and it looks like it might be a two part issue.

In this commit the code went from using the function generated by debounce as the event listener, to accidentally throwing that function away. The result here is that this.react never ends up getting called because the generated debouncing function never got called.

I would suspect that this snippet would fix that aspect of the problem

this.__resizeListener = debounce(() => {
  this.internalLayout.datarevision++
  this.react()
}, 200)

however javascript isn't my strongest language.

The second part of it is that even once this change is made and react gets called, it still doesn't appear to successfully resize the image. I haven't ruled out that just being part of my specific setup though. Thoughts?

This in conjunction with layout: {autosize:true} fixed everything for me

@ghost
Copy link

ghost commented Jan 9, 2020

autoResize doesn't appear to be working, and it looks like it might be a two part issue.
In this commit the code went from using the function generated by debounce as the event listener, to accidentally throwing that function away. The result here is that this.react never ends up getting called because the generated debouncing function never got called.
I would suspect that this snippet would fix that aspect of the problem

this.__resizeListener = debounce(() => {
  this.internalLayout.datarevision++
  this.react()
}, 200)

however javascript isn't my strongest language.
The second part of it is that even once this change is made and react gets called, it still doesn't appear to successfully resize the image. I haven't ruled out that just being part of my specific setup though. Thoughts?

This in conjunction with layout: {autosize:true} fixed everything for me

I am using this with Vuetify and the following code is resizing is working; options: { responsive: true }.

@glorat
Copy link

glorat commented Jan 10, 2020

@JLBlueDom that doesn't have effect for me. I suspect the difference is that you're putting the graph in a responsive layout (e.g. Vuetify/Bootstrap) whereas I'm using old school fixed container sizes.

Either way, if you agree this snippet is required, I'll create a fork and PR

glorat added a commit to glorat/vue-plotly that referenced this issue Jan 10, 2020
@ghost
Copy link

ghost commented Jan 10, 2020

@JLBlueDom that doesn't have effect for me. I suspect the difference is that you're putting the graph in a responsive layout (e.g. Vuetify/Bootstrap) whereas I'm using old school fixed container sizes.

Either way, if you agree this snippet is required, I'll create a fork and PR

Your suspicion may be correct. All I really know is it works perfectly in Vuetify. :)

@Tehsurfer
Copy link

Tehsurfer commented Feb 4, 2020

I use css-element-queries for this and it works smoothly with good performance

import ReziseSensor from "css-element-queries/src/ResizeSensor";
//....
mounted() {
 new ReziseSensor(this.$el, () => {
   this.$refs.plotly.relayout({
      width: this.$el.clientWidth,
      height: this.$el.parentElement.clientHeight
    })
  })
}

@SumNeuron
Copy link

@kjschiroo the solution is relatively simple. Wherever you make you component, on the component itself set:

<Plotly :autoResize="true"/>

See: #27 for more details as to why.

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

5 participants