Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Chart > CustomLine does not work

Not answered CustomLine does not work

Feed from this thread
  • Georgi avatar

    Posted on Sep 8, 2010 (permalink)

    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
    Attached files

    Reply

  • Nikolay Nikolay admin's avatar

    Posted on Sep 13, 2010 (permalink)

    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

    Reply

  • Georgi avatar

    Posted on Sep 16, 2010 (permalink)

    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?

    Reply

  • Nikolay Nikolay admin's avatar

    Posted on Sep 21, 2010 (permalink)

    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

    Reply

  • Brian avatar

    Posted on Aug 4, 2011 (permalink)

    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. 

    Reply

  • Sia Sia admin's avatar

    Posted on Aug 4, 2011 (permalink)

    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 >>

    Reply

  • Manesh avatar

    Posted on Feb 1, 2012 (permalink)

    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Chart > CustomLine does not work
Related resources for "CustomLine does not work"

Silverlight Chart Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]