sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
DaveD170@gmail.com's Avatar

Scale my excel chart


Question posted by: DaveD170@gmail.com (Guest) on August 19th, 2008 09:45 AM
Hi everybody,
I'm newbie in c# and I'm having trouble in creating an excel chart.
I have vector of data that my program calculated.
It's in the next format:
X Y
0.1 100
0.2 90
0.3 80
etc.

I assisted the article "How to automate Microsoft Excel from Microsoft
Visual C# .NET" and some other articles and was able to load this
values to the excel sheet. the X values inserted to A column and the Y
to B column.
My goal is to generate 2 different charts (xlXYScatterSmooth AND
xl3DColumn).

I have 2 problems -
1. The Scatter chart didn't work at all. I got exception on the
ChartWizard line.
the code was:
oRange = oSheet.get_Range("B2:B12", Missing.Value );
oChart.ChartWizard( oRange , Excel.XlChartType.xlXYScatterSmooth ,
Missing.Value,
Excel.XlRowCol.xlColumns, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value );


2. When I generated the xl3DColumn chart it worked fine BUT the scale
of the x axis was [0, 1] so I got graph with Y value = 100 and not
scaling at all.
I want my x axis will be [0.1 , 1]. How can I force the chart to use
the A column as it's scale?
The code is the same with one different - in the ChartWizard it's
xl3DColumn and not xlXYScatterSmooth .

Thank you very much
Dave
2 Answers Posted
Peter Duniho's Avatar
Guest - n/a Posts
#2: Re: Scale my excel chart

On Tue, 19 Aug 2008 01:41:31 -0700, <DaveD170@gmail.comwrote:
Quote:
Originally Posted by
Hi everybody,
I'm newbie in c# and I'm having trouble in creating an excel chart.


For what it's worth, your question isn't so much a C# question as it is an
Excel question (albeit automation). For best results and any serious hope
of a useful answer, you will be much better off finding a newsgroup
specific to Excel automation.

That said, with regards to your questions...
Quote:
Originally Posted by
[...]
1. The Scatter chart didn't work at all. I got exception on the
ChartWizard line.


What exception? You always need to post the exact information about the
exception. What's the type? What's the message?
Quote:
Originally Posted by
[...]
2. When I generated the xl3DColumn chart it worked fine BUT the scale
of the x axis was [0, 1] so I got graph with Y value = 100 and not
scaling at all.
I want my x axis will be [0.1 , 1]. How can I force the chart to use
the A column as it's scale?


I don't really know what you mean by "use the A column as it's [sic]
scale", but...you might consider setting the scale for the axes as desired
after creating the chart. Just set the appropriate properties as needed
on the axis object returned by the appropriate chart property (or method,
I can't recall now whether the axes are exposed as properties or not).

Pete
DaveD170@gmail.com's Avatar
DaveD170@gmail.com August 20th, 2008 06:05 AM
Guest - n/a Posts
#3: Re: Scale my excel chart

On Aug 19, 6:51*pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
Quote:
Originally Posted by
On Tue, 19 Aug 2008 01:41:31 -0700, <DaveD...@gmail.comwrote:
Quote:
Originally Posted by
Hi everybody,
I'm newbie in c# and I'm having trouble in creating an excel chart.

>
For what it's worth, your question isn't so much a C# question as it is an *
Excel question (albeit automation). *For best results and any serious hope *
of a useful answer, you will be much better off finding a newsgroup *
specific to Excel automation.
>
That said, with regards to your questions...
>
Quote:
Originally Posted by
[...]
1. The Scatter chart didn't work at all. I got exception on the
ChartWizard line.

>
What exception? *You always need to post the exact information about the *
exception. *What's the type? *What's the message?
>
Quote:
Originally Posted by
[...]
2. When I generated the xl3DColumn chart it worked fine BUT the scale
of the x axis was [0, 1] so I got graph with Y value = 100 and not
scaling at all.
I want my x axis will be [0.1 , 1]. How can I force the chart to use
the A column as it's scale?

>
I don't really know what you mean by "use the A column as it's [sic] *
scale", but...you might consider setting the scale for the axes as desired *
after creating the chart. *Just set the appropriate properties as needed *
on the axis object returned by the appropriate chart property (or method,*
I can't recall now whether the axes are exposed as properties or not).
>
Pete


Thank you Pete. I will post my question (with your good comments) in
the Excel group.
 
Not the answer you were looking for? Post your question . . .
196,998 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,998 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors