Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 7
Default Create a new chart in C#

I would like to create a new chart in c#, with each series coming from
a different range.

I have an array of Excel.Range - ranges...

Here's what I have so far:

Excel.Range range = ranges[0];

Excel.Worksheet ws = (Excel.Worksheet)range.Worksheet;
Excel.ChartObjects charts =
(Excel.ChartObjects)ws.ChartObjects(Type.Missing);
Excel.Chart c =
((Excel.ChartObject)charts.Add((double)range.Left, (double)range.Top,
500, 300)).Chart;

chart = c;

Excel.SeriesCollection sc =
(Excel.SeriesCollection)chart.SeriesCollection(Typ e.Missing);

foreach (Excel.Range r in ranges)
{
Excel.Series series = sc.NewSeries();
series.Values = r;
}


It works - sort of. The chart is created but is invisible. It is
still possible to interact with it though, as control points for series
elements and the draggable handle for the chart itself is present - it
is just invisible!

If I drag it to a new location then it becomes visible.


Where could I be going wrong?


I've tried sc.Add(r,Excel.XlRows, Type.Missing, Type.Missing,
Type.Missing) but got an oleaut 'type mismatch'.

Any help would be greatly appreciated.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a link between columns from a data chart? Sara Excel Discussion (Misc queries) 1 June 2nd 06 06:51 PM
How to create a chart based on a 2 dim data range dynamical in 1 d Beertje Charts and Charting in Excel 1 October 25th 05 11:54 AM
Macro to Create a Chart and Update it Automatically maperalia Charts and Charting in Excel 2 October 21st 05 05:42 PM
How to create combination stacked area and line chart? BarbAug Charts and Charting in Excel 2 May 19th 05 01:18 PM
Urgent Chart Assistance Requested Brent E Excel Discussion (Misc queries) 0 May 9th 05 11:01 PM


All times are GMT +1. The time now is 10:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"