Marking line

12 posts, 1 answers
  1. prog1
    prog1 avatar
    61 posts
    Member since:
    Jul 2008

    Posted 28 Sep 2010 Link to this post

    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.
  2. Answer
    Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 30 Sep 2010 Link to this post

    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
  3. Justin Wilson
    Justin Wilson avatar
    18 posts
    Member since:
    Jun 2010

    Posted 07 Oct 2010 Link to this post

    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
  4. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 11 Oct 2010 Link to this post

    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
  5. Justin Wilson
    Justin Wilson avatar
    18 posts
    Member since:
    Jun 2010

    Posted 11 Oct 2010 Link to this post

    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...
  6. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 12 Oct 2010 Link to this post

    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
  7. Developper
    Developper avatar
    2 posts
    Member since:
    Feb 2011

    Posted 18 Feb 2011 Link to this post

    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

  8. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 23 Feb 2011 Link to this post

    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!
  9. Developper
    Developper avatar
    2 posts
    Member since:
    Feb 2011

    Posted 24 Feb 2011 Link to this post

    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?

  10. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 01 Mar 2011 Link to this post

    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!
  11. hayk
    hayk avatar
    2 posts
    Member since:
    Jan 2011

    Posted 17 Mar 2011 Link to this post

    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
  12. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 22 Mar 2011 Link to this post

    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
Back to Top