Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing datalabels in OWC scatterplot

Status
Not open for further replies.

magnusharju

Programmer
Aug 27, 2012
1
NO
Hi!

I've been searching everywhere for a solution for this without any luck. so I am turning to the last resort, by posting it here and having the pros looking into it.

I am using Microsoft OWC 11.0, I have created a userform and added the graph object. Everything works great but managing the datalabels.

Here's the code im using to create the graph object:
Dim oChart As ChChart
Dim oSeries1 As ChSeries
ChartSpace1.Clear: ChartSpace1.Refresh
With ChartSpace1
.Clear
.Refresh
Set oChart = .Charts.Add

Set oSeries1 = oChart.SeriesCollection.Add
oSeries1.Type = chChartTypeScatterMarkers
oSeries1.SetData chDimXValues, chDataLiteral, Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
oSeries1.SetData chDimYValues, chDataLiteral, Array(10, 20, 30, 40, 50, 60, 70, 80, 90)

[highlight #EF2929]Possible solution 1[/highlight]
oSeries1.SetData ?[highlight #EF2929][/highlight], ChDataLabels, Array("A", "B", "C", "D", "E", "F", "G", "H", "I")

Set StrLabels = oSeries1.DataLabelsCollection.Add
For tInt = 0 To 9
StrLabels.Item(tInt).Font.Size = 6

[highlight #EF2929]Possible solution 2[/highlight]
StrLabels.Item(tInt).?[highlight #EF2929][/highlight] = "A" '"B", "C","D".....
Next tInt
End With

By adding the datalabels collection, I get the labels which is refering to the values I have assigned to series1. However, my problem is that I can't find a way to assign my own values to these datapoints. I have tried 2 possible solutions.

Solution 1, which also makes most sense to use, is using the chDataLabels reference in the SetData object. I have tried all the options given in the section hinglighted with the "?" and they all seems to be relating to other graph types. If this the way to accomplish the labelschange, then what should I use as the first argument?

Solution 2: The labels series can be changed easily by using the DataLabelsCollection, but this will only allow you to change the collection attributes such as font size, type and so on. I was hoping there would be somethinig equivalent to an .caption argument I could use for each Item in the datacollection but I can't find a way to get the DataLabelsCollection to accept new values.

I have searched MSDN all over, probably 99% of all web sites available not to mention spending all weekend trying to solve this. Any help and ideas are very much appreciated.

/Magnus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top