svvada
asked on
msGraph DataLabel Count
I'm using the 'Microsoft Graph 11.0 Object Library' (Type Lib) to add a chart to a PowerPoint presentation. I've loaded the data into the graph so now I'm looking at formatting the presentation. I would like to change the font on the datalabels and I've figured out how to do this:
ThisSeries := (IDispatch(ThisChart.Serie sCollectio n(1)) as Graph_TLB.Series);
ThisDataLable := (IDispatch(ThisSeries.Data Labels(1)) As DataLabel);
ThisDataLable.Font.Size := 8;
but I've not found a way to get the count from the SeriesCollection or the DataLables so I don't know how many series or how many datalables per series there is. So if there's a way to get this information it would be of great help. Boot the SeriesCollection interface and the DataLables interface has a count property. But I can't seem to get a hold of any of them?
ThisSeries := (IDispatch(ThisChart.Serie
ThisDataLable := (IDispatch(ThisSeries.Data
ThisDataLable.Font.Size := 8;
but I've not found a way to get the count from the SeriesCollection or the DataLables so I don't know how many series or how many datalables per series there is. So if there's a way to get this information it would be of great help. Boot the SeriesCollection interface and the DataLables interface has a count property. But I can't seem to get a hold of any of them?
The code will look like the following. (Not tested)
var
SeriesCol : IEnumVariant ;
Series : Olevariant;
begin
SeriesCol := IUnknown(ThisChart.SeriesC ollection. _NewEnum) as IEnumVariant;
while SeriesCol .Next(1, Series, value) = 0 do
begin
// here you will get the series object e.g.
end;
end
var
SeriesCol : IEnumVariant ;
Series : Olevariant;
begin
SeriesCol := IUnknown(ThisChart.SeriesC
while SeriesCol .Next(1, Series, value) = 0 do
begin
// here you will get the series object e.g.
end;
end
ASKER
The thing is that I can't get hold of the collection? The Chart interface has a function SeriesCollection that takes an index as parameter.
function SeriesCollection(Index: OleVariant): IDispatch; dispid 68;
function SeriesCollection(Index: OleVariant): IDispatch; dispid 68;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Looks good for the series!
But then I need to get to the datalabels. I tried the same thing as for the series, but got a message telling me that it could not access _NewEnum?
But then I need to get to the datalabels. I tried the same thing as for the series, but got a message telling me that it could not access _NewEnum?
ASKER
Never mind. Got that from a series where no datalabels were assigned.
ASKER
atul_parmar, thanks for the help earlier, a quick followup question.
When I have this part in the code:
while SeriesCol.Next(1, Series, value) = 0 do
begin
// Series (ISeries)
end;
the Graph.exe process is not stopped when I free the PowerPoint objects? If I remove the while loop it works fine. Got any ideas as to why?
When I have this part in the code:
while SeriesCol.Next(1, Series, value) = 0 do
begin
// Series (ISeries)
end;
the Graph.exe process is not stopped when I free the PowerPoint objects? If I remove the while loop it works fine. Got any ideas as to why?
It might be because of the olevariant variables (MyChart, Series, ...etc) are still refering to the objects of chart. free them all. e.g.
MyChart := unassigned; // plz. do it for all the used variables
MyChart := unassigned; // plz. do it for all the used variables
ASKER
That did the trick! Thanks again.
See http://www.swissdelphicenter.ch/torry/showcode.php?id=2135 on how to use IEnumVariant.