I have to create these image nodes dynamically. So, here is my code.
I get an unknown template JsRender Error.
var TemplateID = RenderImage("PupilImage" + i, t.Source, hexagon.name);
if (TemplateID)
{
var photo = { name: "native" + ej.datavisualization.Diagram.Util.randomId(), source: t.Source, parent: Pathnode.name, offsetX: Pathnode.offsetX + 20, offsetY: Pathnode.offsetY + 15, templateId: TemplateID, type: ej.datavisualization.Diagram.Shapes.Native, minWidth: 60, width: 60, maxWidth: 60, minHeight: 60, height: 60, maxHeight: 60, scale: "stretch", constraints: DiagramConstraints.Default & ~DiagramConstraints.PointerEvents & ~DiagramConstraints.Resize };
var detailCircle1 = { name: "detailCircle1" + i, labels: [{ name: "", text: "", bold: true, fontColor: "black", fontSize: 10, italic: false, readOnly: true, width: 50, wrapping: ej.datavisualization.Diagram.TextWrapping.Wrap }], minWidth: 25, width: 25, maxWidth: 25, minHeight: 25, height: 25, maxHeight: 25, type: "node", shape: BasicShapes.Ellipse, offsetX: photo.offsetX - 35, offsetY: photo.offsetY - 17, parent: Pathnode.name, constraints: DiagramConstraints.Default & ~DiagramConstraints.PointerEvents };
var detailCircle2 = { name: "detailCircle2" + i, labels: [{ name: "", text: "", bold: true, fontColor: "black", fontSize: 10, italic: false, readOnly: true, width: 50, wrapping: ej.datavisualization.Diagram.TextWrapping.Wrap }], minWidth: 25, width: 25, maxWidth: 25, minHeight: 25, height: 25, maxHeight: 25, type: "node", shape: BasicShapes.Ellipse, offsetX: photo.offsetX - 35, offsetY: photo.offsetY + 17, parent: Pathnode.name, constraints: DiagramConstraints.Default & ~DiagramConstraints.PointerEvents };
var detailCircle3 = { name: "detailCircle3" + i, labels: [{ name: "", text: "", bold: true, fontColor: "black", fontSize: 10, italic: false, readOnly: true, width: 50, wrapping: ej.datavisualization.Diagram.TextWrapping.Wrap }], minWidth: 25, width: 25, maxWidth: 25, minHeight: 25, height: 25, maxHeight: 25, type: "node", shape: BasicShapes.Ellipse, offsetX: photo.offsetX + 35, offsetY: photo.offsetY - 17, parent: Pathnode.name, constraints: DiagramConstraints.Default & ~DiagramConstraints.PointerEvents };
var detailCircle4 = { name: "detailCircle4" + i, labels: [{ name: "", text: "", bold: true, fontColor: "black", fontSize: 10, italic: false, readOnly: true, width: 50, wrapping: ej.datavisualization.Diagram.TextWrapping.Wrap }], minWidth: 25, width: 25, maxWidth: 25, minHeight: 25, height: 25, maxHeight: 25, type: "node", shape: BasicShapes.Ellipse, offsetX: photo.offsetX + 35, offsetY: photo.offsetY + 17, parent: Pathnode.name, constraints: DiagramConstraints.Default & ~DiagramConstraints.PointerEvents };
var detailOct = { name: "detailOct" + i, labels: [{ name: "", text: "", bold: true, fontColor: "black", fontSize: 10, italic: false, readOnly: true, width: 50, wrapping: ej.datavisualization.Diagram.TextWrapping.Wrap }], minWidth: 35, width: 35, maxWidth: 35, minHeight: 25, height: 25, maxHeight: 25, type: "node", shape: BasicShapes.Ellipse, offsetX: photo.offsetX, offsetY: photo.offsetY + 42, parent: Pathnode.name, constraints: DiagramConstraints.Default & ~DiagramConstraints.PointerEvents };
nodes = [photo, detailCircle1, detailCircle2, detailCircle3, detailCircle4, detailOct];
returnChildren(JSON.stringify(nodes), i);
} else {
alert("Server Error Occured.Please try after some time.");
}
function RenderImage(Imgname, Imgsrc, PathName) {
var NodeConstraints = ej.datavisualization.Diagram.NodeConstraints;
var xmlns = "http://www.w3.org/2000/svg";
var dUtils = ej.datavisualization.Diagram.Util;
var patternid = 'imagepattern' + ej.datavisualization.Diagram.Util.randomId();
var definition = document.getElementById("patternelement");
var pattern = document.createElementNS(xmlns, "pattern");
dUtils.attr(pattern, { id: patternid, patternUnits:"userSpaceOnUse", width: '100', height: '100' });
var image = document.createElementNS(xmlns, "image");
dUtils.attr(image, { id: Imgname + ej.datavisualization.Diagram.Util.randomId(), width: 100, height: 100, constraints: NodeConstraints.Default & ~NodeConstraints.PointerEvents, style: "transform: rotate(-90deg) translate(-100px,0px);" });
image.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:rel='nofollow' href", Imgsrc)
pattern.appendChild(image);
definition.appendChild(pattern);
var script = document.createElement('script');
dUtils.attr(script, { id: PathName, type: 'text/x-jsrender' });
var polygon = document.createElement('polygon');
dUtils.attr(polygon, { points: "50 1 95 25 95 75 50 99 5 75 5 25", fill: "url(#" + patternid + ")" });
script.appendChild(polygon);
document.body.appendChild(script);
return script.id;
}