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

Split text in a Shape and reflow

4 Answers 364 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
François
Top achievements
Rank 1
François asked on 20 Mar 2018, 01:20 PM

Hello,
I use the following code to format the text if it is too long.

function createShape(options) {
    var shapeOptions = {
        editable: false,
        selectable: false,
        id: options.id,
        x: options.positionX || 0,
        y: options.positionY || 0,
        width: options.width || 200,
        height: options.height || 50,
        type: options.type,
        path: options.path || undefined,
        content: {
            text: options.textData || undefined,
            color: '#fff',
            fontSize: 15
        },
        fill: options.fillColor || '#0088CC',
        stroke: options.strokeColor || '#0088CC',
    };
   
    var shape = new kendo.dataviz.diagram.Shape(shapeOptions);
    var texts = options.textData.split(" ");
    for (var i = 0; i < texts.length; i++) {
        shape.visual.append(new kendo.dataviz.diagram.TextBlock({
            text: texts[i],
            color: "#fff"
        }));
    }
    shape.visual.reflow();
    
    return shape;
}

I would like to be able to use the method : reflow() afterwards; so that the words of the text place this correctly.  Can you tell me how to do that? Thank you for your help.


4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 22 Mar 2018, 07:02 AM
Hello, François,

Thank you for the provided code.

I can assume that it is based on the how-to example:

https://docs.telerik.com/kendo-ui/controls/diagrams-and-maps/diagram/how-to/text-wrapping#wrap-text

Could please advise the issue caused by this approach as it is looking good on our end?

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
François
Top achievements
Rank 1
answered on 23 Mar 2018, 06:43 AM

thank you for your answer.

I've attached to you what I get with my code. How can I get the text formatted in a row. I don't use layouts to create shapes.I use the code I gave you as an example

Regards.

0
Stefan
Telerik team
answered on 26 Mar 2018, 07:42 AM
Hello, François,

Thank you for the details.

Please have in mind that the layout is needed in this case.

I modify the example to use a combination of both approached:

https://dojo.telerik.com/UvECoSIm

If this approach has limitations in the real application, please share more details on that.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
François
Top achievements
Rank 1
answered on 27 Mar 2018, 05:06 AM
Thank you it works perfectly.
Tags
Diagram
Asked by
François
Top achievements
Rank 1
Answers by
Stefan
Telerik team
François
Top achievements
Rank 1
Share this question
or