Solved

msGraph DataLabel Count

Posted on 2006-06-16
9
238 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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
 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

778 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