Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Canvas Height and Width are Zero #17

Open
lrpatterson opened this issue Jul 1, 2021 · 0 comments
Open

Canvas Height and Width are Zero #17

lrpatterson opened this issue Jul 1, 2021 · 0 comments

Comments

@lrpatterson
Copy link

I am trying to integrate this library with svelte and I am using rollup up to bundle everything together. Look like all the DOM nodes have been added but the canvas node has a width and height of zero. I have added my code/error msg below. Can't figure out why canvas width/height is always zero.

import {onMount, tick} from 'svelte'
import ElGrapho from 'elgrapho'



let container
let graph
let model = {
    nodes: [
      {x: 0,    y: 0.6,  group: 0, label: 0},
      {x: -0.4, y: 0,    group: 1, label: 1},
      {x: 0.4,  y: 0,    group: 1, label: 2},
      {x: -0.6, y: -0.6, group: 2, label: 3},
      {x: -0.2, y: -0.6, group: 2, label: 4},
      {x: 0.2,  y: -0.6, group: 2, label: 5},
      {x: 0.6,  y: -0.6, group: 2, label: 6}
    ],
    edges: [
      {from: 0, to: 1},
      {from: 0, to: 2},
      {from: 1, to: 3},
      {from: 1, to: 4},
      {from: 2, to: 5},
      {from: 2, to: 6}
    ]
  }



async function diagramInit(){
	graph = new ElGrapho({
		container: container,
		model: model,
		height: 500,
		width: 500
	})
}


onMount(diagramInit)
Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.
    at xxxxxxxx/build/bundle.js:8:74837
    at Array.forEach (<anonymous>)
    at o.Viewport.render (xxxxxxxxxxx/build/bundle.js:8:74795)
    at xxxxxxxxx/build/bundle.js:8:108609
    at Array.forEach (<anonymous>)
    at executeFrame (xxxxx/build/bundle.js:8:108073)

image

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant