Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3590
XamWebDataChart crosshair tooltip
posted

If there are multiple players on a chart is it possible to have a unified tooltip that displays the current Y value of each layer currently in contact with the vertical crosshair without having to have the cursor touching each layer individually?

Parents Reply
  • 30692
    Suggested Answer
    Offline posted in reply to Mike Dutra

    I'm personally unable to discuss product roadmaps and timeframes, but you may want to shoot an email over to productmanager@infragistics.com. In the meantime, if you have more questions about how to implement the functionality you are going for on the current codebase, we'll see if we can assist.

    Here would be a way of converting that interpolated categoryxaxis axis value to date times. It assumes the collection bound to the chart is of type TestData, and that the items have a property called Date of type DateTime.

    This is a modification of the end of that function in the earlier linked code. Note there is a .5 offset of the axis value to make the crosshair x align with the category labels, rather than with the category major grid lines. You can comment out that line if you want it to align with the major grid lines instead:

                        //interpolate axis values.
                        double xAxisValue =
                            left + (windowX * (right - left));
                        double yAxisValue =
                            top + (windowY * (bottom - top));
    
                        TestData coll = x.ItemsSource as TestData;
                        //adjust this as to whether you want the crosshair values
                        //to align with the labels or the major gridlines.
                        xAxisValue -= .5;
                        if (xAxisValue >= 0 && !double.IsNaN(xAxisValue))
                        {
                            int floorXIndex =
                                (int) Math.Floor(xAxisValue);
                            int ceilingXIndex =
                                Math.Min((int) Math.Ceiling(xAxisValue), coll.Count - 1);
                            double q = xAxisValue - (double) floorXIndex;
                            long xFloorTicks = coll[floorXIndex].Date.Ticks;
                            long xCeilingTicks = coll[ceilingXIndex].Date.Ticks;
                            long xInterpolatedTicks = (long) (xFloorTicks + q*(xCeilingTicks - xFloorTicks));
    
                            XValue = new DateTime(xInterpolatedTicks);
                        }
                        if (!double.IsNaN(yAxisValue) && 
                            !double.IsInfinity(yAxisValue))
                        {
                            YValue = yAxisValue;
                        }
    

    -Graham

Children