Solved

msGraph DataLabel Count

Posted on 2006-06-16
9
234 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

12 Experts available now in Live!

Get 1:1 Help Now