Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

msGraph DataLabel Count

Posted on 2006-06-16
9
Medium Priority
?
244 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Accepted Solution

by:
atul_parmar earned 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

730 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