About CursorCoordinateGraph

Jul 6, 2009 at 11:14 AM

Hi,

I am using CursorCoordinateeGraph features- very nice feature (thanks for this), looks this will solve solve my purpose.

I have one issue here, Is it possible to set positions of cursorcooridinates externallly, some thing like

cursorCoordinateeGraph.HorizontalLine.X1 = ****.

I saw this in

UpdateUIRepresentation(Point mousePos)

{

}

Is it possible to set these position from my code, how to set

Regards

Ravi.

Editor
Jul 6, 2009 at 2:03 PM

Hi, Ravi,

 

I've changed CursorCoordinateGraph a little for you - now it is posible ti set its position using its Position property.

Changed D3 and sample app are here - http://cid-eaf0a921258b5980.skydrive.live.com/self.aspx/.Public/D3/CursorGraphUpdate/FixedCursorCoordinateGraph.zip

 

Best regards,

Mikhail.

Jul 6, 2009 at 4:42 PM

Hi,

I am very much thankful to you for the support you are giving

I need some more help.

private void OnPlotterMouseMove(object sender, System.Windows.Input.MouseEventArgs e)

{

Point point = System.Windows.Input.Mouse.GetPosition(this.cursorCoordinateGraph);

point.Y = 10;

// THIS is working

// here I need to get the y coordinate from the point data source

LineGraph line = this.lineGraphLines[0]; // this is collection of line graphs

IPointDataSource ds = line.DataSource;

// Some how I need to retreive y coordinate from data source by passing x coordinate, is it possible to get.

point.Y = this.SomeMethod(point.X, ds);

 

is it possible to do? My horizontal line ( y line) should always stick to data point based on the mouse movement

 

 this.cursorCoordinateGraph.Position = point;

}

Can you please suggest how to achieve.

Regardss

Ravi.

Jul 7, 2009 at 9:55 AM

Hi,

Its me again, i got some partial soulution.

using System;

using System.Collections.Generic;

using System.Globalization;

using System.Linq;

using System.Text;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using Microsoft.Research.DynamicDataDisplay;

using Microsoft.Research.DynamicDataDisplay.Charts.Navigation;

using Microsoft.Research.DynamicDataDisplay.DataSources;

using System.Collections;

 

namespace LogPointValue

{

    /// <summary>

    /// Interaction logic for Window1.xaml

    /// </summary>

    public partial class Window1 : Window

    {

        private CursorCoordinateGraph cursorCoordinateGraph;

        IList<Point> pnts;

        Point AxisPoint = new Point();

        public Window1()

        {

            InitializeComponent();

 

            GetData();

            this.plotter.Legend.Remove();

            this.cursorCoordinateGraph = new CursorCoordinateGraph();

            this.cursorCoordinateGraph.XTextMapping = x => dateAxis.ConvertFromDouble(x).ToString(CultureInfo.CurrentCulture);

            this.cursorCoordinateGraph.YTextMapping = y => y.ToString(CultureInfo.CurrentCulture);

            this.plotter.Children.Add(cursorCoordinateGraph);

            this.plotter.MouseMove += new MouseEventHandler(plotter_MouseMove);

        }

 

        private void plotter_MouseMove(object sender, MouseEventArgs e)

        {

            ////throw new NotImplementedException();

            Point point = System.Windows.Input.Mouse.GetPosition(this.cursorCoordinateGraph);

            IList<Point> points = new List<Point>();

            foreach (Point pt in this.pnts)

            {

                points.Add(this.plotter.Viewport.Transform.ViewportToScreen(pt));

            }

 

            foreach (Point pt in points)

            {

                if ((int)point.X == (int)pt.X)

                {

                    this.AxisPoint.Y = pt.Y;

                    break;

                }

            }

 

            this.AxisPoint.X = point.X;

            this.cursorCoordinateGraph.Position = this.AxisPoint;

 

            /*

             *

             * ////throw new NotImplementedException();

            Point point = System.Windows.Input.Mouse.GetPosition(this.cursorCoordinateGraph);

            ////IList<Point> points = new List<Point>();

            ////foreach (Point pt in this.pnts)

            ////{

            ////    points.Add(this.plotter.Viewport.Transform.ViewportToScreen(pt));

            ////}

            AxisPoint = this.plotter.Viewport.Transform.ScreenToViewport(point);

            foreach (Point pt in this.pnts)

            {

                if (AxisPoint.X == pt.X)

                {

                    this.AxisPoint.Y = pt.Y;

                    break;

                }

            }

 

            Point pnt = this.plotter.Viewport.Transform.ViewportToScreen(AxisPoint);

            this.cursorCoordinateGraph.Position = pnt;

             */

        }

 

        private void GetData()

        {

            const int N = 240;

            double[] x = new double[N];

            double[] y = new double[N]; 

            DateTime[] date = new DateTime[N];

 

            for (int i = 0; i < N; i++)

            {

                x[i] = i * 0.1;

                y[i] = Math.Sin(x[i]);

                date[i] = DateTime.Now.AddMinutes(-N + i);

            }

 

            EnumerableDataSource<double> xs = new EnumerableDataSource<double>(y);           

            xs.SetYMapping(_x => _x);

            EnumerableDataSource<DateTime> ys = new EnumerableDataSource<DateTime>(date);

            ys.SetXMapping(dateAxis.ConvertToDouble);

            CompositeDataSource ds = new CompositeDataSource(xs, ys);

            IEnumerable<Point> points = ds.GetPoints();

            this.pnts = points.ToList();

            plotter.AddLineGraph(ds);

        }

    }

}

 

But  here one proble,

While comparing coordinates in mouse move event I am converting coordinates into int and finding the near by coordinate.

Is there any other way available to get the near by point, or is there any other way to do this. Please suggest proper solution.

Regards

Ravi.

Editor
Jul 7, 2009 at 10:39 AM

Hi Ravi,

 

Please take a look at LineTestSample here - http://cid-eaf0a921258b5980.skydrive.live.com/self.aspx/.Public/D3/D3%20for%20VPV.zip

Try to move a mouse over the chart.

Maybe this fits your needs.

 

Regards,

Mikhail.

Aug 3, 2009 at 8:45 AM

Hi,

Sorry for the late reply.

Great control, My application is coming very good.

Thanks for your support.