Pie Chart Colors

Jodi

New member
Local time
Today, 04:24
Joined
May 3, 2012
Messages
1
I need to find out how in Access 2003, I can chose particular colors for each of the sectors on my pie chart. Currently, it picks a couple at random everytime the chart is created and uses the same ones 2 times within the same pie.
 

Attachments

Here is some code I used in a bar chart to change colors of each series. You may be able to apply this to your pie chart.

Code:
Public Sub ChartColors(ch As Chart)
Dim iPt As Integer
Dim ser As Series
Dim i As Integer
iPt = 1
  For i = 1 To ch.SeriesCollection.Count
    With ch.SeriesCollection(i)
        For iPt = 1 To ch.SeriesCollection(i).Points.Count
            Select Case GetColorCode(iPt)
                Case "R"
                .Points(iPt).Interior.Color = RGB(255, 0, 0)
                Case "Y"
                .Points(iPt).Interior.Color = RGB(255, 255, 0)
                Case "T"
                .Points(iPt).Interior.Color = RGB(226, 206, 180)
                Case "CDL"
                .Points(iPt).Interior.Color = RGB(128, 0, 128)
                Case "O"
                .Points(iPt).Interior.Color = RGB(255, 165, 0)
                Case "S"
                    .Points(iPt).Interior.Color = RGB(192, 192, 192)
            End Select
        Next iPt
    End With
    Next i
End Sub
 
'I use this to pass my chart object to the above routine
ChartColors [YourGraphName].Object.Application.Chart

In my ChartColors routine my series are based on a production line that corresponds to a color - R=Red, O=Orange, S=Silver, etc..You don't need the GetColorCode routine but you can use your own evaluation statement to determine which colors you want each pie section to be. NOTE: You need to look up the RGB color for the color codes you want: I'm not able to post links yet but you can go to google and search for RGB Color Chart: You can also use this - tayloredmkt.com/rgb/. - just add the rest of the URL.

Let me know how this works for you!
 

Users who are viewing this thread

Back
Top Bottom