Profile Picture

How to get Double-Click event in WebForms - NThinChartControl with active Zoom-Tool

Posted By joern kunze 7 Years Ago

How to get Double-Click event in WebForms - NThinChartControl with...

Author
Message
joern kunze
Posted 7 Years Ago
View Quick Profile
Junior Member

Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)

Group: Forum Members
Last Active: 4 Months Ago
Posts: 86, Visits: 221
Hi Experts,

I want to implement in a NThinChartControl a Zoom-functionality and reset the zoom on Double click. I have added a Zoom and a MouseEventTool:
     //----- Zoom Tool
      NDataZoomTool dataZoomTool = new NDataZoomTool();
      dataZoomTool.Exclusive = true;
      dataZoomTool.Enabled = true;
      dataZoomTool.DataZoomCallback = new eventSink_ChartDataZoomCallback();
      NThinChartControl1.Controller.Tools.Add(dataZoomTool);
      NThinChartControl1.ScrollCallback = new eventSink_ChartScrollbarCallback();

     //----- MouseEventTool
      serverMouseEventTool = new NServerMouseEventTool();
      NThinChartControl1.Controller.Tools.Add(serverMouseEventTool);
serverMouseEventTool.MouseDoubleClick = new eventSink_ChartDoubleClick();

When I implement just the MouseEventTool - all is working. But as soon as I implement the DataZoomTool as well, the Event eventSink_ChartDoubleClick(...) doesnt occure anymore. The Zoom is working though.

Is there a way to reset the Zoom on double click?

Thanks for the help,
best regards,
Joern

Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 1 days ago @ 4:39 AM
Posts: 3,054, Visits: 4,018
Hi Jorn,
We don't think it is possible to reset the zoom on double click as the browser will first send a click event which is intercepted by the data zoom tool. When the data zoom tool is activated by the click it will grab all mouse input of the control until it's deactivated (mouse up). Probably a better approach will be to have a button next to the chart or a custom toolbar button which when clicked reset the zoom. Hope this helps - let us know if you meet any problems or have any questions.

Best Regards,
Nevron Support Team



joern kunze
Posted 7 Years Ago
View Quick Profile
Junior Member

Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)

Group: Forum Members
Last Active: 4 Months Ago
Posts: 86, Visits: 221
Is it possible to create a new button within the ThinChart Toolbar for resetting the Zoom? So far, I am using the following buttons from the toolbar:

     NThinChartControl1.Toolbar.Visible = true;

      NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction()));
      NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataPanToolAction()));
      NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator());

      NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction(DateTime.Now.ToString("yyyyMMdd_HHmmss") + "__Chart", new NPngImageFormat(), true, new NSize(0, 0), 96)));


But I could not find a way to add a new button with a user specific callback function.

Thanks again, Best regards,
Joern

Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 1 days ago @ 4:39 AM
Posts: 3,054, Visits: 4,018
Hi Joern,

Yes it is possible to create toolbar buttons that have custom actions - the following code shows how to create a toolbar that has a reset axes custom toolbar button:

using System;
using System.Drawing;
using System.Web;
using Nevron.Chart;
using Nevron.Chart.ThinWeb;
using Nevron.GraphicsCore;
using Nevron.ThinWeb;

namespace Nevron.Examples.Chart.WebForm
{
    public partial class NToolbarConfigurationUC : NExampleUC
 {
        protected void Page_Load(object sender, EventArgs e)
        {
   NThinChartControl1.StateId = "Chart1";

   if (!NThinChartControl1.Initialized)
            {
                // set a chart title
                NLabel title = new NLabel("Toolbar Configuration");
                NThinChartControl1.Panels.Add(title);
                title.DockMode = PanelDockMode.Top;
                title.Padding = new NMarginsL(4, 6, 4, 6);
                title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
                title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

                // configure the legend
                   // configure the chart
                NCartesianChart chart = (NCartesianChart)NThinChartControl1.Charts[0];

                // setup the X axis
                NAxis axisX = chart.Axis(StandardAxis.PrimaryX);
                axisX.ScrollBar.Visible = true;

                // add interlaced stripe for the Y axis
                NAxis axisY = chart.Axis(StandardAxis.PrimaryY);
                axisY.ScrollBar.Visible = true;

                // add a bar series and fill it with data
                NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
                bar.Name = "Simple Bar Chart";
                bar.BarShape = BarShape.SmoothEdgeBar;
                bar.Legend.Mode = SeriesLegendMode.DataPoints;
                bar.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
                bar.DataLabelStyle.Visible = false;
    bar.Values.FillRandom(new Random(), 10);

                // configure toolbar
                NThinChartControl1.Toolbar.Visible = true;
                NThinChartControl1.Controller.SetActivePanel(chart);               

                // add a data zoom tool
                NDataZoomTool dataZoomTool = new NDataZoomTool();
                dataZoomTool.Exclusive = true;
                dataZoomTool.Enabled = false;
                NThinChartControl1.Controller.Tools.Add(dataZoomTool);

    NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction()));
    NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new ResetZoomAction()));

    NThinChartControl1.CustomRequestCallback = new CustomRequestCallback();
            }
        }
  /// <summary>
  /// A simple class showing how to show / hide data labels
  /// </summary>
  [Serializable]
  class ResetZoomAction : NAction
  {
   public ResetZoomAction()
    : base("Reset Zoom")
   {
   }

   public override Bitmap GetImage()
   {
    string path = HttpContext.Current.Server.MapPath(@"~\Images\ShowDataLabelsButton.png");
    return (Bitmap)Bitmap.FromFile(path);
   }

   public override string GetScript()
   {
    NThinChartControl control = (NThinChartControl)this.m_Control;
    return "NClientNode.GetFromId(\'" + control.StateId  + "\').ExecuteCustomRequest(\"ResetZoom\");";
   }

   public override bool IsEnabled()
   {
    NThinChartControl control = (NThinChartControl)this.m_Control;
    NChart chart = control.Charts[0];
    return chart.Axis(StandardAxis.PrimaryX).PagingView.Enabled || chart.Axis(StandardAxis.PrimaryY).PagingView.Enabled;
   }
  }
  [Serializable]
  public class CustomRequestCallback : INCustomRequestCallback
  {
   #region INCustomRequestCallback Members

   void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument)
   {
    NThinChartControl chartControl = (NThinChartControl)control;

    NChart chart = chartControl.Charts[0];

    switch (argument)
    {
     case "ResetZoom":
      {
       chart.Axis(StandardAxis.PrimaryY).PagingView.Enabled = false;
       chart.Axis(StandardAxis.PrimaryX).PagingView.Enabled = false;
      }
      break;
    }

    // update the control and toolbar
    chartControl.Update();
   }

   #endregion
  }
    }
}

Hope this help let us know if you meet any problems.


Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic