Class ChartBehavior
ChartBehavior is an abstract base class for behaviors which can be added to SfChart
Inheritance
Implements
Namespace: Syncfusion.UI.Xaml.Charts
Assembly: Syncfusion.SfChart.WPF.dll
Syntax
public abstract class ChartBehavior : DependencyObject, ICloneable
Remarks
You can handle the SfChart events directly in Chart behavior, which will be helpful in designing the Chart application in MVVM pattern. You can add a custom behavior to the SfChart by inheriting a class from the ChartBehavior. You can also add ui elements to the Chart by making use of the top layer canvas returned from AdorningCanvas property,which can be used to place the ui elements at desired positions in SfChart.
Examples
This example, we are using ChartZoomPanBehavior.
<syncfusion:SfChart>
<syncfusion:SfChart.Behaviors>
<syncfusion:ChartZoomPanBehavior/>
</syncfusion:SfChart.Behaviors>
</syncfusion:SfChart>
ChartZoomPanBehavior zoomPanBehavior = new ChartZoomPanBehavior();
chartArea.Behaviors.Add(zoomPanBehavior);
Constructors
ChartBehavior()
Called when instance created for ChartBehavior.
Declaration
public ChartBehavior()
Fields
chartAxis
Used to specify corresponding ChartAxis.
Declaration
protected ChartAxis chartAxis
Field Value
| Type |
|---|
| ChartAxis |
Properties
AdorningCanvas
Gets the top layer Canvas.
Declaration
public Canvas AdorningCanvas { get; }
Property Value
| Type |
|---|
| System.Windows.Controls.Canvas |
BottomAdorningCanvas
Gets the bottom layer Canvas.
Declaration
public Canvas BottomAdorningCanvas { get; }
Property Value
| Type |
|---|
| System.Windows.Controls.Canvas |
ChartArea
Gets the owner Chart.
Declaration
public SfChart ChartArea { get; }
Property Value
| Type |
|---|
| SfChart |
Methods
AlignDefaultLabel(ChartAlignment, ChartAlignment, Double, Double, ContentControl)
Align the element inside the content control.
Declaration
protected virtual void AlignDefaultLabel(ChartAlignment verticalAlignemnt, ChartAlignment horizontalAlignment, double x, double y, ContentControl control)
Parameters
| Type | Name | Description |
|---|---|---|
| ChartAlignment | verticalAlignemnt | Used to specify ChartAlignment for vertical |
| ChartAlignment | horizontalAlignment | Used to specify ChartAlignment for horizontal |
| System.Double | x | The X location |
| System.Double | y | The Y location |
| System.Windows.Controls.ContentControl | control | Used to specify corresponding content control |
AttachElements()
Method implementation for attach elements.
Declaration
protected virtual void AttachElements()
Clone()
Returns the clone behavior.
Declaration
public DependencyObject Clone()
Returns
| Type |
|---|
| System.Windows.DependencyObject |
CloneBehavior(DependencyObject)
Declaration
protected virtual DependencyObject CloneBehavior(DependencyObject obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.DependencyObject | obj |
Returns
| Type |
|---|
| System.Windows.DependencyObject |
DetachElement(UIElement)
Method implementation for DetachElement.
Declaration
protected virtual void DetachElement(UIElement element)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.UIElement | element | UIElement |
DetachElements()
Method implementation for DetachElements.
Declaration
protected virtual void DetachElements()
GetYValuesBasedOnIndex(Double, ChartSeriesBase)
Return collection of double values from the given ChartSeries.
Declaration
protected IList<double> GetYValuesBasedOnIndex(double x, ChartSeriesBase series)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | x-position |
| ChartSeriesBase | series | ChartSeriesBase |
Returns
| Type |
|---|
| System.Collections.Generic.IList<System.Double> |
OnDoubleTapped(MouseButtonEventArgs)
Method implementation for OnDoubleTapped.
Declaration
protected virtual void OnDoubleTapped(MouseButtonEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseButtonEventArgs | e | MouseButtonEventArgs |
OnDragEnter(DragEventArgs)
Called when drag action enter into the chart area.
Declaration
protected virtual void OnDragEnter(DragEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.DragEventArgs | e | DragEventArgs |
OnDragLeave(DragEventArgs)
Called when drag action leave from the chart area.
Declaration
protected virtual void OnDragLeave(DragEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.DragEventArgs | e | DragEventArgs |
OnDragOver(DragEventArgs)
Called when drag action over in the chart area.
Declaration
protected virtual void OnDragOver(DragEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.DragEventArgs | e | DragEventArgs |
OnDrop(DragEventArgs)
Called when drop the cursor in the chart area.
Declaration
protected virtual void OnDrop(DragEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.DragEventArgs | e | DragEventArgs |
OnGotFocus(RoutedEventArgs)
Called when got focus in UIElement.
Declaration
protected virtual void OnGotFocus(RoutedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.RoutedEventArgs | e | RoutedEventArgs |
OnKeyDown(KeyEventArgs)
Called when pointer key down in the chart area.
Declaration
protected virtual void OnKeyDown(KeyEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.KeyEventArgs | e | KeyEventArgs |
OnKeyUp(KeyEventArgs)
Called when pointer key up in the chart.
Declaration
protected virtual void OnKeyUp(KeyEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.KeyEventArgs | e | KeyEventArgs |
OnLayoutUpdated()
Called when layout updated.
Declaration
protected virtual void OnLayoutUpdated()
OnLostFocus(RoutedEventArgs)
Called when lost the focus in the chart.
Declaration
protected virtual void OnLostFocus(RoutedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.RoutedEventArgs | e | RoutedEventArgs |
OnManipulationCompleted(ManipulationCompletedEventArgs)
Called when manipulation completed.
Declaration
protected virtual void OnManipulationCompleted(ManipulationCompletedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.ManipulationCompletedEventArgs | e | ManipulationCompletedEventArgs |
OnManipulationDelta(ManipulationDeltaEventArgs)
Called when manipulation delta is changed.
Declaration
protected virtual void OnManipulationDelta(ManipulationDeltaEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.ManipulationDeltaEventArgs | e | ManipulationDeltaEventArgs |
OnManipulationStarted(ManipulationStartedEventArgs)
Called when manipulation started.
Declaration
protected virtual void OnManipulationStarted(ManipulationStartedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.ManipulationStartedEventArgs | e | ManipulationStartedEventArgs |
OnMouseEnter(MouseEventArgs)
Called when mouse entered into the chart.
Declaration
protected virtual void OnMouseEnter(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseEventArgs | e | MouseEventArgs |
OnMouseLeave(MouseEventArgs)
Called when mouse leave from the chart.
Declaration
protected virtual void OnMouseLeave(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseEventArgs | e | MouseEventArgs |
OnMouseLeftButtonDown(MouseButtonEventArgs)
Called when mouse left button clicked.
Declaration
protected virtual void OnMouseLeftButtonDown(MouseButtonEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseButtonEventArgs | e | MouseButtonEventArgs |
OnMouseLeftButtonUp(MouseButtonEventArgs)
Called when mouse left button released.
Declaration
protected virtual void OnMouseLeftButtonUp(MouseButtonEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseButtonEventArgs | e | MouseButtonEventArgs |
OnMouseMove(MouseEventArgs)
Called when mouse moved in the chart.
Declaration
protected virtual void OnMouseMove(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseEventArgs | e | MouseEventArgs |
OnMouseWheel(MouseWheelEventArgs)
Called when mouse wheel on the chart.
Declaration
protected virtual void OnMouseWheel(MouseWheelEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseWheelEventArgs | e | MouseWheelEventArgs |
OnSizeChanged(SizeChangedEventArgs)
Called when size changed.
Declaration
protected virtual void OnSizeChanged(SizeChangedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.SizeChangedEventArgs | e | SizeChangedEventArgs |
UpdateArea()
This method used to update the entire chart by recalculating and redrawing it.
Declaration
protected void UpdateArea()