I'm using a microsoft graph object to display a pie chart on a form to represent the proportion of red amber and green and black indicators in a table. The red slice needs to be coloured red, the green slice needs to be green etc... The problem is getting the slices to appear as the right colours. Either they come up as different colours when the form is loaded on different occaisions, or the displayed colours have no bearing to the RGB colour value that is being specified. The code snippet below, which is run on the current event (have tried load activate etc) shows the technique I'm trying to use, basically display the data labels, identify the text of the label, apply the corresponding colour and then hide the labels again... sounds easy doesn't it ?
The technique I'm trying at the moment is to define the colour palette and then use the colorindex property to specify the required colour. However this doesn't work at all.
My Previous attempt used the .Interior.Color property of the point object and this just about worked when I was using raw RGB colours e.g. RGB(255,0,0) for red etc, however even this didn't always work i.e. when the routine was first run the colours where wrong and it had to be run twice for the colours to be corrected. In any case these colours are too intense, so I defined my own colours
Public Const kpiRed = 8947967
Public Const kpiGreen = 10678678
Public Const kpiAmber = 7972351
However when these were applied to the .Interior.Color the results were complete rubbish, so I'm wondering if there is a better way ...
Dim x As Long
Dim p As Graph.Point
Me.Graph3.Object.Colors(1) = kpiRed
Me.Graph3.Object.Colors(2) = kpiGreen
Me.Graph3.Object.Colors(3) = kpiAmber
Me.Graph3.Object.Colors(4) = 0
For x = 1 To Me.Graph3.SeriesCollection.Count
For Each p In Me.Graph3.SeriesCollection(x).Points
Select Case p.DataLabel.Text
'p.Interior.Color = kpiRed
'p.Interior.Color = 255
p.Interior.ColorIndex = 1
p.Interior.ColorIndex = 3
p.Interior.ColorIndex = 2
p.Interior.ColorIndex = 4
p.HasDataLabel = False