Search code examples
wpftooltipdynamic-data-display

how to display the co-ordinates of the point in tooltip of D3 chart


I have generated a graph using the tutorial provided by James McCaffrey : http://msdn.microsoft.com/en-us/magazine/ff714591.aspx

Iam able to do so successfully. Also I have added a tooltip as follows:

plotter.AddLineGraph(compositeDataSource1,
new Pen(Brushes.Blue, 2),
new CircleElementPointMarker{ Size = 10.0, Fill = Brushes.Red ,Tooltip="Coordinates"},
new PenDescription("Number bugs open"));

My Question is : how do I display the co-ordinates of the point in tooltip.?


Solution

  • This is how I solved my issue.

    EnumerableDataSource<TPoint> edc;
    edc= new EnumerableDataSource<TPoint>(List_Of_TPoint);
                edc.SetXMapping(x => dateAxis.ConvertToDouble(x.X));
                edc.SetYMapping(y => Convert.ToDouble(y.Y));
                edc.AddMapping(CircleElementPointMarker.ToolTipTextProperty, s => String.Format("Y-Data : {0}\nX-Data : {1}", s.Y, s.X));
    

    I just added above mapping while creating my EnumerableDataSource. And then added the edc to plotter.

    plotter.AddLineGraph(
                                edc,
                                new Pen(Brushes.Transparent, 3),
                                new CircleElementPointMarker
                                {
                                    Size = 15,
                                    Brush = border,
                                    Fill = c2
                                },
                                null
                                );