Chart for .NET / Getting Started / Integrating ThinWeb Chart / Tools / Trackball Tool
In This Topic
    Trackball Tool
    In This Topic

    The trackball tool allows the user to change the rotation and elevation properties of the currently selected chart. This tool works only in case the currently active chart is operating in 3D mode. In order to use the trackball tool you must create an instance of the NTrackballTool object and add it to the control Tools collection:

    C#
    Copy Code

    NThinChartControl1.Controller.Tools.Add(new NTrackballTool());

    Visual Basic
    Copy Code

    NThinChartControl1.Controller.Tools.Add(new NTrackballTool())

    Note that the tool requires the control to have an active chart. Check out the Panel Selector Tool for more information on how to set the active chart.

    The following code snippet shows how to create a simple rotatable pie chart that displays the current rotation and elevation parameters in a label.

    C#
    Copy Code

    public partial class _Default : System.Web.UI.Page

    {

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!NThinChartControl1.Initialized)
    {
    // get the default chart
    NThinChartControl1.Panels.Clear();

    // create the first pie chart
    NPieChart pieChart = new NPieChart();
    NLabel label = new NLabel();
    label.Text =
    "Rotation [" + pieChart.Projection.Rotation.ToString() + "], Elevation [" + pieChart.Projection.Elevation.ToString() + "]";
    label.Dock =
    DockStyle.Top;
    NThinChartControl1.Panels.Add(label);
    pieChart.Enable3D =
    true;
    pieChart.Dock =
    DockStyle.Fill;
    pieChart.Margins =
    new NMarginsL(10, 10, 10, 10);
    NPieSeries pieSeries = new NPieSeries();
    pieSeries.DataLabelStyle.Visible =
    false;
    pieChart.Series.Add(pieSeries);
    pieSeries.Values.Add(10);
    pieSeries.Values.Add(20);
    pieSeries.Values.Add(30);
    NThinChartControl1.Panels.Add(pieChart);

    // apply style sheet
    NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.NevronMultiColor);
    styleSheet.Apply(NThinChartControl1.Document);

    // add trackball tool
    NThinChartControl1.Controller.SetActivePanel(pieChart);

    NTrackballTool trackballTool = new NTrackballTool();
    trackballTool.TrackballCallback =
    new TrackballCallback();
    NThinChartControl1.Controller.Tools.Add(trackballTool);

    }

    }

    [Serializable]

    class TrackballCallback : INTrackballCallback

    {

    #region INTrackballCallback Members

    public void OnTrackball(NThinChartControl control, NChart chart, float oldRotation, float oldElevation)

    {

    // update the label

    control.Labels[0].Text = "Rotation [" + chart.Projection.Rotation.ToString() + "], Elevation [" + chart.Projection.Elevation.ToString() + "]";

    }

    #endregion

    }

    }

     Related Examples
    Web Forms\ThinWeb\Trackball Tool
    Mvc\ThinWeb\Trackball Tool