I am able to get the SVG file now I wanted to know if there is a way to import this file back to the ej-diagram so that the shapes I have created would be automatically created. I tried searching in the documentation but could not find anything. |
By default, in the diagram, we want to set the nativeTemplate in the script. We cannot able to directly load the exported SVG in the diagram.
|
When I use the MODE as DATA in the EXPORT function then nothing happens. It does not throw the error as well so I am just confused why it does not export. |
HTML node cannot be exported to image format, like JPEG, PNG, and BMP. It is by design that while exporting, Diagram is drawn in a canvas. Further, this canvas is exported into image formats. Currently, drawing in a canvas equivalent from all possible HTML is not feasible. Hence, this limitation.
We have already mentioned this in the documentation
|
var nodes = [{
name: "NativeNode",
offsetX: 100,
offsetY: 100,
//Sets type as Native
type: ej.datavisualization.Diagram.Shapes.Native,
//Sets id of SVG element
templateId: "svgTemplate",
labels: [{
text: "Mail"
}]
}];
<!--dependency scripts-->
<script src="http://borismoore.github.io/jsrender/jsrender.min.js"></script>
<!--define html element-->
<script id="svgTemplate" type="text/x-jsrender">
<g>
<path d="M 58.813 0 H 3.182 L 30.998 24.141 L 58.813 0 Z M 32.644 34.425 C 32.133 34.87 31.567 35.095 31 35.095 S 29.867 34.87 29.353 34.425 L 1 9.826V 60 H 61 V 9.826 L 32.644 34.425Z"></path>
</g>
</script> |
var syncApp = angular.module('syncApp', ["ejangular"], function() {});
//Initializes Diagram
syncApp.controller('diagramCtrl', function($scope)
{
$scope.NodeAdd = function()
{
$scope.diagram = angular.element("#diagram").ejDiagram("instance");
var name = "Event"+$scope.nodeCounter;
$scope.diagram.model.drawType = {
type : ej.datavisualization.Diagram.Shapes.Native,
templateId : "svgTemplate"
};
var tool = $scope.diagram.tool();
$scope.diagram.update({ tool: tool | ej.datavisualization.Diagram.Tool.DrawOnce });
}
});
https://jsfiddle.net/B_AV_B/df3j2w98/5/
I am unable to add BUTTON within each SVG element that I am creating. Is it possible to add a button within each SVG element I am creating and add the click event? |
Button is an HTML element, we cannot able to add directly in SVG element.
For more information please refer to below link
|
Also, If I continue to use the HTML type then I would not have any alternative approach to EXPORT and IMPORT the NODE and templates back to my ej-diagram right? |
Yes, Currently, support to export the diagram into image format with the HTML nodes is not available. Since while exporting, the diagram will be drawn in a canvas, and then canvas is converted to image format. Currently, drawing in a canvas equivalent from all possible HTML is not feasible and rendering the SVG content in a canvas and convert canvas to image will get the security issues in IE browser.
|
If I use NATIVE then I can export the diagram that I have created and I can import them back, right? |
Like HTML node, Native node also cannot be exported to image format.
We have mentioned this limitation in the documentation. Please refer to below UG documentation link
|