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

Annotation text on customline - Y Intercept

1 Answer 45 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Willem asked on 22 Nov 2012, 12:47 AM

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"  />

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 26 Nov 2012, 09:12 AM

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.

Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question