Results 1 to 14 of 14

Thread: Plot graphs

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    9

    Lightbulb

    Hi,
    My VB program should read data from a datafile and plot graphs based on the data in the datafile by clicking a button?? can anyone help me out in figuring how to do it.

    I have tried embedding excel and working in excel, but I need something like on clicking a button it should plot the graphs..

    any help is greatly appreciated
    thanks
    p1

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Lightbulb

    I'm gonna do something with graphs soon too. The best way I've figured out so far is with the MS Chart Control. I'm not sure how to use it yet, but I got a book on VB Controls so I'll figure it out.

    Anyway that's how I'm doing it. If you want me to look something up just ask
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    9

    Question Plot graphs

    Hi Harry,
    Thanks for your message,
    may be you can help me in this, I open my data file(it has text and data(very long data)) in a rich text box and I am trying to use "find" command to go to a particular string and get all the data from that point till it reaches another string and plot that collected data using MS graphs.

    could you give me any insight towards how to go about it or do you have any other ideas to go about?

    Thanks, I really appreciate it.
    P1

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Well, the first bit you describe, getting all the data between two strings which you search for is pretty simple, using the InStr function.

    I might have some insight if I knew how this string of data you have is formatted ie. the data are comma-delimited, tab-delimited, or whatever. If there's a delimiting character, then it's fairly easy to extract the data.

    Once you have the data, I expect you can use the MS Chart control to display it. As I said I'm not entirely sure how the MS Chart control works yet (I've been busy programming in C recently) but I can easily find out.

    If you can reply saying how your data string is formatted, I'll probably be able to help further
    Harry.

    "From one thing, know ten thousand things."

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    9

    Lightbulb plot graphs

    Hi,

    My data file looks something like this:

    Checker Profile
    Height 1 2 3 4 5 6 7
    0 2 3 4 5 6 7 8
    1 23 34 54 45 54 45 654

    Brick Profile
    .....data

    so I need to plot the data under checker profile, data is printed in a richtextbox and using find or Instr methods find "checker" then take all the data and plot graphs.

    the string of data is actually tab delimited

    thanks
    p1

  6. #6
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Smile

    So you can get all the data out, looks like all you need is how to use the chart control.

    I'll post again when I get home from work this evening with some information on the MS Chart control. There's about 30 pages on it if I remember, but I'm not going to type it all out

    I'll take a good look at it anyway, and post again later.
    Harry.

    "From one thing, know ten thousand things."

  7. #7
    Lively Member
    Join Date
    Jan 2000
    Posts
    123

    Question

    Hey Harry, what exactly is that book you have?

  8. #8

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    9

    Question plot graphs

    hey harry,
    could you post those pages?

    which is the book you are referring to?
    Thanks
    p1

  9. #9
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    The project I am working on includes some simple bar graphs. I had a look at the mschart control, but the graphics it produces where of that poor quality, I decided to use a picturebox instead and draw the graphs myselve.
    Luckily the bar graphs are simple to draw.

  10. #10

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    9
    Hi FransC

    Could you throw some light on how you plotted graphs using picture box?

    Thanks
    p1

  11. #11
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Exclamation

    D'oh!

    Sorry man, I totally forgot what with the whole Easter thing, and family business Erm.. you still want em?
    Harry.

    "From one thing, know ten thousand things."

  12. #12

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    9
    Harry,
    yup I need them
    Thanks
    P1

  13. #13
    Lively Member
    Join Date
    Jan 2000
    Posts
    123
    I would also like to know!!!

  14. #14
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Talking Finally...

    Okay, the book I have is 'Visual Basic COntrols in a Nutshell' by Evan S. Dictor. It's part of the 'in a nutshell' series by O'Reilly & Associates.

    ISBN 1-56592-294-8

    You first have to define the data that the chart will use. You can do that by defining fata one item at a time, assigning multiple values at once, or by using the MSChart control's data grid directly.

    One at a time:
    The chat control has properties rowcount and columncount, which you first set to the maximum sizes of your table of data.

    Then you define a current row and column using the row and column properties. Then you can assign a value to the current cell using the data property.

    Multiple values at once:
    To do this you create an array of the same dimensions of your table, with all your data in, and assign that array to the ChartData property.

    Using the datagrid:
    Retrieve a reference to the datagrid object
    Code:
    Dim objDataGrid as DataGrid
    Set objDataGrid = Me.MSChart1.DataGrid
    Then you use the GetData and SetData methods of the control to change the data in the datagrid like this:
    Code:
    objDataGrid.GetData Row, column, DataPoint, NullFlag
    Row and Column are obvious, and DataPoint is a double that is the data value you are assigning, or a variable name to retrieve the value to. NullFlag is an integer that indicates whether DataPoint is null.

    Okay so that's how you change the data the grid uses. There's some other methods and stuff but like I said, I'm not typing it all out. Now you need to set the chart type etc., and that's done using the ChartType property. THere's a list of constants for different styles, like vtChChartType3dBar.

    Anyway that's the basics, there's loads of objects withing the control with their own properties, like different series and labels and things. If you need anything specific I'll post it. Hope that much helps to get started anyway
    Harry.

    "From one thing, know ten thousand things."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width