MSChart sample

I am trying to use the MSChart control in my VC project. It is difficult for me to start as there are no sample source code in the help file. May I know anyone out there can give me a sample of how to plot a line graph with two series of data? For example, I have income and expense for a company for years 1997, 1998, 1999. I would like to have two lines on the graph, one showing the income and the other line show the expense.
Thank you very much for your help in advance. :) Cheers!
tszwangAsked:
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.

ToronadoCommented:
Hi tszwang,

Do you have problems inserting the MSChart control in your project, or with using the control?

Regards,
 Toronado
0
tszwangAuthor Commented:
I have problem using it. Can you help me? :)
0
tszwangAuthor Commented:
Adjusted points to 200
0
V_BapatCommented:
Hi
Assuming that you have already added MS Chart control in your dialog/formview, you have to do this:

First you have to select the row and column in which you have to set the data. Here is an example:

for(short i = 1; i <= m_chart.GetRowCount(); i++)
{
     for(short j = 1; j <= m_chart.GetColumnCount(); j++)
     {
          m_chart.SetRow(i);
          m_chart.SetColumn(j);
          strValue.Format("%d", j * 5);
         
          m_chart.SetData(strValue);
     }
}

Here, m_chart is the member variable for the chart control.

Hope this helps. If you have further questions, feel free to ask.

Vicky
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
V_BapatCommented:
Hi
Suppose you have added the chart control to CFormView. In OnInitialUpdate() add the following:

m_chart.SetColumnCount(3);  // No of columns
m_chart.SetRowCount(2);     // No of rows

This will give you a chart with 3 columns and 2 rows. To set data first select row and column and then set data. For example,

m_chart.SetColumn(1);
m_chart.SetRow(1);
m_chart.SetData("20");  // R1C1 = 20

m_chart.SetColumn(2);
m_chart.SetRow(2);
m_chart.SetData("40");  // R2C2 = 40

m_chart.SetColumn(3);
m_chart.SetRow(1);
m_chart.SetData("60");  // R1C3 = 60
0
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
System Programming

From novice to tech pro — start learning today.