Link to home
Start Free TrialLog in
Avatar of nickwoolley
nickwoolley

asked on

MSChart - Data point values

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?
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nickwoolley
nickwoolley

ASKER

Thanks Tim, can you also get an x/y point which is not necessarily a plot/data point?
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.
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.
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.
Thanks Tim, no hurry. Going anywhere nice?

I see you have been climbing up the ee leader board recently.  
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.
Nice and quiet then. Hope you're not like me and take your laptop on holiday with you!!
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.
Have a good one.
Listening
Tim: There's been some interesting conversations re MS Chart at https://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"
   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
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
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.
Hi Nick , did you have this working in Excel or ? if Excel or Access would you mind sending me a demo, much appreciated. Luke
This was back in 2001, 12 years ago, I'm sorry I can't recall. The project got complicated and didn't get completed.
no problem. ok - giong with a 3rd party tool ...