Nevron .NET Vision
Chart for .NET / Getting Started / Integrating ThinWeb Chart / Tools / Panel Selector Tool
In This Topic
    Panel Selector Tool
    In This Topic

    The panel selector tool is used to dynamically select the active panel, which then becomes the target of tools that require such panel (like trackball, data zoom, panning etc). In order to create a panel selector tool you need to create an instance of the NPanelSelectorTool class and add it to the control tools collection:

    C#
    Copy Code

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

    Visual Basic
    Copy Code

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

    This tool is useful when you have multiple charts in a single control and want to give the user the ability to dynamically switch between them. The following code snippet creates two pie charts that can be rotated with the mouse - note that the code also intercepts the panel selector tool callback and provides some visual feedback of the currently selected chart.

    C#
    Copy Code

    protected void Page_Load(object sender, EventArgs e)

    {

    if (!NThinChartControl1.Initialized)
    {

    // get the default chart
    NThinChartControl1.Panels.Clear();

    // create the first pie chart
    NPieChart pieChart1 = CreatePieChart();
    pieChart1.Location =
    new NPointL(0, 0);
    pieChart1.Size =
    new NSizeL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage));
    NThinChartControl1.Panels.Add(pieChart1);

    // create the second pie chart
    NPieChart pieChart2 = CreatePieChart();
    pieChart2.Location =
    new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(0));
    pieChart2.Size =
    new NSizeL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage));
    NThinChartControl1.Panels.Add(pieChart2);

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

    // add panel selector and trackball tools
    NPanelSelectorTool panelSelector = new NPanelSelectorTool();
    panelSelector.ActivatePanelCallback =
    new ActivatePanelCallback();
    NThinChartControl1.Controller.Tools.Add(panelSelector);
    NThinChartControl1.Controller.Tools.Add(
    new NTrackballTool());

    }

    }

    private NPieChart CreatePieChart()

    {

    NPieChart pieChart = new NPieChart();
    pieChart.Enable3D =
    true;
    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);
    return pieChart;

    }

    [Serializable]

    class ActivatePanelCallback : INActivatePanelCallback

    {

    #region INActivatePanelCallback Members

    void INActivatePanelCallback.OnActivatePanel(NThinChartControl control, NContentPanel newActivePanel, NContentPanel oldActivePanel)
    {
    // when the currently active panel changes, change its border to prompt the user
    if (oldActivePanel != null)
    {
    oldActivePanel.BorderStyle =
    null;
    }
    if (newActivePanel != null)
    {

    newActivePanel.BorderStyle = new NStrokeBorderStyle();
    }

    control.UpdateView();
    }

    #endregion
    }
    }

    In some cases you may want to have only one active panel in the control regardless of whether you have multiple charts or not. In this case you can manually set the currently active panel trough code - for example:

    C#
    Copy Code

    NThinChartControl1.Controller.SetActivePanel(NThinChartControl1.Charts[0]);

    Visual Basic
    Copy Code

    NThinChartControl1.Controller.SetActivePanel(NThinChartControl1.Charts(0))

    The code above sets the active panel to be the first chart in the control charts collection.

     Related Examples
    Web Forms\ThinWeb\Panel Selector Tool
    Mvc\ThinWeb\Panel Selector Tool