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

Vue3 - Cannot read property '_c' of undefined #67

Open
thespacedeck opened this issue Oct 1, 2020 · 5 comments
Open

Vue3 - Cannot read property '_c' of undefined #67

thespacedeck opened this issue Oct 1, 2020 · 5 comments
Labels
needs repro Reproduction steps needed

Comments

@thespacedeck
Copy link

Hi there,

I cannot seem to get vue2vis to work in vue3. I did a simple implementation and seems to crash at:

var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:"visualization"})}

Neither _self or $createElement is available.

Could you perhaps assist?

Thanks,
Wzz

@alexcode alexcode added enhancement needs repro Reproduction steps needed labels Nov 9, 2020
@erlebach
Copy link

I have tried to create a Vue-3 container for vis-network. I got issues related to strict mode. Some how all vis functions ended up with problems in their argument TS. Here is a snapshot.

@shambu2k
Copy link

Here is a codesandbox link which reproduces this issue with graph2d. Note that vue version in the sandbox is 3.2.6.
Please take a look @alexcode

@webmalex
Copy link

webmalex commented Jan 6, 2022

example for vue 3:

<template>
  <q-inner-loading :showing="loading">
    <q-spinner-ball size="50px" color="primary"/>
  </q-inner-loading>
  <div ref="root"/>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { Network } from 'vis-network';
import API from 'src/services/api';

export default defineComponent({
  name: 'vis',
  data(): {
    vis: Network | null,
    loading: boolean
  } {
    return {
      loading: false,
      vis: null,
    };
  },
  async mounted() {
    try {
      this.loading = true;
      var data: any = await API.core.vis(this.$route.query);
    } catch (error) {
      const message = 'Error vis';
      this.$q.notify({ type: 'negative', message: message });
      console.log(message, error, data);
    } finally {
      this.loading = false;
    }
    if (data != undefined) {
      const el : HTMLElement | any = this.$refs.root;
      this.vis = new Network(el, data['graph'], {});
      this.vis.once('afterDrawing', () => {
        el.style.height = '100vh'
      });
    };
  },
  beforeUnmount() {
    this.vis?.destroy();
  }
});
</script>

@webmalex
Copy link

webmalex commented Jan 6, 2022

minimum for typescript and vue 3:

<template>
  <div ref="root"/>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { Network } from 'vis-network';

export default defineComponent({
  name: 'vis',
  data(): {
    vis: Network | null,
  } {
    return {
      vis: null,
    };
  },
  mounted() {
      const el : HTMLElement | any = this.$refs.root;
      this.vis = new Network(el, {nodes: ...}, {});
      this.vis.once('afterDrawing', () => {
        el.style.height = '100vh'
      });
    };
  },
  beforeUnmount() {
    this.vis?.destroy();
  }
});
</script>

@alexcode
Copy link
Owner

Sorry for the very late reply. @shambu2k you are using the vue2 version of vue2vis. You must migrate to the new package of the repo by modifying the imports to:

import { Graph2d } from "@vue2vis/graph2d";
import "vis-timeline/styles/vis-timeline-graph2d.css";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Reproduction steps needed
Projects
None yet
Development

No branches or pull requests

5 participants