Create image without creating diagram

Hi,

Im using ajax to load my diagram with nodes (saved in a database).
Now the idea is to create a preview of what these saved diagram look like.

Is there a way to not load the whole diagram but still to create an image of the model that is saved?

I mean the easiest way would be to have something like:

myDiagram.model = go.Model.fromJson(data);
myDiagram.makeImage;

But this would populate my whole diagram already.

I don’t know how it would be possible to draw a diagram without creating the contents of the diagram.

But you don’t need to make the DIV for the Diagram be visible. Or is there some other concern that you have?

Well the thing is:
I have a load button which shows all possible models in a simple radio list.
If someone clicks on one of these radios, a preview image should be shown.

But I guess it’s not possible to show a preview image on the fly without populating the diagram first?

Another question though: when I save these models in a database (in the same format as myDiagram.model.toJson())… If i want to retrieve the database field using ajax, do I use a json dataType and encode the value? or simply as text?

There is no way to produce an image of a diagram without first creating the diagram. But that does not mean you could not use a thumb-nail image, which you could generate automatically on first demand and save for later views.

Regarding the data type for saving the model: I cannot answer that because it depends greatly on the database. You should find out from your database provider what the best datatype would be for JSON data based on your expected usage. It might be that there is no difference between a “json” data type and a “text” data type. Or it might be that there is a huge difference, permitting better queries or indexing or whatever. It depends on what you want to do and what the database does.

oke thanks for the answer :)