CustomLine does not work

7 posts, 0 answers
  1. Georgi
    Georgi avatar
    6 posts
    Member since:
    Aug 2010

    Posted 08 Sep 2010 Link to this post

    I'm trying to add CustomLine to my chart with these lines of code:

     

    CustomLine line = new CustomLine();
    line.StartX = 2;
    line.StartY = 2;
    line.EndX = 5;
    line.EndY = 30; // !?!?
    ...

    The result is strange (look at the attached picture, the end of the line is [5,5]). Because there is little help and no examples at all, would somebody help me with this "tough" example?

    I've tried everything in my mind (playing with Slope, YAxisName, ElementX1, etc.). Whatever I do I couldn't add a line that is rendered as I expect giving its properties
  2. Nikolay
    Admin
    Nikolay avatar
    386 posts

    Posted 13 Sep 2010 Link to this post

    Hello Georgi,

    The StartX, EndX, etc properties do not represent coordinate points, they merely show where the line is clipped.The function which draws the custom line is : y = mx + b, where 'm' is the Slope and 'b' is YIntercept. The Slope is defined as : (y2 - y1)/(x2 - x1).

    In your case, in order to draw a line from Point (2, 2) to Point(5, 30), you would need to define it in the following way:
    RadChart1.DefaultView.ChartArea.Annotations.Add(new CustomLine() { StartX = 2, EndX = 5, YIntercept = -16.66, Slope = 9.33});

    Hope this helps. A help topic on the matter will be added in the nearest future.

    Best wishes,
    Nikolay
    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. DevCraft banner
  4. Georgi
    Georgi avatar
    6 posts
    Member since:
    Aug 2010

    Posted 16 Sep 2010 Link to this post

    Knowing the actual function that represents the line and some base trigonometry from high school it takes a few lines of code to draw almost every possible line with starting and ending coordinates as input. So thanks for the hint :)

    But I said almost every possible line... what about a vertical line? My basic math knowledge tells me that it's not possible with your approach, is it? :) And is there any other way to draw a line from (2, 2) to (2,4)?

    I'm not such a stickler, I just try to find some solution for my other problems with MarkedZones (look here). If I can find a way to draw vertical lines, then I can just draw 4 lines to form a rectangle, don't I?
  5. Nikolay
    Admin
    Nikolay avatar
    386 posts

    Posted 21 Sep 2010 Link to this post

    Hello Georgi,

    You can draw a vertical line from Point( 2, 2 ) to Point( 2, 4 ) by setting PositiveInfinity for the Slope. Here is a sample code snippet :
    RadChart1.DefaultView.ChartArea.Annotations.Add(new CustomLine() { StartY = 2, EndY = 4, XIntercept = 2, Slope = double.PositiveInfinity });

    Hope this helps.

    Sincerely yours,
    Nikolay
    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
  6. Brian
    Brian avatar
    73 posts
    Member since:
    Sep 2010

    Posted 04 Aug 2011 Link to this post

    I am trying to create a horizontal custom line.  Using your instructions above, that would be:

    new
    CustomLine { YIntercept = 5, Slope = double.PositiveInfinity, MinX = 5, MaxX = 15 };

    for a line with a Y value of 5 that extends from X=5 to X=15, right?  It doesn't seem to work.  I can't get it to actually draw the line. 
  7. Sia
    Admin
    Sia avatar
    667 posts

    Posted 04 Aug 2011 Link to this post

    Hello Brian,

    Please find our answer in the other forum thread concerning the same issue.

    Greetings,
    Sia
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  8. Manesh
    Manesh avatar
    24 posts
    Member since:
    Feb 2012

    Posted 01 Feb 2012 Link to this post

    HELLO GEORGI,


     This is manesh its nice to see custom line working in your programming but i'm unable to have custome line syntax error is comming so please tell me how to write it or please mail your code to manesh561@gmail.com
Back to Top
DevCraft banner