Hi there, Please answer my another question here
In RadChart, I want to have CustomGridLine on ChartArea with the TextLabel just a little above or below the line to explain what is the line's meaning.
I looked at the example on this link. http://www.telerik.com/community/forums/silverlight/chart/is-it-possible-to-annotate-customgridlines.aspx . The problem is that when I set YIntercept that is not equal to 90 (e.g. 0). The Text just go above at the top of chartArea and didn't stick with the line. I also try to adjust margin also, but failed. (Adjusting Margin also brought the line position not equal to the YIntercept point)
How can I adjust the example code to have text label stick with line whatever the YIntercept is.
Thanks
In RadChart, I want to have CustomGridLine on ChartArea with the TextLabel just a little above or below the line to explain what is the line's meaning.
I looked at the example on this link. http://www.telerik.com/community/forums/silverlight/chart/is-it-possible-to-annotate-customgridlines.aspx . The problem is that when I set YIntercept that is not equal to 90 (e.g. 0). The Text just go above at the top of chartArea and didn't stick with the line. I also try to adjust margin also, but failed. (Adjusting Margin also brought the line position not equal to the YIntercept point)
How can I adjust the example code to have text label stick with line whatever the YIntercept is.
Thanks
4 Answers, 1 is accepted
0
Hi Woramin,
You can control the positioning of the TextBlock by wrapping the TextBlock in Canvas and setting its Canvas.Left and Canvas.Top values to X1 and Y1 coordinates of the GridLine. Here is what I mean:
Regards,
Evgenia
the Telerik team
You can control the positioning of the TextBlock by wrapping the TextBlock in Canvas and setting its Canvas.Left and Canvas.Top values to X1 and Y1 coordinates of the GridLine. Here is what I mean:
<
SolidColorBrush
x:Key
=
"AxisStroke"
Color
=
"#FF000000"
/>
<
Style
x:Key
=
"gridLineStyle"
TargetType
=
"telerik:CustomGridLine"
>
<
Setter
Property
=
"Stroke"
Value
=
"{StaticResource AxisStroke}"
/>
<
Setter
Property
=
"StrokeThickness"
Value
=
"1"
/>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"telerik:CustomGridLine"
>
<
Grid
>
<
Line
X1
=
"{TemplateBinding ElementX1}"
X2
=
"{TemplateBinding ElementX2}"
Y1
=
"{TemplateBinding ElementY1}"
Y2
=
"{TemplateBinding ElementY2}"
Stroke
=
"{TemplateBinding Stroke}"
StrokeThickness
=
"{TemplateBinding StrokeThickness}"
Style
=
"{TemplateBinding ElementStyle}"
/>
<
Canvas
>
<
TextBlock
TextWrapping
=
"Wrap"
Text
=
"{Binding}"
Canvas.Left
=
"{TemplateBinding ElementX1}"
Canvas.Top
=
"{TemplateBinding ElementY1}"
>
</
TextBlock
>
</
Canvas
>
</
Grid
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
Regards,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
![](/forums/images/avatarimages/default.gif)
Woramin
Top achievements
Rank 1
answered on 11 Nov 2011, 05:23 AM
Hi Evgenia,
I think your code might work fine. However, when I Implemented your code, I got an error "Unhandled Error in Silverlight Application Error HRESULT E_FAIL has been returned from a call to a com component". (The old code at this time doesn't work also)
Do you have any idea what the problem is? I can't move forward at this time because of this error
By the way this is my additional code for setting style in code behind (The style in User.Resource is the same as yours)
Note that I have to add CustomGridLine in code behind since I have no RadChart in markup page. I create RadChart from the code behind page.
I think your code might work fine. However, when I Implemented your code, I got an error "Unhandled Error in Silverlight Application Error HRESULT E_FAIL has been returned from a call to a com component". (The old code at this time doesn't work also)
Do you have any idea what the problem is? I can't move forward at this time because of this error
By the way this is my additional code for setting style in code behind (The style in User.Resource is the same as yours)
CustomGridLine customLine = new CustomGridLine
{
YIntercept = 0,
Stroke = new SolidColorBrush(Colors.Blue),
StrokeThickness = 4,
DataContext = "Testing Text",
ElementStyle = this.Resources["gridLineStyle"] as Style
};
chartArea.Annotations.Add(customLine);
Note that I have to add CustomGridLine in code behind since I have no RadChart in markup page. I create RadChart from the code behind page.
0
Accepted
Hello Woramin,
I prepared a sample project for you (attached below) where the CustomGridline is added in code-behind and this erroneous behavior doesn't reproduce.
Feel free to customize it so that it meets your requirements. If the issue still occurs on your side please try to reproduce it in this project or send us a runnable version of yours. This way we will be able to inspect it locally and provide you with a more proper support based on your code.
Kind regards,
Evgenia
the Telerik team
I prepared a sample project for you (attached below) where the CustomGridline is added in code-behind and this erroneous behavior doesn't reproduce.
Feel free to customize it so that it meets your requirements. If the issue still occurs on your side please try to reproduce it in this project or send us a runnable version of yours. This way we will be able to inspect it locally and provide you with a more proper support based on your code.
Kind regards,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
![](/forums/images/avatarimages/default.gif)
Woramin
Top achievements
Rank 1
answered on 17 Nov 2011, 02:41 AM
Hi Evgenia,
Thanks a lot for the sample project, I will try customize it as you suggested. There are still something I want to try
Any question I will contact you later
Thanks a lot for the sample project, I will try customize it as you suggested. There are still something I want to try
Any question I will contact you later