0

I have been using cytoscape on a project for some time, but want to do some custom edits to the visualization which the API doesn't support. I can do these with the native canvas methods. However, once I update the canvas, the changes are not reflected in the downloaded image (generated from the .png() method).

After the graph has rendered, I am editing the canvas like this:

var canvas = $("canvas")[0];
var ctx = canvas.getContext("2d");
ctx.fillText("hello world", 100, 100);

While "hello world" is now visible, subsequent calls to .png() generate an image with no extra text. How can I make my custom changes show up in the image?

ragingsquirrel3
  • 415
  • 3
  • 12

1 Answers1

0

That workflow won't work, because you're modifying private data (i.e. the canvas) with the assumption that it will cause specific postconditions.

You could instead grab the PNG, pull that image into your own canvas, and then modify it however you like.

maxkfranz
  • 11,896
  • 1
  • 27
  • 36