This is a migrated thread and some comments may be shown as answers.

How to avoid text overflow in shape?

5 Answers 218 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Holger
Top achievements
Rank 1
Holger asked on 23 Sep 2014, 12:47 PM
Hello,

Is there any possibility to avoid text overflow in a shape?

Maybe by showing a ellipsis or dynamically resizing the shape by it's content size?

Sample: http://dojo.telerik.com/@Holger/utIYE/3

Thanks,
Holger

5 Answers, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 25 Sep 2014, 09:06 AM
Hi Holger,

For this scenario you should manually calculate the shapes widths. For your convenience I modified the example with a possible implementation.

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Oscar
Top achievements
Rank 1
answered on 25 Sep 2014, 09:51 AM
Here you have another implementation:
http://dojo.telerik.com/iWIW
0
Holger
Top achievements
Rank 1
answered on 29 Sep 2014, 06:14 AM
Hello Iliana,
Hello Oscar,

many thanks for your answers. We are now using a similar approach which gives a slightly better result.

Just for completeness, here is the code:
function measureText(text) {
    var canvas = document.createElement("canvas");
    var context = canvas.getContext("2d");
    context.font = '15px sans-serif';
    var metrics = context.measureText(text);
 
    return metrics.width;
}

But all of this is just a workaround. I think the final solution will be to make the rectangle a visual group or parent for embedded elements, so it will grow with the size of it's children.

What do you think?

Regards,
Holger
0
Accepted
Iliana Dyankova
Telerik team
answered on 30 Sep 2014, 01:38 PM
Hi Holger,

I agree this is a reasonable solution and would suggest to send this idea as a feature request at Kendo UI UserVoice portal - this way the community would be able to vote and comment it. The most popular requests take the highest priority when planning for a release. Thank you in advance.

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Holger
Top achievements
Rank 1
answered on 01 Oct 2014, 02:48 PM
Link to Kendo UI User Voice:

Diagram: Make the rectangle a visual group
Tags
Diagram
Asked by
Holger
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Oscar
Top achievements
Rank 1
Holger
Top achievements
Rank 1
Share this question
or