Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MSChart - Data point values

Posted on 2001-08-09
18
Medium Priority
?
2,292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

688 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