We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Background Image for a node

Hi,

I have two nodes of which one is Hexagon and other is image node..

In onnodedrop event, i want the image to be in the hexagon.Image in hexagon as shown in the link.

I have tries using CSS class which didn't work..Can you please give me a workaround.

Thank you

12 Replies

SG Shyam G Syncfusion Team December 21, 2016 07:03 AM UTC

Hi Indrani, 

Could you please confirm us whether you need an image to be appended in hexagon while dragging image node and dropping it into hexagon or while performing drag and drop the image node from palette onto the diagram, the image node should be changed as an hexagon node. Also we could not see your image provided in the forum. Please provide us more details such as an image or explain your requirement with the screenshot. 

Regards, 
Shyam G 



IG indrani Gajjarapu December 24, 2016 12:51 PM UTC

Hi,

I have attached two photos in which i have two tables and 4 chairs..I want to embed the image node in to the hexagon on drop function..I have sent you a picture where the image lies on the hexagon.

Thank you

Attachment: ImageNode_7986cd76.zip


SG Shyam G Syncfusion Team December 27, 2016 12:52 PM UTC

Hi Indrani, 

When you drag and drop the image node onto the hexagon node, we create a group node to embed the image node into the hexagon. Please refer to the sample below. 


Regards, 
Shyam G 



IG indrani Gajjarapu January 4, 2017 10:35 AM UTC

Hi,

In this scenario, i can neither set a background-image to hexagon node nor change the shape of the image node to hexagon to overlay image on hexagon.

Workaround to any one of them would solve my issue.

I have attached a picture with an image embedded inside hexagon or simply, background image for hexagon for your reference.

I want my node as such.

Thank you



Attachment: hexagon_f6a6f68b.zip


SG Shyam G Syncfusion Team January 6, 2017 09:13 AM UTC

Hi Indrani, 

Sorry for the delay 

We have created a sample to achieve your requirement. 


In the above sample, when we drag the image node from the palette and drop onto the path Node(hexagon), we create a native node with hexagon and image. Also we have created a script template dynamically in the generateSVGtemplate method maintained in the application level(refer index.cshtml file in the sample). Instead of native node, you can use path node to achieve your requirement but image in the path node remains static and could not be updated while resizing the path node. 

Regards, 
Shyam G 



IG indrani Gajjarapu January 10, 2017 11:39 AM UTC

Hi Shyam,

Thanks for your reply.

1) In your sample project, if i drag one more hexagon and try to put image in it, the code doesn't work. It works only for the first time.

2) Also, in generateSVGtemplate function  you have  used "Path._absolutePath". 

In my project, hexagon is one of the child in a group node which doesn't have any property named _absolutePath. So, I have put the static data("M 25 100 L 0 50 L 25 0 L 75 0 L 100 50 L 75 100 L 25 100 z") from your sample project  which works fine for the first photo. However, when i drag next photo, the previous picture was gone and displays current picture.

I have attached a picture of this scenario and scripts used in my project. Instead of removing and adding node, I have just updated the existing node so that the user cannot make any other modifications to the node such as resizing.

Can you please modify your sample project with more than one hexagon and photo



Attachment: svg_ff30b4c9.zip


SG Shyam G Syncfusion Team January 11, 2017 07:19 AM UTC

Hi Indrani, 

Query 
Response 
 In your sample project, if i drag one more hexagon and try to put image in it, the code doesn't work. It works only for the first time. 
We have fixed the issue in the sample and provided the modified sample below. 
 Also, in generateSVGtemplate function  you have  used "Path._absolutePath".  
 
In my project, hexagon is one of the child in a group node which doesn't have any property named _absolutePath. So, I have put the static data("M 25 100 L 0 50 L 25 0 L 75 0 L 100 50 L 75 100 L 25 100 z") from your sample project  which works fine for the first photo 

Sorry for the inconvenience 

you can set the node’s property pathData in the path element instead of _absolutePath.  
 
Code example: 
 
var pathelement = document.createElementNS(xmlns, "path"); 
dUtils.attr(pathelement, { 'fill': 'url(#' + patternid + ')', 'stroke': "black", 'stroke-width': "1", 'd': pathnode.pathData }) 
 
Also we have used Getpath method in the sample level to get the path bounds. In this method, you can pass the pathData. We have set these bounds to the image width and height. 
 
code example: 
var bounds = Getpath(pathnode.pathData); 
var image = document.createElementNS(xmlns, "image"); 
                //set an attribute to the image element 
 dUtils.attr(image, { id: imagenode.name + ej.datavisualization.Diagram.Util.randomId(), width: bounds.width, height: bounds.height, preserveAspectRatio: "none" }); 



Regards, 
Shyam G 



IG indrani Gajjarapu January 11, 2017 11:14 AM UTC

Hi Shyam,

The previous code worked fine after deleting the while loop from "generateSVGtemplate" function. However, I am not able export or print the diagram with the updated node.

Export didn't work in the sample project as well.

Also, I want to rotate the Image as i have a rotated hexagon as shown in picture in my last attachment.(Tried rotateAngle which did not work.)

And, if i use PathData instead of absolutePath the image is displayed but not in correct offset. However, when the image is clicked, the empty hexagon area is selected. Static _absolutePath works..So, I think that's no problem.

If you can give me a workaround to rotate the image and to export the diagram,that would be great





SG Shyam G Syncfusion Team January 12, 2017 11:57 AM UTC

Hi Indrani, 

Query 
Response 
The previous code worked fine after deleting the while loop from "generateSVGtemplate" function. However, I am not able export or print the diagram with the updated node. 
 
Export didn't work in the sample project as well. 
Currently we don’t have support to  Export Diagram with native node support”. We have already logged “Export Diagram with native node support” as a feature. 
Also, I want to rotate the Image as i have a rotated hexagon as shown in picture in my last attachment.(Tried rotateAngle which did not work.) 
Please set node’s rotateAngle property for an native node which we create at runtime in the drop event. 

Code example: 
function drop(args) { 
. . . . . 
. . . . . 
  var node = { name: "native" + ej.datavisualization.Diagram.Util.randomId(), rotateAngle:50,  type: "native", templateId: templateID, scale: "stretch" }; 
 
                        diagram.add(node); 
} 
 


Regards, 
Shyam G 



IG indrani Gajjarapu January 12, 2017 03:05 PM UTC

Hi Shyam,

1) In your Sample Project, only hexagon rotates but not the image.i want the image to be rotated as well.

2) Can you please let me know if there is any other way to achieve this other than native node as exporting is quite important.

Thank you for your time.




SG Shyam G Syncfusion Team January 16, 2017 12:52 PM UTC

Hi Indrani, 
 
We considered this “Export diagram with native node support” as an feature and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates. 
 
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents 
                                                                                                                                     
Regards, 
Shyam G 



KR Kameshwaran R Syncfusion Team January 17, 2017 07:31 AM UTC

Hi Indrani,  
 
  
  
1) In your Sample Project, only hexagon rotates but not the image.i want the image to be rotated as well. 

We have updated the response for this query with the incident # I170853.Please check in to that incident #I170853 for the further details. 
  
 
Regards, 
Kameshwaran R.  


Loader.
Up arrow icon