Graph are not drawn in nuxt3
See original GitHub issueI’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 - 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:
- Created a year ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@murawakimitsuhiro I’ve got the same issue with vue3 (not nuxt) and your code fixed it, thanks !
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-angularmy 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?