Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2316
  • Last Modified:

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?
0
nickwoolley
Asked:
nickwoolley
  • 7
  • 6
  • 2
  • +2
1 Solution
 
TimCotteeCommented:
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
 
nickwoolleyAuthor Commented:
Thanks Tim, can you also get an x/y point which is not necessarily a plot/data point?
0
 
TimCotteeCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
nickwoolleyAuthor Commented:
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
 
TimCotteeCommented:
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
 
nickwoolleyAuthor Commented:
Thanks Tim, no hurry. Going anywhere nice?

I see you have been climbing up the ee leader board recently.  
0
 
TimCotteeCommented:
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
 
nickwoolleyAuthor Commented:
Nice and quiet then. Hope you're not like me and take your laptop on holiday with you!!
0
 
TimCotteeCommented:
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
 
nickwoolleyAuthor Commented:
Have a good one.
0
 
adgCommented:
Listening
0
 
nickwoolleyAuthor Commented:
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
 
adgCommented:
   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
 
nickwoolleyAuthor Commented:
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
 
TimCotteeCommented:
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
 
LukeBCommented:
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
 
ncwCommented:
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
 
LukeBCommented:
no problem. ok - giong with a 3rd party tool ...
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 7
  • 6
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now