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
755
Is there a way to trap the MouseHover event when the mouse is over a DataPoint of the series?
posted

Hi,

I have a column chart and I would like to display information about the column pointed by the mouse.  I dont want to use the tooltip, its position changes all the time and its disturbing.  I want to put a TextBlock in my window that will act as a tooltip but the position will remain.

I would also like to change the look of the column when the cursor is over it.  Ex : change the DataPointColor property or show the marker only when the mouse is over the column.

I cannot find the MousHover event.

 

(you can see an example of what I would like to do here)

http://ca.finance.yahoo.com/charts?s=%5EGSPTSE#chart6:symbol=^gsptse;range=3m;indicator=volume;charttype=line;crosshair=on;ohlcvalues=0;logscale=on;source=undefined

Thanks

Karine

Parents
No Data
Reply
  • 9836
    Verified Answer
    posted

    About your second require to change the color of the DataPoint  you can try the following :

    Brush defaultBrush;

    public Window1()
    {
                InitializeComponent();
                Loaded += new RoutedEventHandler(Window1_Loaded);
     }

     void Window1_Loaded(object sender, RoutedEventArgs e)
     {
                EventManager.RegisterClassHandler(typeof(DataPoint),DataPoint.MouseEnterEvent,new   MouseEventHandler(OnDataPointMouseEnter));
                EventManager.RegisterClassHandler(typeof(DataPoint), DataPoint.MouseLeaveEvent, new MouseEventHandler(OnDataPointMouseLeave));
      }
     void OnDataPointMouseEnter(object sender, MouseEventArgs e)
     {
                DataPoint currentPoint=e.Source as DataPoint;
                defaultBrush = currentPoint.Fill;
                textBlock.Text = currentPoint.Value.ToString();
                currentPoint.Fill = Brushes.Red;
       }
            void OnDataPointMouseLeave(object sender, MouseEventArgs e)
       {
                DataPoint currentPoint = e.Source as DataPoint;
                textBlock.Text = "";
                currentPoint.Fill = defaultBrush;
        }

    Hope this helps

    Best Regards

    Vlad Zagorski

    Developer Support Team

Children