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

Marking line

11 Answers 150 Views
Chart
This is a migrated thread and some comments may be shown as answers.
prog1
Top achievements
Rank 1
prog1 asked on 28 Sep 2010, 08:33 AM
I want to have some lines in my chart that show an average value.
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

Sort by
0
Accepted
Yavor
Telerik team
answered on 30 Sep 2010, 03:25 PM
Hello,

 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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Justin Wilson
Top achievements
Rank 1
answered on 07 Oct 2010, 03:05 PM
For the CustomGridLine is there anyway to add a tooltip to this or visually show what the exact value is on the YAxis?

Thanks,
Justin
0
Yavor
Telerik team
answered on 11 Oct 2010, 12:56 PM
Hi Justin Wilson,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Justin Wilson
Top achievements
Rank 1
answered on 11 Oct 2010, 03:04 PM
Is there anyway to do this from the code?  Below is the code I am using to create the line.

            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...
0
Yavor
Telerik team
answered on 12 Oct 2010, 02:47 PM
Hi Justin Wilson,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Developper
Top achievements
Rank 1
answered on 18 Feb 2011, 10:52 AM
I've tried to retemplate the custom grid line as shown but the tooltip is never displayed. I have a linesrie on my chart too. Could you help me.

Thanks in advance

0
Yavor
Telerik team
answered on 23 Feb 2011, 04:51 PM
Hi REYNAUD Guillaume,

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
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Developper
Top achievements
Rank 1
answered on 24 Feb 2011, 11:15 AM
Hi,

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?

0
Yavor
Telerik team
answered on 01 Mar 2011, 09:20 AM
Hello REYNAUD Guillaume,

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
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
hayk
Top achievements
Rank 1
answered on 17 Mar 2011, 12:18 PM
Hi,
I'm also using a customgridline but vertically and the problem is that the line is drawing under chart bar items and only the upper part of the line is shown. Is there a way to draw it over chart bars ?
Thanks
0
Yavor
Telerik team
answered on 22 Mar 2011, 10:32 AM
Hello hayk,

You need to re-template your Chart Area in order to position the custom grid lines over the chart. Please check these topics in our forum for additional information and sample projects: here and here.

All the best,
Yavor Ivanov
the Telerik team
Tags
Chart
Asked by
prog1
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Justin Wilson
Top achievements
Rank 1
Developper
Top achievements
Rank 1
hayk
Top achievements
Rank 1
Share this question
or