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

There is a way to re-render the graph according to width to the window to make it respnsive? #7

Open
dhertzb opened this issue Aug 20, 2019 · 2 comments

Comments

@dhertzb
Copy link

dhertzb commented Aug 20, 2019

No description provided.

@dhertzb dhertzb changed the title There is a way to re-render the graph according to width to the window? There is a way to re-render the graph according to width to the window to make it respnsive? Aug 20, 2019
@pcm0nk
Copy link

pcm0nk commented Sep 2, 2019

The way i made it responsive was putting it in a responsive box and made it center , then getting the width of that box minus one hundered would be the width of my funnel

         var element =  document.getElementById('cardbox')
    this.thefunnelwidth = element.offsetWidth - 100

and in the funnel component

<funnelcomponent v-if="thefunnelwidth != ''" :width="this.thefunnelwidth"></funnelcomponent>

the v-if holds the component from rendering if the funnelwidth is not set
you can do the same with height if its needed and some minor adjustment.

@nullablebool
Copy link

It would be great to see support for this. A more robust approach, to support resizing, would be:

    <vue-funnel-graph
      :width="$refs.wrapper && $refs.wrapper.offsetWidth"
      ...
      v-if="isFunnelVisible"
    />
  data() {
    return {
      isFunnelVisible: false,
      resizeTimeout: null
    };
  },
  mounted() {
    this.isFunnelVisible =
      this.$refs.wrapper && this.$refs.wrapper.offsetWidth > 0;
    window.addEventListener('resize', this.handleResize);
  },
  methods: {
    handleResize() {
      if (this.resizeTimeout) clearTimeout(this.resizeTimeout);
      this.resizeTimeout = setTimeout(() => {
        this.isFunnelVisible = false;
        this.$nextTick(() => {
          this.isFunnelVisible = true;
        });
      }, 200);
    }
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.handleResize);
  }

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

3 participants