How to change the font size of the shapes in Telerik RadDiagram

467 Views Asked by At

I am using RadDiagram in my ASP.NET application. Control doesn't offer the ability of changing font size of shapes. Is there any way to change sizes?

I create shapes dynamically. Example:

label[i] = new DiagramShape();
label[i].Y = shape[5].Y + SHAPE_HEIGHT + LABEL_TOP_MARGIN;
label[i].X = shape[i].X - LABEL_LEFT_INDENT;
label[i].Height = 20;
label[i].Width = 20;
label[i].ContentSettings.Text = dateLabels[i] ;
label[i].Background = "#FFFFFF";
label[i].ContentSettings.Color = "#000000";
RadDiagram1.ShapesCollection.Add(label[i]);
1

There are 1 best solutions below

0
On

Use a template: http://docs.telerik.com/devtools/aspnet-ajax/controls/diagram/functionality/shape-templates

There are some details in getting templates to work (for starters, you will need to implement a JS function for that) and then you will need to create a text block where you can set the font:

    var textBlock2 = new diagram.TextBlock({
        text: options.id,
        color: "#ffffff",
        fontSize: 16,
        x: 28,
        y: 50
    });

You can use server code blocks to obtain data from serer objects in the markup, or you can create the entire script on the server and register it via the ScriptManager.RegisterStartupScript(Page, Page.GetType(), "someKey", yourScriptString, true); method