How to apply fillcolor to connector label

Hi,

I thought this would be easy.

I'm trying the following:

diagram.updateLabel(conn.name, conn.labels[0], { fillColor: 'white' });

It would seem that conn.labels[0] is undefined.

What am I doing wrong?

Thanks

Jim

3 Replies

SG Shyam G Syncfusion Team May 4, 2015 01:12 PM UTC

Hi Jim

Thanks for using Syncfusion products.

We are glad to let you know that we have created a simple sample to achieve your requirement and it is available in the below link for download. Please refer the code snippet:

Code snippet:

<ej:diagram id="Diagram1" runat="server" height="1000px" width="1000px">
</ej:diagram>

//creating connectors

Connector connect = new Connector();

connect.Name = "samsa";

//adding labels

Label label = new Label();

label.Text = "ram";
Diagram1.Model.Connectors.Add(connect);

<input type="button" value="updatelabel" onclick="updatelabel()" />

<script type="text/javascript">

function updatelabel() {

var diagram = $("#Diagram1").ejDiagram("instance");

var connector = diagram.model.selectedItems.children[0];

if (connector)

diagram.updateLabel(connector.name,connector.labels[0], {fillColor:"blue"});

}
</script>

Sample:http://www.syncfusion.com/downloads/support/forum/118991/updatelabel839675744.zip

Please let me know if any concerns.

Regards,
Shyam G



JJ Jim Jacobs May 4, 2015 01:50 PM UTC

Hi Shyam,

Thanks for the code.
Actually I ended up changing the fillcolor in the OnClientTextChange event handler.
It seems that the label does not exist until you first double-click on the connector to add the text.
Anyway, this approach works for me.

Thanks for confirming that my updateLabel statement was in the correct format.

Jim


SG Shyam G Syncfusion Team May 5, 2015 12:52 PM UTC

Hi Jim

Thanks for your update.

Query
Response
It seems that the label does not exist until you first double-click on the connector to add the text.
Please note that by default there won’t be label added in the elements. Once the editing is completed, if an element has a label then the label will updated or else it will be added to the element. Please note that updateLabel method is applicable only when the element has a label.


Please let me know if any concerns,

Regards,
Shyam G

Loader.
Up arrow icon