Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Drawing our Own Charts on Forms with out using the MSChart Control

Drawing our Own Charts on Forms with out using the MSChart Control

Scheduled Pinned Locked Moved Visual Basic
csharpgraphics
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    EmanAli
    wrote on last edited by
    #1

    Hi Every one i am making a project, in which i need to draw the charts by means of simple drawing methods as used in VB.Net. So that i can make any type of chart i want to draw. I want to draw the charts like in MS Acess. Thanks Eman Ali.

    D 1 Reply Last reply
    0
    • E EmanAli

      Hi Every one i am making a project, in which i need to draw the charts by means of simple drawing methods as used in VB.Net. So that i can make any type of chart i want to draw. I want to draw the charts like in MS Acess. Thanks Eman Ali.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Great! And your question is? RageInTheMachine9532

      E 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Great! And your question is? RageInTheMachine9532

        E Offline
        E Offline
        EmanAli
        wrote on last edited by
        #3

        this is my question

        D 1 Reply Last reply
        0
        • E EmanAli

          this is my question

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          First, I have to question why you would want to do this? There are many controls already out there that handle chart drawing of any imaginable type. I just don't see the point in reinventing the wheel...? But if you must, you could use a PicBox or draw directly on the Form itself. I would suggest writing this as a control using a PicBox so it can be reused in other projects. First, you have to work out a method of keeping track of data. This is going to depend on the type of data your working with. Then, you calculate the scaling for your data, then calculate the size of your chart and its scaling in the PicBox. Your also going to have to calculate positions for labels and font scaling. When you have all that, you have to write your code to paint the chart in the Paint event of your control. Get a Graphics object for the PicBox by using the CreateGraphics method of the PicBox. Then you can use the Graphics objects methods to draw what your chart is going to look like. Just as an example of drawing using the Graphics object, this is a little snippet of code from a goofy little control project I worked on a while back:

          Private Sub threadDrawingLines()
              Dim x As Integer
              Dim objPen As New Pen(Color.Blue)
              Dim grPicBox As Graphics = PictureBox1.CreateGraphics
          
              Try
                  While (pNumberOfLines > 0)
                      For x = 1 To pNumberOfLines
                          grPicBox.DrawLine(objPen, Lines(x, 1), Lines(x, 2))
                      Next
                      UpdatePositions()
                      Thread.Sleep(pSleepTime)
                  End While
              Catch ex As ThreadAbortException
                  grPicBox = Nothing
                  objPen = Nothing
              End Try
          End Sub
          

          RageInTheMachine9532

          E 1 Reply Last reply
          0
          • D Dave Kreskowiak

            First, I have to question why you would want to do this? There are many controls already out there that handle chart drawing of any imaginable type. I just don't see the point in reinventing the wheel...? But if you must, you could use a PicBox or draw directly on the Form itself. I would suggest writing this as a control using a PicBox so it can be reused in other projects. First, you have to work out a method of keeping track of data. This is going to depend on the type of data your working with. Then, you calculate the scaling for your data, then calculate the size of your chart and its scaling in the PicBox. Your also going to have to calculate positions for labels and font scaling. When you have all that, you have to write your code to paint the chart in the Paint event of your control. Get a Graphics object for the PicBox by using the CreateGraphics method of the PicBox. Then you can use the Graphics objects methods to draw what your chart is going to look like. Just as an example of drawing using the Graphics object, this is a little snippet of code from a goofy little control project I worked on a while back:

            Private Sub threadDrawingLines()
                Dim x As Integer
                Dim objPen As New Pen(Color.Blue)
                Dim grPicBox As Graphics = PictureBox1.CreateGraphics
            
                Try
                    While (pNumberOfLines > 0)
                        For x = 1 To pNumberOfLines
                            grPicBox.DrawLine(objPen, Lines(x, 1), Lines(x, 2))
                        Next
                        UpdatePositions()
                        Thread.Sleep(pSleepTime)
                    End While
                Catch ex As ThreadAbortException
                    grPicBox = Nothing
                    objPen = Nothing
                End Try
            End Sub
            

            RageInTheMachine9532

            E Offline
            E Offline
            EmanAli
            wrote on last edited by
            #5

            tahkns for the help. Its mean that what i was doing is write i am making my own charts . The reason why , which you have asked , The answer is that i have devoloped the clases for printing so what ever i draw on the panel will go as an output to the printer. And the project on which i am working is a document formatter which is connected to some data sourse and the charting facility like Acces is a main module for the project. so Thats why i am doing all my own.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups