Custom Bar chart - Guidance needed

  • 13 years ago
    I want to develop a bar chart with the following requirements:

    An activity is represented as a box / rectangle with different colors. The colours change according to the activity. The width of the box determines the duration of the activity and is linked to start date and end date in a database record. The order of the activities will be changed by dragging the boxes (in the same row) and the record should be updated automatically. There are many people who are assigned these activities, which are represented in different rows. I should also be able to drag the boxes from one row to another with an immediate update of database.

    Could anyone help in telling me the best approach for this task? I am just an intermediate programmer. I hope that my requirement is understandable. Please help me...

  • 13 years ago

    Hi friends,

    I think my question was a bit complicated and no one answered.  Let me rephrase it.

    I want to create an object, a rectangle / box, with its own properties like name, color etc.  I also want to get the properties from a database.  How do I make it.  Can anyone point me to any article or posts in this forum or on the web?

    Thanks in advance...


  • 13 years ago


    Sorry my friend but am not having enough time to create you the required example but I posted you a module I previously created to display a graph of medical test results using arrays of pictures and labels.

    Dim rs As ADODB.Recordset

    Dim db As ADODB.Connection


    Private Sub Form_Load()

    Set db = New Connection

    db.Open "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;dsn=LOCAL;uid=;pwd=;"

    Set RsRead = New Recordset

    End Sub



    Private Sub cmdDis_Click()


    If Me.Bar().Count > 1 Then


            For I = 1 To Me.Bar().UBound


                Unload Bar(I)

                Unload lbl(I)

                Unload lblDat(I)

                Unload lblDir(I)




        End If




        SQL = "select Test,[result date],Result,firstname,sex,age from Results2 where test= '" & Me.MSHFlexGrid1.TextMatrix(Me.MSHFlexGrid1.Row, 1) & "' and patientID = '" & Me.txtPatientID & "' order by [result date] "

        RsRead.Open SQL, db, adOpenStatic, adLockOptimistic


        Dim X As Double

        X = 300


        If Not RsRead.EOF Then


            Me.txtField(1) = Me.txtPatientID & " # " & RsRead!firstname

            Me.txtField(2) = Me.MSHFlexGrid1 & " # " & range(RsRead!Test, RsRead!Age, RsRead!sex)



            For I = 1 To RsRead.RecordCount


                Load lbl(I)

                Load lblDat(I)

                Load lblDir(I)

                Load Me.Bar(I)

                Me.Bar(I).Left = X

                Me.Bar(I).Height = Cof * IIf(IsNumeric(RsRead!Result), RsRead!Result, 0)

                Me.Bar(I).Top = 4510 - Me.Bar(I).Height

                Me.lbl(I) = Format(IIf(IsNull(RsRead!Result), 0, RsRead!Result), "0.0")

                Me.lbl(I).Left = X - 100

                Me.lblDir(I) = Dir(RsRead!Result)

                Me.lblDir(I).Left = X

                Me.lblDat(I) = Format(RsRead![Result Date], "d/m/yy")

                Me.lblDat(I).Left = X - 100

                Me.lblDat(I).Top = Me.Bar(I).Top + Me.Bar(I).Height + 100

                Me.lbl(I).Top = Me.Bar(I).Top - 300

                Me.lblDir(I).Top = Me.Bar(I).Top - 600

                X = X + 650

                lbl(I).Visible = True

                lblDat(I).Visible = True

                lblDir(I).Visible = True

                Me.Bar(I).Visible = True





            Me.Picture1.Width = X + 200

            Me.HScroll1.Max = I

            Me.Shape1.Width = Me.Picture1.Width


        End If




    End Sub

    Hope this works for you.

  • 13 years ago

    Thanks Kassem.

    I am getting an idea now.  Let me go throuhg it.  It is a BIG help.

    Thx again.

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” - Brian Kernighan