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; };
mxImageExport | Creates a new image export instance to be used with an export canvas. |
Functions | |
mxImageExport | Constructs a new image export. |
Variables | |
includeOverlays | Specifies if overlays should be included in the export. |
glassSize | Reference to the thread while the animation is running. |
shapes | Holds implementations for the built-in shapes. |
markers | Holds implementations for the built-in markers. |
Functions | |
drawState | Draws the given state and all its descendants to the given canvas. |
createShape | Creates a shape wrapper for the custom shape in the given cell state and links its output to the given canvas. |
drawOverlays | Draws the overlays for the given state. |
drawShape | Draws the given state to the given canvas. |
drawGlass | Draws the given state to the given canvas. |
drawGlass | Draws the given state to the given canvas. |
drawImage | Draws the given state to the given canvas. |
drawLabelBackground | Draws background for the label of the given state to the given canvas. |
drawLabel | Draws the given state to the given canvas. |
getBackgroundBounds | Draws the given state to the given canvas. |
getImageBounds | Draws the given state to the given canvas. |
drawMarker | Initializes the built-in shapes. |
initShapes | Initializes the built-in shapes. |
initMarkers | Initializes the built-in markers. |
mxImageExport.prototype.drawOverlays = function( state, canvas )
Draws the overlays for the given state. This is called if includeOverlays is true.
Constructs a new image export.
function mxImageExport()
Specifies if overlays should be included in the export.
mxImageExport.prototype.includeOverlays
Reference to the thread while the animation is running.
mxImageExport.prototype.glassSize
Holds implementations for the built-in shapes.
mxImageExport.prototype.shapes
Holds implementations for the built-in markers.
mxImageExport.prototype.markers
Draws the given state and all its descendants to the given canvas.
mxImageExport.prototype.drawState = 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.createShape = function( state, canvas )
Draws the overlays for the given state.
mxImageExport.prototype.drawOverlays = function( state, canvas )
Draws the given state to the given canvas.
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 background for the label of the given state to the given canvas.
mxImageExport.prototype.drawLabelBackground = function( state, canvas, bounds, vert )
Draws 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 )
Initializes the built-in shapes.
mxImageExport.prototype.drawMarker = function( canvas, state, source )
Initializes the built-in shapes.
mxImageExport.prototype.initShapes = function()
Initializes the built-in markers.
mxImageExport.prototype.initMarkers = function()