?
Solved

MSChart - Data point values

Posted on 2001-08-09
18
Medium Priority
?
2,333 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 100 total points
ID: 6368727
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
ID: 6368811
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
ID: 6368834
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:nickwoolley
ID: 6383258
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
ID: 6383326
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
ID: 6383551
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
ID: 6383814
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
ID: 6384657
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
ID: 6384706
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
 

Author Comment

by:nickwoolley
ID: 6387378
Have a good one.
0
 
LVL 3

Expert Comment

by:adg
ID: 6410571
Listening
0
 

Author Comment

by:nickwoolley
ID: 6431251
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
ID: 6435880
   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
ID: 6519264
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
ID: 6519286
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
ID: 39328209
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
ID: 39341361
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
ID: 39343319
no problem. ok - giong with a 3rd party tool ...
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

593 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