Solved

msGraph DataLabel Count

Posted on 2006-06-16
9
235 Views
Last Modified: 2010-04-05
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.SeriesCollection(1)) as Graph_TLB.Series);
    ThisDataLable := (IDispatch(ThisSeries.DataLabels(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?
0
Comment
Question by:svvada
  • 5
  • 4
9 Comments
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16920087
To loop through collection in Delphi, you will need to use IEnumVariant.
See http://www.swissdelphicenter.ch/torry/showcode.php?id=2135 on how to use IEnumVariant.
0
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16920155
The code will look like the following. (Not tested)

var
  SeriesCol : IEnumVariant ;
  Series : Olevariant;
begin
  SeriesCol := IUnknown(ThisChart.SeriesCollection._NewEnum) as IEnumVariant;
  while SeriesCol .Next(1, Series, value) = 0 do
  begin
     // here you will get the series object e.g.
  end;
end
0
 
LVL 1

Author Comment

by:svvada
ID: 16920309
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;

0
 
LVL 10

Accepted Solution

by:
atul_parmar earned 500 total points
ID: 16920696
Dude, paste the following code. it works! (Tested)

var
  SeriesCol : IEnumVariant;
  ChSeries, Series : Olevariant;
  MyChart : OleVariant;
  Value : longword;
begin
  MyChart := ThisChart;
  ChSeries := MyChart.SeriesCollection;
  SeriesCol := IUnknown(ChSeries._NewEnum) as IEnumVariant;
  while SeriesCol.Next(1, Series, value) = 0 do
  begin
    // Series (ISeries)
  end;
end;
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:svvada
ID: 16940125
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?
0
 
LVL 1

Author Comment

by:svvada
ID: 16940139
Never mind. Got that from a series where no datalabels were assigned.
0
 
LVL 1

Author Comment

by:svvada
ID: 16958646
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?
0
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16958772
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
0
 
LVL 1

Author Comment

by:svvada
ID: 16966657
That did the trick! Thanks again.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to fill array with TArray.Create? 14 79
Delphi cmd execution 6 56
Show Listview image from database (String field) 5 113
URL for downloading Google Chrome for Win XP 2 122
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now