Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Tools for Microsoft .Net
 SPC Control Chart Tools for .Net
 How to catch the point when it was clicked?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
fanyorn Posted - 30 Aug 2009 : 12:07:13
Hi,
how to get the point's index when I double click the point on the chart,I have searched all of example CS codes about MouseListener,but there seems no means to get this index value.

Thanks.
5   L A T E S T    R E P L I E S    (Newest First)
quinncurtis Posted - 10 Dec 2013 : 10:17:45
It would look something like this.

Private Class CustomToolTip
        Inherits DataToolTip

        Public Sub New(ByVal component As ChartView)
            MyBase.New(component)
        End Sub 'New


        Public Overrides Sub OnDoubleClick(ByVal [me] As EventArgs)
            Dim mouseevent As MouseEventArgs = DirectCast([me], MouseEventArgs)
            Dim mousepos As New Point2D()
            mousepos.SetLocation(mouseevent.X, mouseevent.Y)
            MyBase.OnDoubleClick([me])

            Dim selectedPlot As ChartPlot = DirectCast(GetSelectedPlotObj(), ChartPlot)
            If selectedPlot IsNot Nothing Then
                Dim selectedindex As Integer = GetNearestPoint().GetNearestPointIndex()


                Dim transform As PhysicalCoordinates = GetSelectedCoordinateSystem()
            End If
        End Sub

    End Class



You would add the class defintion to the main SPC Chart class. Using the SPCApplication1 example as a starting point, you would add it to the UserChartControl1 class

Create a public instance of it so you can access throughout the UserChartControl1 class.

Public Class UserChartControl1
    Dim startTime As New ChartCalendar()
    ' The time increment between adjacent subgroups
    Dim timeincrementminutes As Integer = 15

    ' Number of samples per sub group
    Dim numsamplespersubgroup As Integer = 5
    Dim tooltip As CustomToolTip
.
.
.


Instantiate it in the InitializeChart method


    Public Sub InitializeChart()
.
.
.
       ' New data
        SimulateData(50, 30, 15)

        tooltip = New CustomToolTip(Me)
        tooltip.SetEnable(True)

        ' Scale the y-axis of the X-Bar chart to display all data and control limits
        Me.AutoScalePrimaryChartYRange()
        ' Scale the y-axis of the Range chart to display all data and control limits
        Me.AutoScaleSecondaryChartYRange()
        ' Rebuild the chart using the current data and settings
        Me.RebuildChartUsingCurrentData()
.
.
.
   End Sub 'InitializeChart


One last thing. Override the PreDraw method for the UserChartControl1 class and call SetCurrentMouseListener there. This is needed because only the standard mouse listeners are retained after each redraw, and custom ones need to be added back in each time the chart is redrawn.

Public Overrides Sub PreDraw(ByVal g2 As Graphics)
        Me.SetCurrentMouseListener(toolTip)
    End Sub

quahys Posted - 10 Dec 2013 : 04:25:49
Would you mind to post a VB.net version for coding that portion? Because I'm not familiar with C#.
I was wondering when I double click at any data point, could I execute some functions and point index can be retrieved as well.
Any example would be appreciated.
quinncurtis Posted - 01 Sep 2009 : 13:47:25
You found a flaw in adding an external mouse listener the way we described. Once the scroll bar forces a change, or rebuilding of the graph, the mouse listeners are reset, and only the standard ones are reinitialized for the new graph. External ones like the one you added are not. We can describe simple workaround, but we will wait until you actually own the software.
fanyorn Posted - 01 Sep 2009 : 11:46:53
Thank for your reply,it works now,but we found a strange problem:
The event was not invoked when the following codes was added:
this.HScrollBar1.Value = this.HScrollBar1.Maximum - numdatapointsinview;


Could you please give some explanation about it?

By the way,we now just doing some funtion test on this library,and we are sure of considering the purchase if there is no function problem. -:)

Thanks.
quinncurtis Posted - 30 Aug 2009 : 18:57:15
You can use a subclass of the DataToolTip class, much like the ChartZoom class in the previous example

class CustomToolTip : DataToolTip
        {
            public CustomToolTip(ChartView component)
                : base(component)
            {
            }

            public override void OnDoubleClick(EventArgs me)
            {
                MouseEventArgs mouseevent = (MouseEventArgs)me;
                Point2D mousepos = new Point2D();
                mousepos.SetLocation(mouseevent.X, mouseevent.Y);
                base.OnDoubleClick(me);

                ChartPlot selectedPlot = (ChartPlot)GetSelectedPlotObj();
                if (selectedPlot != null)
                {
                    int selectedindex = GetNearestPoint().GetNearestPointIndex();
                    PhysicalCoordinates transform = GetSelectedCoordinateSystem();


                }
            }
        }


Install it in the main part of the program using code similar to:

CustomToolTip tooltip = new CustomToolTip(this);
            tooltip.SetDataToolTipFormat(ChartObj.DATA_TOOLTIP_CUSTOM);
            tooltip.SetEnable(true);
            this.SetCurrentMouseListener(tooltip);


If you are still using a trial version of the software after more than 30 days, you should think about getting a commercial license.

Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07