Draw graphs in VB6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raghunadhs
    New Member
    • May 2007
    • 52

    Draw graphs in VB6

    Hi All,

    I have few pairs of float vlues, like (1.5,4.5),(4.67 ,8.90)..etc.
    Now i want to draw a graph among the points. is there any "Graph" control? is it possible to draw graphs in V.B 6.0? if it is possible,kindly let me know it.

    Thanks in advance:
    regards:
    raghunadhs.
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Use this Line Function :

    [code=vb]
    Me.Line (X1, Y1) - (X2, Y2)
    [/code]


    Regards
    Veena

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      As QVeen72 points out, you could draw it all yourself, using the graphics methods such as Pset and Line. However, probably your simplest approach would be to use the MS Chart control.

      Comment

      • raghunadhs
        New Member
        • May 2007
        • 52

        #4
        Thanks QVeen72, and Killer
        could you give me syntax, how to use chart control? i have found that control in components, and dragged and drooped on the form. but i don't know how to use it. if possible kindly give me a sample code also..
        Thanks in advance:
        regards:
        raghunadhs

        Originally posted by Killer42
        As QVeen72 points out, you could draw it all yourself, using the graphics methods such as Pset and Line. However, probably your simplest approach would be to use the MS Chart control.

        Comment

        • QVeen72
          Recognized Expert Top Contributor
          • Oct 2006
          • 1445

          #5
          Hi,

          What I feel is, MSChart Control and most of such controls rely on the Data and Draw a graph, Say Compare Customer wise Sales for Previous Year and Present Year, U need to give the Amount of Data and the Graph Lines, Re-Adjust itself... Since have the CoOrdinates of Points already, U better use "Line" function.

          REgards
          Veena

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Sorry, I don't have any experience with the MSChart control. If you try the search box, you'll probably find other discussions about it here though.

            Comment

            • raghunadhs
              New Member
              • May 2007
              • 52

              #7
              Ok, Killer,no problem i will search...

              and Qveen, i tried that line method.

              instead of x1,y1,x2,y2 i substituted my own values.. is it right? or any thing else. if it is correct, how can i draw lines for small readings like (5,6),(8,9) like that?
              if what i am thinking is wrong, please provide me a sample code...

              Thanks:
              regards:
              raghunadhs

              Originally posted by Killer42
              Sorry, I don't have any experience with the MSChart control. If you try the search box, you'll probably find other discussions about it here though.

              Comment

              • debasisdas
                Recognized Expert Expert
                • Dec 2006
                • 8119

                #8
                If you use MS Chart control, it can be connected to database easily.

                Comment

                • raghunadhs
                  New Member
                  • May 2007
                  • 52

                  #9
                  Hi, debasisdas,
                  I don't want to connect with database. I just want to plot a graph, with set of (x1,y1),(x2,y2) pairs. And those readings may be floating point. I want a way to do this. It may be either regarding to MS Chart or Line method of graphics.

                  If you know how to do it in MS Chart, kindly let me know the syntax.
                  Thanks:
                  regards:
                  raghunadhs
                  Originally posted by debasisdas
                  If you use MS Chart control, it can be connected to database easily.

                  Comment

                  • debasisdas
                    Recognized Expert Expert
                    • Dec 2006
                    • 8119

                    #10
                    please try this sample code
                    [CODE=vb]Dim X(1 To 7, 1 To 6) As Variant

                    X(1, 2) = "Rice"
                    X(1, 3) = "Corn"
                    X(1, 4) = "Lentilis"
                    X(1, 5) = "Wheat"
                    X(1, 6) = "Rye"

                    X(2, 1) = "JANUARY"
                    X(2, 2) = 2
                    X(2, 3) = 3
                    X(2, 4) = 4
                    X(2, 5) = 5
                    X(2, 6) = 6

                    X(3, 1) = "FEBRUARY"
                    X(3, 2) = 4
                    X(3, 3) = 6
                    X(3, 4) = 3
                    X(3, 5) = 10
                    X(3, 6) = 18

                    X(4, 1) = "MARCH"
                    X(4, 2) = 1
                    X(4, 3) = 3
                    X(4, 4) = 8
                    X(4, 5) = 7
                    X(4, 6) = 9

                    X(5, 1) = "APRIL"
                    X(5, 2) = 4
                    X(5, 3) = 6
                    X(5, 4) = 13
                    X(5, 5) = 10
                    X(5, 6) = 12

                    X(6, 1) = "MAY"
                    X(6, 2) = 2
                    X(6, 3) = 9
                    X(6, 4) = 9
                    X(6, 5) = 12
                    X(6, 6) = 7

                    X(7, 1) = "JUNE"
                    X(7, 2) = 13
                    X(7, 3) = 20
                    X(7, 4) = 5
                    X(7, 5) = 18
                    X(7, 6) = 11

                    MSChart1.ChartD ata = X[/CODE]

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      Originally posted by debasisdas
                      please try this sample code ...
                      Very nice! :)

                      Thanks for that, debasisdas. I think we should write this up for the Articles area.

                      Comment

                      • debasisdas
                        Recognized Expert Expert
                        • Dec 2006
                        • 8119

                        #12
                        Originally posted by Killer42
                        Very nice! :)

                        Thanks for that, debasisdas. I think we should write this up for the Articles area.
                        ok i will post that as an article with some explanations.

                        Comment

                        • raghunadhs
                          New Member
                          • May 2007
                          • 52

                          #13
                          Hi debasisdas,
                          This was very nice. there is no doubt. i think it is a bar chart. but i need a graph.Means user should be able to draw lines between (x1,y1),(x2,y2) points.and these number of points are depending upon the user's choice(it may be 10 or 15)
                          egg:
                          ( X1 , Y1) (X2 , Y2)
                          (2.34 , 3.12), (5.45 , 8.78)
                          (6.98 ,10.23) (3.67,13.56)


                          if i could not explain this question much better, please let me know it.so that i will try to post this thread with more clarity.
                          Thanks:
                          regards:
                          raghunahds.

                          Originally posted by debasisdas
                          ok i will post that as an article with some explanations.

                          Comment

                          • debasisdas
                            Recognized Expert Expert
                            • Dec 2006
                            • 8119

                            #14
                            if u want lines, not chart then use

                            [CODE=vb]Me.Line (X1, Y1) - (X2, Y2)[/CODE]
                            as already suggested by Qveen

                            Comment

                            • QVeen72
                              Recognized Expert Top Contributor
                              • Oct 2006
                              • 1445

                              #15
                              Hi Raghu,

                              If u have Small Readings and want a Clear Picture, u can Multiply By Some Common Factor say 10,
                              So if ur Line is (4,6) to (8,7)

                              U can Draw, (40,60) to (80,70)

                              Regards
                              Veena

                              Comment

                              Working...