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

Annotation text on customline - Y Intercept

1 Answer 51 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Willem
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:

http://www.telerik.com/community/forums/silverlight/chart/annotation-text-on-customline.aspx

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.

MainPage.xaml.cs

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

MainPage.xaml

<telerik:CustomLine Style="{StaticResource gridLineStyle}"
                    DataContext="Test" Stroke="Red" Slope="0.01" YIntercept="2.55"  />

1 Answer, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 26 Nov 2012, 09:12 AM
Hello,

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,
Nikolay
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart
Asked by
Willem
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or