setting graph series colours?

H

Howard

I have a pie chart in the group header section of a report that shows the
relative count of the words "good" and "bad" in a field called GoodBad
assosiated with a grouped person ID (it could get repeated in the table
with different values of GoodBad for each record)

This works fine with the default colours but I want the 'good' slice always
green and the 'bad' slice always red.

Playing with the 'format data point' bit of the design I set the colours of
data point 'bad' to red and datapoint 'good' to green.

All went OK until some reccords came up with 9 good's and 0 bad's then the
whole pie was coloured red instead of green

How can I fix the colours of the good and bad data display?

Howard
 
H

Howard

Finally found out myself how to do it so posting code here in case it helps
someone else.


Private Sub GroupHeader2_Format(Cancel As Integer, FormatCount As Integer)

Dim v As Variant

v = Me.chart1.SeriesCollection(1).Points.Item(1).DataLabel.Text
If UCase(Left(v, 1)) = "B" Then 'label starts with B - the bad slice, make
it red
Me.chart1.SeriesCollection(1).Points.Item(1).Interior.Color = RGB(255, 0,
0)
Else 'the good slice, make it green
Me.chart1.SeriesCollection(1).Points.Item(1).Interior.Color = RGB(0, 255,
0)
End If

End Sub

Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top