Annotation text on customline - Y Intercept

2 posts, 1 answers
  1. Willem
    Willem avatar
    12 posts
    Member since:
    Nov 2012

    Posted 21 Nov 2012 Link to this post

    I am attempting to place a text annotation against a CustomLine using the method outlined in the forum article below:

    This works fine if the line intersects with the X-Axis within the display area of the chart or if the slope is 0, however if the line has a slope that intersects with the Y-Axis the text is not shown.

    The reason is that the XElement property of CustomLine is a large negative value that pushes the text off screen

    Could you please advise how to place text annotation on this type of line.

    I modified the sample in the above forum post to illustrate the problem.


    for (int i = 2; i < 50; i++)
        DummyDataItem item = new DummyDataItem();
        item.YValue = rand.Next(2000, 4000)/1000;
        item.XValue = i + 1;


    <telerik:CustomLine Style="{StaticResource gridLineStyle}"
                        DataContext="Test" Stroke="Red" Slope="0.01" YIntercept="2.55"  />
  2. Answer
    Nikolay avatar
    397 posts

    Posted 26 Nov 2012 Link to this post


    The reason why the text block is not visible in this scenario is because its Canvas.Left property is bound to the ElementX1, which using this slope and YIntercept is a negative value - actually the XIntecept is -255 and this is where the custom text is positioned.

    In order to place the text in the visible area you would need to adjust the Canvas.Left and Canvas.Top properties of the TextBlock in the GridLineStyle. You can either bind them to some custom properties that would calculate the text block's position dynamically or set the pixels manually.

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top