question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Graph are not drawn in nuxt3

See original GitHub issue

I’m trying to use d3-graphviz with nuxt3. Here is the code I wrote.

<script setup lang="ts">
import * as d3 from 'd3'
import { onMounted, ref } from 'vue';
import { Graphviz, graphviz } from 'd3-graphviz';

const graphSvg = ref<HTMLDivElement>();
let graph: Graphviz<any, any, any, any>;

const render = () => {
  graph = graphviz(graphSvg.value as HTMLDivElement, {
    useWorker: false,
    width: 1000,
  })
      .dot(`digraph {a -> b}`)
      .render()
}

onMounted(async () => {
  render()

  setTimeout(() => {
    console.log('mounted rendered', graph)
  }, 3000)

  graph.onerror((errorMessage) => {
    console.log('graph vis error', errorMessage)
  })
});
</script>

<template>
  <div class="graph" ref="graphSvg" />
</template>

<style scoped>
.graph {
  min-height: 500px;
}
</style>

Here is what I have confirmed.

  • The defined variables are correctly assigned values and the console.log result after render returns the following
    • mounted rendered Graphviz {_options: {…}, _selection: Selection, _active: false, _busy: true, _jobs: Array(0), …}
  • I put a breakpoint in node_modules/d3-graphviz/src/redner.js:16 in Chrome DevTools, and it stops here
    • スクリーンショット 2022-03-23 22 24 30
  • It worked fine when I wrote other d3 methods within my render function (e.g., drawing a simple straight line)
    d3.select(graphSvg.value as HTMLDivElement)
      .append("svg")
      .append("line")
      .attr("x1", 20)
      .attr("y1", 5)
      .attr("x2", 300)
      .attr("y2", 200)
      .attr("stroke", "red")
    

I am concerned that _busy in the graphViz object is still true after waiting 3 seconds. Is this correct behavior?

Sorry if nuxt3 support should not be discussed here.

Thanks for your help.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
nicolidincommented, Mar 27, 2022

@murawakimitsuhiro I’ve got the same issue with vue3 (not nuxt) and your code fixed it, thanks !

2reactions
murawakimitsuhirocommented, Mar 24, 2022

I have solved this problem. Finally, I was able to get it to work by referencing your angular project and specifying the wasmFolder. https://github.com/magjac/d3-graphviz-angular

my code is here. https://github.com/murawakimitsuhiro/exgraph/blob/main/components/DotGraph.vue

I guess it seems to occur when some module bundler is used. Should I add this to the README and create a PR? Also, do you have any good solutions?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt 3 data is not displayed in the form - Stack Overflow
I am updating the data of an authorized user in my account. When I go through NuxtLink , the data is loaded from...
Read more >
Unable to import external Vue 3 component #2474 - GitHub
I'm working on adding graph functionality to my Nuxt 3 project, ... that it supports both Vue 3 and Vue 2 + the...
Read more >
The Nuxt 3 Crash Course - YouTube
This is 3 hours of a 9-hour course hosted on Udemy. You will learn everything you need to become a Nuxt 3 expert....
Read more >
How To Work With Meta Data in Nuxt - langvad.dev
Meta data is not visible on the page. It gets parsed by the browser and search engine crawlers. You can inspect a webpage...
Read more >
Building a Photo Sharing App with Nuxt 3, GraphQL ... - Strapi
We'll also look into how we can build our frontend using Nuxt 3 which ... to our auth pages depending on if session.user...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found