mxImageExport

Creates a new image export instance to be used with an export canvas.  Here is an example that uses this class to create an image via a backend using <mxXmlExportCanvas>.

var xmlDoc = mxUtils.createXmlDocument();
var root = xmlDoc.createElement('output');
xmlDoc.appendChild(root);

var xmlCanvas = new mxXmlCanvas2D(root);
var imgExport = new mxImageExport();
imgExport.drawState(graph.getView().getState(graph.model.root), xmlCanvas);

var bounds = graph.getGraphBounds();
var w = Math.ceil(bounds.x + bounds.width);
var h = Math.ceil(bounds.y + bounds.height);

var xml = mxUtils.getXml(root);
new mxXmlRequest('export', 'format=png&w=' + w +
     '&h=' + h + '&bg=#F9F7ED&xml=' + encodeURIComponent(xml))
     .simulate(document, '_blank');

In order to export images for a graph whose container is not visible or not part of the DOM, the following workaround can be used to compute the size of the labels.

mxText.prototype.getTableSize = function(table)
{
  var oldParent = table.parentNode;

  document.body.appendChild(table);
  var size = new mxRectangle(0, 0, table.offsetWidth, table.offsetHeight);
  oldParent.appendChild(table);

  return size;
};
Summary
mxImageExportCreates a new image export instance to be used with an export canvas.
Functions
mxImageExportConstructs a new image export.
Variables
includeOverlaysSpecifies if overlays should be included in the export.
glassSizeReference to the thread while the animation is running.
shapesHolds implementations for the built-in shapes.
markersHolds implementations for the built-in markers.
Functions
drawStateDraws the given state and all its descendants to the given canvas.
createShapeCreates a shape wrapper for the custom shape in the given cell state and links its output to the given canvas.
drawOverlaysDraws the overlays for the given state.
drawShapeDraws the given state to the given canvas.
drawGlassDraws the given state to the given canvas.
drawGlassDraws the given state to the given canvas.
drawImageDraws the given state to the given canvas.
drawLabelBackgroundDraws background for the label of the given state to the given canvas.
drawLabelDraws the given state to the given canvas.
getBackgroundBoundsDraws the given state to the given canvas.
getImageBoundsDraws the given state to the given canvas.
drawMarkerInitializes the built-in shapes.
initShapesInitializes the built-in shapes.
initMarkersInitializes the built-in markers.

Functions

mxImageExport

function mxImageExport()

Constructs a new image export.

Variables

includeOverlays

mxImageExport.prototype.includeOverlays

Specifies if overlays should be included in the export.  Default is false.

glassSize

mxImageExport.prototype.glassSize

Reference to the thread while the animation is running.

shapes

mxImageExport.prototype.shapes

Holds implementations for the built-in shapes.

markers

mxImageExport.prototype.markers

Holds implementations for the built-in markers.

Functions

drawState

mxImageExport.prototype.drawState = function(state,
canvas)

Draws the given state and all its descendants to the given canvas.

createShape

mxImageExport.prototype.createShape = function(state,
canvas)

Creates a shape wrapper for the custom shape in the given cell state and links its output to the given canvas.

drawOverlays

mxImageExport.prototype.drawOverlays = function(state,
canvas)

Draws the overlays for the given state.  This is called if includeOverlays is true.

drawShape

mxImageExport.prototype.drawShape = function(state,
canvas,
shape)

Draws the given state to the given canvas.

drawGlass

Draws the given state to the given canvas.

drawGlass

mxImageExport.prototype.drawGlass = function(state,
canvas,
bounds,
shape,
size)

Draws the given state to the given canvas.

drawImage

mxImageExport.prototype.drawImage = function(state,
canvas,
bounds,
image)

Draws the given state to the given canvas.

drawLabelBackground

mxImageExport.prototype.drawLabelBackground = function(state,
canvas,
bounds,
vert)

Draws background for the label of the given state to the given canvas.

drawLabel

mxImageExport.prototype.drawLabel = function(state,
canvas,
bounds,
vert,
str)

Draws the given state to the given canvas.

getBackgroundBounds

mxImageExport.prototype.getBackgroundBounds = function(state)

Draws the given state to the given canvas.

getImageBounds

mxImageExport.prototype.getImageBounds = function(state)

Draws the given state to the given canvas.

drawMarker

mxImageExport.prototype.drawMarker = function(canvas,
state,
source)

Initializes the built-in shapes.

initShapes

mxImageExport.prototype.initShapes = function()

Initializes the built-in shapes.

initMarkers

mxImageExport.prototype.initMarkers = function()

Initializes the built-in markers.

function mxImageExport()
Constructs a new image export.
mxImageExport.prototype.includeOverlays
Specifies if overlays should be included in the export.
mxImageExport.prototype.glassSize
Reference to the thread while the animation is running.
mxImageExport.prototype.shapes
Holds implementations for the built-in shapes.
mxImageExport.prototype.markers
Holds implementations for the built-in markers.
mxImageExport.prototype.drawState = function(state,
canvas)
Draws the given state and all its descendants to the given canvas.
mxImageExport.prototype.createShape = function(state,
canvas)
Creates a shape wrapper for the custom shape in the given cell state and links its output to the given canvas.
mxImageExport.prototype.drawOverlays = function(state,
canvas)
Draws the overlays for the given state.
mxImageExport.prototype.drawShape = function(state,
canvas,
shape)
Draws the given state to the given canvas.
mxImageExport.prototype.drawGlass = function(state,
canvas,
bounds,
shape,
size)
Draws the given state to the given canvas.
mxImageExport.prototype.drawImage = function(state,
canvas,
bounds,
image)
Draws the given state to the given canvas.
mxImageExport.prototype.drawLabelBackground = function(state,
canvas,
bounds,
vert)
Draws background for the label of the given state to the given canvas.
mxImageExport.prototype.drawLabel = function(state,
canvas,
bounds,
vert,
str)
Draws the given state to the given canvas.
mxImageExport.prototype.getBackgroundBounds = function(state)
Draws the given state to the given canvas.
mxImageExport.prototype.getImageBounds = function(state)
Draws the given state to the given canvas.
mxImageExport.prototype.drawMarker = function(canvas,
state,
source)
Initializes the built-in shapes.
mxImageExport.prototype.initShapes = function()
Initializes the built-in shapes.
mxImageExport.prototype.initMarkers = function()
Initializes the built-in markers.
Close