Chart for .NET / User's Guide / Interactivity / Interactivity Overview

In This Topic
    Interactivity Overview
    In This Topic

    It is indeed very nice to have a presentation quality chart or text displayed by your .NET application, but often this is not enough to build a really useful program. What you may need sometimes is information passed from the component to the program that drives it.

    The nature of this information can vary, but the common in all these actions is that the component is initiating them and the program simply decides whether to respond in some way or just to skip it. Building interactive Web applications is out of the scope of this book although the techniques for applying tooltips and cursors are the same in both cases. For more detailed information on how to generate interactive web content check out the ThinWeb Chart Overview and WebForms Deployment.

    Interactivity in Windows Forms is controlled by accessing the NController object exposed from the Controller property of the control:

    C#
    Copy Code
    NController controller = chartControl.Controller;
    
    Visual Basic
    Copy Code
    Dim controller As NController = chartControl.Controller
    

    The controller has two properties: Selection and Tools that work together when interactivity operations occur.

     Selection

    The selection object represented by the NSelection class holds the selected elements in the control. It provides the target for interactivity operations. For example when you use data point dragging it will check whether the selection contains a data point and if so it will start to drag it. The following code obtains the selection object from the controller:

    C#
    Copy Code
    NController controller = chartControl.Controller;
    NSelection selection = controller.Selection;
    
    Visual Basic
    Copy Code
    Dim controller As NController = chartControl.Controller
    Dim selection As NSelection = controller.Selection
    

    The selection can be modified both programmatically and by the user.

     Tools Collection

    The tools collection holds objects derived directly or indirectly from the NTool object. It is accessible through the Tools property of the Controller object:

    C#
    Copy Code
    NController controller = chartControl.Controller;
    NToolCollection tools = controller.Tools;
    
    Visual Basic
    Copy Code
    Dim controller As NController = chartControl.Controller
    Dim tools As NToolCollection = controller.Tools
    

    There are four major tool types as described in the following table:

    Tool Type Description
    Selector Tool Dynamically modifies the selection based on the chart element the mouse is currently over.
    Drag Tool Checks the selection for objects of type it requires and if such objects are present in the selection starts a drag operation when the user presses the left mouse button and drags the mouse.
    Interactivity Tool Checks the InteractivityStyle applied on the chart element the mouse is currently over and performs an action accordingly. For example display tooltip or change the mouse cursor.
    Synchronizer Tool Passes mouse and keyboard input to a chart element. For example mouse down event to an axis scroller.

    The following topics show how to work with the Selection and ToolsCollection objects that help you to create highly interactive charts.

     Related Examples
    Windows forms: Interactivity\Drag Operations; Interactivity\Mouse Events; Interactivity\Tooltips and Cursors

    See Also

    NChartControl | NInteractivityStyleOffset Tool | Zoom Tool | Trackball Tool | Data Zoom Tool | Data Pan Tool | Data Point Drag Tool

    See Also