When building a ChartRenderer programmatically, ICalcRendererValues.GetFieldTotals is commonly used to set up 'Percent of Total' normalization. This method returns a variant (an array of field totals), but the return value is always empty.
This occurs due to defective logic in the CalcRendererValues implementation of ICalcRendererValues.
Avoid using ICalcRendererValues to calculate field totals. Instead, do one of the following:
- Manually calculate field totals using the ArcMap graphical user interface, and hard code these values into the code:
Dim pChtRend as IChartRenderer
Dim pCalcValues as ICalcRendererValues
Dim pField as IFields
Dim i as Integer
Dim Totals As Variant
Totals = pCalcValues.GetFieldTotals ' empty, not usable
' use hardcoded field totals instead
Dim dTotals(4) As Double
dTotals(0) = 7518518
dTotals(1) = 12094871
dTotals(2) = 26716211
dTotals(3) = 11447833
' FieldTotal used for normalization by percent of total
For i = 0 To pFields.FieldCount - 1
pChtRend.FieldTotal(i) = dTotals(i)
- Write your own logic to calculate field totals.