moving custom grid line based on mouse move event

4 posts, 0 answers
  1. Venkatesh
    Venkatesh avatar
    8 posts
    Member since:
    Dec 2011

    Posted 06 Jan 2012 Link to this post

    I am using telerik chart for silverlight. I created a custom grid line which should move as we move the mouse. Hence, I calculate the x intercept based on the x coordinate of the mouse. when I do it, there is always a gap between the cursor and the line. how do we solve this issue.
    thanks
    venkatesh
  2. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 09 Jan 2012 Link to this post

    Hi Venkatesh,

    You may use the approach shown in this help topic to achieve your scenario.

    All the best,
    Evgenia
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft banner
  4. Venkatesh
    Venkatesh avatar
    8 posts
    Member since:
    Dec 2011

    Posted 09 Jan 2012 Link to this post

    I did use that link to create a custom grid line using the following code.

     

     

     

     

     CustomGridline gridline = new CustomGridLine();

    gridline.XIntercept = collection[0].Date.ToOADate();

    gridline.Stroke =

     

    new SolidColorBrush(Colors.Green);

    gridline.StrokeThickness = .3;

    tChart.DefaultView.ChartArea.Annotations.Add(gridline);

    Then I move the grid line using the following code. I am not sure how to convert the position X to a date value. I cannot use TOaDate() as it gives some wrong date. if I use position.x -67 then I get somewhat close coordinates for the cursor but not exact. How do you solve this.


     

    void ChartArea_MouseMove(object sender, MouseEventArgs e)

    {

     

    ChartArea plotAreaPanel = sender as ChartArea;

     

    var position = e.GetPosition(plotAreaPanel);

     

    double posX = double.Parse(position.X.ToString());

     

    var x = plotAreaPanel.AxisX.ConvertPhysicalUnitsToData(posX -67);

     

    AnnotationCollection cGridCollection1 = chart.DefaultView.ChartArea.Annotations;

     

        if (cGridCollection1.Count == 1)

         {

             (cGridCollection1[0]

     

            as CustomGridLine).XIntercept = x;

          }

    }

     

  5. Venkatesh
    Venkatesh avatar
    8 posts
    Member since:
    Dec 2011

    Posted 09 Jan 2012 Link to this post

    I fixed this issue. I used chart area instead of plot area. That was the issue
Back to Top