This project is read-only.
1
Vote

LineCursor Vertical Line

description

Hello !

I would to creat an Vertical Line and a DraggablePoint to show an Y Value for an X Value of an chart...

I search everywhere but i don't find a methode who return Y Value for an X Value...

Can you help me ?

Regards

comments

lioneloddo wrote May 19, 2015 at 6:21 PM

I can try to show you for the vertical line.

Suppose you have a chartplotter, named plotter, declared in your xaml file, with an event for the mouse:
<c:ChartPlotter Name="plotter"  MouseLeftButtonDown="plotter_MouseLeftButtonDown">
In your code, you can enter this :
public partial class Window1 : Window
    {
       public CursorCoordinateGraph mouseTrack { get;set;}
       public Point mouseTrackX { get; set; }
       public int d { get; set; }
        public Window1()
        {
            InitializeComponent();
                       CursorCoordinateGraph mouseTrack = new CursorCoordinateGraph();
                      mouseTrackX = mouseTrack.Position;
                      plotter.Children.Add(mouseTrack);
                      d = plotter.Children.Count;
                     mouseTrack. .ShowHorizontalLine = false;
                     mouseTrack.ShowVerticalLine = true;
        }
Then you can add this for the mouse event
 public void plotter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            
            var s = sender as ChartPlotter;
            var sc = s.Children[d-1] as CursorCoordinateGraph;
           mouseTrackX = sc.Position;
           var transform = plotter.Viewport.Transform;
           Point mousePosInData = mouseTrackX.ScreenToData(transform);
           // textBlock1.Text = Convert.ToString(mousePosInData);
            var line = new VerticalLine();
            line.Value= mousePosInData.X;
            plotter.Children.Add(line);
        }
It should add a vertical line at the position of the mouse click.
X and Y positions are given by the Point mousePosInData (mousePosInDat.X and mousePosInDat.Y)