Coder Social home page Coder Social logo

Comments (5)

erlebach avatar erlebach commented on July 16, 2024

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.

from vue2vis.

shambu2k avatar shambu2k commented on July 16, 2024

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

from vue2vis.

webmalex avatar webmalex commented on July 16, 2024

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>

from vue2vis.

webmalex avatar webmalex commented on July 16, 2024

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>

from vue2vis.

alexcode avatar alexcode commented on July 16, 2024

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";

from vue2vis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.