Page 2 of 2 FirstFirst 12
Results 41 to 43 of 43

Thread: Charts controls with GDI+

  1. #41
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    3,560

    Re: Charts controls with GDI+

    If you add image tags around the image links they will display inline. [ I M G ] and [ / I M G ] without the spaces, of course. You will need the full name from imgur ie. https://imgur.com/y0ehIkQ.gif


    Last edited by yereverluvinuncleber; Apr 4th, 2025 at 10:27 AM.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  2. #42
    New Member
    Join Date
    Apr 2025
    Posts
    3

    Re: Charts controls with GDI+

    Hello Yereverluvinuncleber ,
    Thanks for the guidance.

    I have a challenge with the ucChartBar. I need to display departments by their initials in X-axis and the employee count in the Y-axis for both the Males and Females using the bar chart. Allow me to attach both the code and the data to be analyzed by the graph here. The issue I have is that the code stops in the function GetMax() of the ucChartBar with error "Object is no longer valid". Can you assist me go past this error and display the graph.
    Below is the code

    Code:
    Private Sub DisplayGenderGraph()
    Dim VALUEX As Collection
    Dim VALUEY As Collection
    Dim CustomColors As Collection
    Dim i As Long, j As Long
    Dim Min As Single
    Dim Max As Single
    Dim Palette() As String
    Dim strDEPTINITIAL() As String
    
    
    'Display Employee Count by Gender per Department
    
        ucChartBar1.Clear
        'determine unique departments
        myString = "SELECT TOP (100) PERCENT DEPARTMENT AS DEPARTMENTQ, DEP_INITIAL " _
            & "FROM DEPARTMENT " _
            & "WHERE (DEPT_ACTIVE = 1) " _
            & "ORDER BY DEP_INITIAL"
        If rsTemp.State = adStateOpen Then rsTemp.Close
        rsTemp.Open myString, Maincn, adOpenKeyset, adLockOptimistic
        If rsTemp.RecordCount > 0 Then
            intX = rsTemp.RecordCount
            strX = "'"
            Set VALUEX = New Collection
            For i = 0 To intX - 1
                'VALUEX.Add rsTemp!DEP_INITIAL
                strX = strX & rsTemp!DEP_INITIAL & "','"
                If rsTemp.EOF = False Then rsTemp.MoveNext Else Exit For
            Next
            strX = Left(strX, Len(strX) - 2)
            strDEPTINITIAL = Split(strX, ",")
            For i = 0 To UBound(strDEPTINITIAL)
                VALUEX.Add strDEPTINITIAL(i)
            Next i
            ucChartBar1.AddAxisItems VALUEX, False, 0, 1
        End If
    
        Palette = Split("&H004744E3, &H003DB0EF, &H00ABA56C, &H0048BDBF, &H004D91F4, &H007450, &H0050C187, &HC0C0FF, &HFFFFC0, &H80FFFF, &HFF8D11, &HA744E0, &H376CE6, &H40AB1A, &H7B006B, &H400000, &H404080, &H80C0FF, &HC0C0C0, &HFF00FF, &HC0FFC0, &H8080FF, &H80&", ",")
    
        'Determine unique genders
        myString = "SELECT DISTINCT GENDER AS GENDERM FROM PERSONNEL_MASTER ORDER BY GENDER"
        If rs.State = adStateOpen Then rs.Close
        rs.Open myString, Maincn, adOpenKeyset, adLockOptimistic
        If rs.RecordCount > 0 Then
            For i = 1 To rs.RecordCount
                NameX = rs!GENDERM
                myString = "SELECT TOP (100) PERCENT DEPARTMENT, GENDER, EMPCOUNT, PERIOD, PYEAR, DEP_INITIAL " _
                    & "FROM EMPLOYEE_COUNT_GENDER_TEMP " _
                    & "WHERE (GENDER = '" & rs!GENDERM & "') " _
                    & "ORDER BY DEP_INITIAL"
                If rsTemp.State = adStateOpen Then rsTemp.Close
                rsTemp.Open myString, Maincn, adOpenKeyset, adLockOptimistic
    
                Set VALUEY = New Collection
                For j = 0 To intX - 1
                    VALUEY.Add rsTemp!EMPCOUNT
                    rsTemp.MoveNext
                Next
                ucChartBar1.AddSerie NameX, CLng(Palette(i)), VALUEY
                rs.MoveNext
            Next i
        End If
    End Sub

    Error generated can be seen here:


    Point where error occurs in the user control code:


    Data to be displayed in the ucChartBar


    I will really appreciate your support on this. I hope I have gotten it right now

    Regards,

    Nicholas.

  3. #43
    Addicted Member
    Join Date
    Aug 2023
    Posts
    201

    Re: Charts controls with GDI+

    Quote Originally Posted by NOkello2002 View Post
    Hello Yereverluvinuncleber ,
    Thanks for the guidance.

    I have a challenge with the ucChartBar. I need to display departments by their initials in X-axis and the employee count in the Y-axis for both the Males and Females using the bar chart. Allow me to attach both the code and the data to be analyzed by the graph here. The issue I have is that the code stops in the function GetMax() of the ucChartBar with error "Object is no longer valid". Can you assist me go past this error and display the graph.
    Below is the code

    Code:
    Private Sub DisplayGenderGraph()
    Dim VALUEX As Collection
    Dim VALUEY As Collection
    Dim CustomColors As Collection
    Dim i As Long, j As Long
    Dim Min As Single
    Dim Max As Single
    Dim Palette() As String
    Dim strDEPTINITIAL() As String
    
    
    'Display Employee Count by Gender per Department
    
        ucChartBar1.Clear
        'determine unique departments
        myString = "SELECT TOP (100) PERCENT DEPARTMENT AS DEPARTMENTQ, DEP_INITIAL " _
            & "FROM DEPARTMENT " _
            & "WHERE (DEPT_ACTIVE = 1) " _
            & "ORDER BY DEP_INITIAL"
        If rsTemp.State = adStateOpen Then rsTemp.Close
        rsTemp.Open myString, Maincn, adOpenKeyset, adLockOptimistic
        If rsTemp.RecordCount > 0 Then
            intX = rsTemp.RecordCount
            strX = "'"
            Set VALUEX = New Collection
            For i = 0 To intX - 1
                'VALUEX.Add rsTemp!DEP_INITIAL
                strX = strX & rsTemp!DEP_INITIAL & "','"
                If rsTemp.EOF = False Then rsTemp.MoveNext Else Exit For
            Next
            strX = Left(strX, Len(strX) - 2)
            strDEPTINITIAL = Split(strX, ",")
            For i = 0 To UBound(strDEPTINITIAL)
                VALUEX.Add strDEPTINITIAL(i)
            Next i
            ucChartBar1.AddAxisItems VALUEX, False, 0, 1
        End If
    
        Palette = Split("&H004744E3, &H003DB0EF, &H00ABA56C, &H0048BDBF, &H004D91F4, &H007450, &H0050C187, &HC0C0FF, &HFFFFC0, &H80FFFF, &HFF8D11, &HA744E0, &H376CE6, &H40AB1A, &H7B006B, &H400000, &H404080, &H80C0FF, &HC0C0C0, &HFF00FF, &HC0FFC0, &H8080FF, &H80&", ",")
    
        'Determine unique genders
        myString = "SELECT DISTINCT GENDER AS GENDERM FROM PERSONNEL_MASTER ORDER BY GENDER"
        If rs.State = adStateOpen Then rs.Close
        rs.Open myString, Maincn, adOpenKeyset, adLockOptimistic
        If rs.RecordCount > 0 Then
            For i = 1 To rs.RecordCount
                NameX = rs!GENDERM
                myString = "SELECT TOP (100) PERCENT DEPARTMENT, GENDER, EMPCOUNT, PERIOD, PYEAR, DEP_INITIAL " _
                    & "FROM EMPLOYEE_COUNT_GENDER_TEMP " _
                    & "WHERE (GENDER = '" & rs!GENDERM & "') " _
                    & "ORDER BY DEP_INITIAL"
                If rsTemp.State = adStateOpen Then rsTemp.Close
                rsTemp.Open myString, Maincn, adOpenKeyset, adLockOptimistic
    
                Set VALUEY = New Collection
                For j = 0 To intX - 1
                    VALUEY.Add rsTemp!EMPCOUNT
                    rsTemp.MoveNext
                Next
                ucChartBar1.AddSerie NameX, CLng(Palette(i)), VALUEY
                rs.MoveNext
            Next i
        End If
    End Sub

    Error generated can be seen here:


    Point where error occurs in the user control code:


    Data to be displayed in the ucChartBar


    I will really appreciate your support on this. I hope I have gotten it right now

    Regards,

    Nicholas.
    Hi

    I did some mods to the control since I also had problems with it but don't know if it would fix your problem. Please do a simpler example without using database (just adding some data manually) and I'll try to run you code with my modified control.

    Regards

Page 2 of 2 FirstFirst 12

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