Better explanation for Chart.ChartWizard

Hi All
I'm dying here. I am trying to create an excel chart programatically. I can easily create the chart using c# but the chart displays the category in the values axis and the values in the category axis. I have tried to find proper explanations of the Chart.ChartWizard method on MSDN but there are no examples and the parameter descriptions make no sense. I have attached a screen shot of the report I need to chart. The "PercentageThanSmoke" column is the categories (%) and the Count column is the series values.

Here is the code snippet I am using:

            // Create the chart
            ChartObjects charts = ( ChartObjects )worksheet.ChartObjects( Missing.Value );
            ChartObject chart = charts.Add( 0, ( int )( double )range.Height, 600, 400 );
            Range chartRange = worksheet.get_Range( "A3", string.Format( "B{0}", rows + 2 ) );
           
            chart.Chart.ChartWizard( chartRange, XlChartType.xl3DColumn, 1, XlRowCol.xlColumns, 0, 0, false, "Percentage That Smoke", "Category", "Values", "" );
            chart.Chart.HasLegend = false;
            chart.Chart.HasDataTable = false;
            chart.Chart.ApplyDataLabels( XlDataLabelsType.xlDataLabelsShowValue, false, false, false, false, false, false, false, false, Missing.Value );
            chart.Name = ParseColumnName( reportName );
            chart.Shadow = true;

I am sure it has something do do with the "PlotBy" paramater and the "CategoryLabels" and "SeriesLabels" parameters. I have tried to change the values but still nothing.

Any urgent help would be greatly appreciated.

Thanks
Sheet1.xls
mwskuzzyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rory ArchibaldCommented:
Hi,
Try using:
 

chart.Chart.ChartWizard( chartRange, XlChartType.xl3DColumn, 1, XlRowCol.xlColumns, 1, 0, false, "Percentage That Smoke", "Category", "Values", "" );

Open in new window

0
mwskuzzyAuthor Commented:
Hi rorya

I have tried that but still got the same results. I am currently playing around with the "Axis" object to see if i can manually set the category and series axis. I am sure however that specifying the XLRowCol as xlColumns should read the report this way. I also noticed that even if i specify the range as only including two columns (PercentageThatSmoke and Count) the chart still plots all three columns?
0
Rory ArchibaldCommented:
That's odd - it works from within Excel (I don't have C# here to test). To do it manually, you would use the chart's SeriesCollection collection (which contains Series objects) and set the XValues to the category label range.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.