But if I do this with chartitems, there are 10 itemlabels. I just need one. Text would be optional because of the legend I could use.
Is ther another option to do this? Marking areas?
Added a picture to show what I mean.
Thanks in advance.
11 Answers, 1 is accepted
You can use several approaches to mark the zone. First you can use our MarkedZones like on this demo. Other way can be to use custom gridlines like on this demo. You can use our custom grid lines in your case like this:
<
telerik:CustomGridLine
YIntercept
=
"50"
Visibility
=
"Visible"
Stroke
=
"Green"
StrokeThickness
=
"3"
/>
<
telerik:CustomGridLine
YIntercept
=
"75"
Visibility
=
"Visible"
Stroke
=
"Red"
StrokeThickness
=
"3"
/>
Kind regards,
Yavor Ivanov
the Telerik team
![](/forums/images/avatarimages/default.gif)
Thanks,
Justin
You can retemplate the custom grid line and use the ToolTipService provided by Silverlight like this:
<
telerik:CustomGridLine
YIntercept
=
"20"
StrokeThickness
=
"5"
>
<
telerik:CustomGridLine.Template
>
<
ControlTemplate
TargetType
=
"telerik:CustomGridLine"
>
<
Line
X1
=
"{TemplateBinding ElementX1}"
X2
=
"{TemplateBinding ElementX2}"
Y1
=
"{TemplateBinding ElementY1}"
Y2
=
"{TemplateBinding ElementY2}"
Stroke
=
"{TemplateBinding Stroke}"
StrokeThickness
=
"{TemplateBinding StrokeThickness}"
Style
=
"{TemplateBinding ElementStyle}"
ToolTipService.ToolTip
=
"This is my tooltip"
>
</
Line
>
</
ControlTemplate
>
</
telerik:CustomGridLine.Template
>
</
telerik:CustomGridLine
>
I hope this information gets you started properly.
Kind regards,Yavor Ivanov
the Telerik team
![](/forums/images/avatarimages/default.gif)
CustomGridLine customGridLine = new CustomGridLine();
customGridLine.YIntercept = chartItems.Average(p => p.PricePerUOM.Value);
customGridLine.Stroke = StyleHelper.Brushes.SelectedMember();
customGridLine.StrokeThickness = 3;
customGridLine.YAxisName = "Test";
this.Chart.DefaultView.ChartArea.Annotations.Add(customGridLine);
Thanks in advance...
You can define your template as a UserControl Resource and set it in code like this:
<
UserControl.Resources
>
<
ControlTemplate
x:Key
=
"myGridLineTemplate"
TargetType
=
"telerik:CustomGridLine"
>
<
Line
X1
=
"{TemplateBinding ElementX1}"
X2
=
"{TemplateBinding ElementX2}"
Y1
=
"{TemplateBinding ElementY1}"
Y2
=
"{TemplateBinding ElementY2}"
Stroke
=
"{TemplateBinding Stroke}"
StrokeThickness
=
"{TemplateBinding StrokeThickness}"
Style
=
"{TemplateBinding ElementStyle}"
ToolTipService.ToolTip
=
"This is my tooltip"
>
</
Line
>
</
ControlTemplate
>
</
UserControl.Resources
>
You can now set the template of the CustomGridLine in code like this:
customGridLine.Template =
this
.Resources[
"myGridLineTemplate"
]
as
ControlTemplate;
The ToolTip can be set through binding to some value set in code through the CustomGridLine's DataContext.
Best wishes,
Yavor Ivanov
the Telerik team
![](/forums/images/avatarimages/default.gif)
Thanks in advance
This happens because DragZoomLayerControl is before the AnnotationLayer (the layer of the custom annotations) and all user events are handled by this layer and don't reach your custom GridLine. The solution is to retemplate RadChart and set IsHitTestVisible=False to the DragZoomLayerControl.
Best wishes,Yavor Ivanov
the Telerik team
![](/forums/images/avatarimages/default.gif)
I tried your solution and it worked well for my custom grid line but now, the problem is that i haven't my tooltip on my line series. Is there any way having tooltips on both line serie and custom grid line?
I understand your scenario, but unfortunately it is not supported by the current implementation of RadChart. I have forwarded your bug to our developers and it is logged it in our bug tracking system. You can track its progress in our PITS system here.
Best wishes,Yavor Ivanov
the Telerik team