Mouse Interaction with ChartPanel

The ChartPanel panel has support of mouse interaction. The ChartPanelAction enumeration specifies possible action for the chart panel objects. The ChartPanelAction enumeration includes the following members:

 

Member name

Description

None

No action.

MouseMove

Follow mouse.

LeftMouseButtonDrag

Can be dragged with left mouse button.

RightMouseButtonDrag

Can be dragged with right mouse button.

 

Using the Action property we can make a draggable element or element that follows the mouse pointer. For examplle, adding Action to the previous sample we get the marker that can be moved by user.

   <!-- vertical line -->

   <c1chart:ChartPanelObject DataPoint="0,NaN" VerticalAlignment="Stretch"

       Action="LeftMouseButtonDrag" >

     <Border BorderBrush="Red" BorderThickness="3,0,0,0"

Margin="-1.5,0,0,0" />

   </c1chart:ChartPanelObject>

 

Using data binding it's easy to add label that shows the current coordinate:

   <!-- vertical line with coordinate label -->

   <c1chart:ChartPanelObject x:Name="xmarker" DataPoint="0,NaN"

VerticalAlignment="Stretch"

       Action="LeftMouseButtonDrag">

     <Border BorderBrush="Red" BorderThickness="3,0,0,0"

Margin="-1.5,0,0,0" >

       <TextBlock

         Text="{Binding RelativeSource={RelativeSource Self},

         Path=Parent.Parent.DataPoint.X,StringFormat='x=0.0;x=-0.0'}" />

     </Border>

   </c1chart:ChartPanelObject>

The property Attach allows to stick the possible positions of the element to the nearest data point. It can be attached to the single coordinate(X or Y) or both coordintates(XY).


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.