Solved

MSChart - Data point values

Posted on 2001-08-09
18
2,213 Views
Last Modified: 2013-07-21
Can the values of data points on an MSChart be retrieved by the mousemove or mouseclick events. If so can you give me some sample code please?
0
Comment
Question by:nickwoolley
  • 7
  • 6
  • 2
  • +2
18 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 25 total points
Comment Utility
Nick, you can do it with the pointselected event:

Private Sub chtTrend_PointSelected(Series As Integer, DataPoint As Integer, MouseFlags As Integer, Cancel As Integer)
    Dim dblValue As Double
    blnSelecting = True
    lstTrend.ListIndex = (DataPoint * 2) - IIf(Series = 2, 2, 1)
    chtTrend.DataGrid.GetData DataPoint, Series, dblValue, 1
    MsgBox dblValue
    blnSelecting = False
End Sub
0
 

Author Comment

by:nickwoolley
Comment Utility
Thanks Tim, can you also get an x/y point which is not necessarily a plot/data point?
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
I don't think you can Nick, the mousemove event will give you an x/y coordinate relative to the chart control but you would have to work out where this is relative to the plot and the scale of the axes. It might take some time to figure this out if it is even possible.
0
 

Author Comment

by:nickwoolley
Comment Utility
To be able to get an x/y coord relative to the 0,0 point is what I was hoping to do, I was wondering if I could do it without having to overlay say a picturebox or something.
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
Nick, I haven't forgotten this but have been a bit busy recently. I will try to have a look before I go on Holiday this weekend.
0
 

Author Comment

by:nickwoolley
Comment Utility
Thanks Tim, no hurry. Going anywhere nice?

I see you have been climbing up the ee leader board recently.  
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
Indeed, been a good month, 20K points so far and just made it to number 25 overall!

I am off to Ireland for a fortnight, we have a house there and my Wife and kids have been there for the last four weeks so it will be good to see everyone again. It is a great break as the house is about 200 yds from the atlantic with almost no-one else around.
0
 

Author Comment

by:nickwoolley
Comment Utility
Nice and quiet then. Hope you're not like me and take your laptop on holiday with you!!
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
My Wife has her's already there and there is an old PC in the corner but given that the phone connection is a radio one and it connects at the massive speed of 1200 baud or thereabouts it is pretty much useless for anything. Add to that the fact that my wife would probably give me hell if I come within a few feet of a computer for anything other than a very good reason (in her opinion). I tend to take the opportunity to leave them alone for a couple of weeks. It does me no harm to have a rest once a year anyway.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:nickwoolley
Comment Utility
Have a good one.
0
 
LVL 3

Expert Comment

by:adg
Comment Utility
Listening
0
 

Author Comment

by:nickwoolley
Comment Utility
Tim: There's been some interesting conversations re MS Chart at http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20171373 "VB for MSChart -  display the data points as circles on a 2dLine Chart and  x-axis showing dates"
0
 
LVL 3

Expert Comment

by:adg
Comment Utility
   Option Explicit
' the intent is to calculate the x,y offset in twips from the origin of the
' graph.  I wouldn't use this in production code but I just posted it since
' it seems to work (sort of).

Private Sub Form_Resize()
    MSChart1.Move ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight
End Sub

Private Sub MSChart1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim xorg As Single, yorg As Single
    Dim part As Integer, id1 As Integer, id2 As Integer, id3 As Integer, id4 As Integer
    With MSChart1
        ' assumption: y intersects x at zero
        yorg = .Height - .Plot.LocationRect.Min.Y - .Plot.PlotBase.BaseHeight
        For xorg = .Plot.LocationRect.Min.X To .Plot.LocationRect.Max.X
            .TwipsToChartPart xorg, yorg, part, id1, id2, id3, id4
            If part = VtChPartTypeAxis And id1 = VtChAxisIdY Then Exit For
        Next xorg
        If xorg = .Plot.LocationRect.Max.X Then
            MsgBox "Y Axis not found!"
        Else
            Debug.Print
            Debug.Print "X,Y= "; X - xorg - 113 & "," & yorg - Y - 48
        End If
    End With
End Sub
0
 

Author Comment

by:nickwoolley
Comment Utility
Hi Tim, I see you are climbing the leader board. I'm sure this question became too complex for 25 pts, anyway I've decided that it is better to create a user control to create the graph and determine data points.
Thanks,
Nick
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
Probably a good choice Nick, I hadn't totally forgotten this one but hadn't quite got around to looking at it in any detail.
0
 
LVL 1

Expert Comment

by:LukeB
Comment Utility
Hi Nick , did you have this working in Excel or ? if Excel or Access would you mind sending me a demo, much appreciated. Luke
0
 
LVL 1

Expert Comment

by:ncw
Comment Utility
This was back in 2001, 12 years ago, I'm sorry I can't recall. The project got complicated and didn't get completed.
0
 
LVL 1

Expert Comment

by:LukeB
Comment Utility
no problem. ok - giong with a 3rd party tool ...
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now