chDataBound vs. chDataLiteral - Combination Chart

H

hrfrank

I am trying to create a combination chart plotting a
target line against a bar chart with the monthly totals.
I have no problem with the bar chart or plotting a line.
My problem is trying to plot a line that is bound to the
values in the pivot table by adding a new series. I am
using OfficeXP(OWC10). My understanding from another post
is that chDataBound has been retired in OWC and you have
to read the values into an array and pass them to
chDataLiteral in order to make this work. I got it to
work for the row values, but I cannot seem to locate the
correct syntax to make it work for the data value. Can
someone help fix the commented code below. The
pvtDataFldlst variable is incorrect and I cannot figure it
out.

'**************************************
'*** COMBINATION CHART ***
'**************************************
'==================================================
'create arrays to pass values to create 2nd chart
series
'==================================================
Dim RowArray, DataArray
Dim sElementsList, sElementsList2
Dim pvtView
Dim pvtFldlst, pvtDataFldlst
Dim pvtFld, pvtDataFld
Dim pvtMbr, pvtDataMbr

Set pvtView = pTable.ActiveView
Set pvtRowFldlst = pvtView.RowAxis.FieldSets(0)
Set pvtRowFld = pvtRowFldlst.Fields(0)
RowElementsList = ""
DataElementsList = ""
' Set pvtDataFldlst =
pvtView.Totals.PivotTableAxis.PivotTotals(0)
' Set pvtDataFldlst =
pTable.PivotData.PivotResultDataAxis.PivotDataAxis.FieldSet
s(0)
' Set pvtDataFld = pvtDataFldlst.Fields(0)

'=========
'Row axis
'=========
For Each pvtMbr In pvtRowFld.FieldSet.Members
RowElementsList = RowElementsList & CStr
(pvtMbr.Value) & ";"
Next
RowElementsList = Left(RowElementsList, Len
(RowElementsList) - 1)
RowArray = Split(RowElementsList, ";")

'===========
'Data Axis
'===========
' For Each pvtDataMbr In pvtDataFld.FieldSet.Members
' DataElementsList = DataElementsList & CStr
(pvtDataMbr.Value) & ";"
' Next
' DataElementsList = Left(DataElementsList, Len
(DataElementsList) - 1)
' DataArray = Split(DataElementsList, ";")

'=====================================
'Add a second series of type Line.
'=====================================
Set oConst = ch.Constants

Set oSeries2 = ch.Charts(0).SeriesCollection.Add
With oSeries2
.SetData oConst.chDimCategories,
oConst.chDataLiteral, RowArray
.SetData oConst.chDimValues, oConst.chDataLiteral,
DataArray
.Type = oConst.chChartTypeLine
.Caption = "chDataBound - oSeries2"
.Marker.Style = chMarkerStyleStar
'Marker Style
.Interior.Color = "RED"
'Marker Interior Color
.Border.Color = "BLUE"
'Marker Border Color
.Marker.Size = 6
'Marker Size
.Line.Weight = 1
'Line Weight
.Line.Color = "BLUE"
'Line Color
End With
 

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