Click to See Complete Forum and Search --> : how to use MS chart control


Goang-Sik Lee
May 31st, 1999, 09:19 AM
hi.
i want use to mschart control
so i insert chart control for my application.
next step i do not know what i do
please send me sample code
thanks
email : gslee@safety.hoseo.ac.kr

Masaaki
May 31st, 1999, 10:48 AM
Hi.

This is a crucial top on GUI application, but codeguru never answer
this question. I can't find any clue on search or Last updates.

So, now I'm working this top on my project for the future enhancement.
1) Explorer the property page of chart control.
2) Subclass the chart control like m_chart by class wizard.

I set three rows,rowindex and VtChChartType2dBar as chart type at property page of the chart control.
m_chart.SetShowLegend(TRUE);
short Colnum = m_chart.GetColumn();
TRACE1("Col Num is %d", Colnum);
// short RowNum = m_chart.GetRow();
// TRACE1("Col Num is %d", RowNum);
m_chart.SetRow(1);//put SetRow() at first.
m_chart.SetData("56");//the chart value as string
m_chart.SetRowLabel("Row 2");

m_chart.SetRow(2);
m_chart.SetData("80");
m_chart.SetRowLabel("Row 1");

m_chart.SetRow(3);
m_chart.SetData("100");

I just starts this and show you the simple one. So, try to do more
complicated approach.
In fact, I was surprised that there are many classes when I insert
the chart control to my project.

HTH.
-Masaaki Onishi-

Goang-Sik Lee
May 31st, 1999, 02:20 PM
THANK YOU !
i remember that chart type is about 13
by the way i have to use the outer surface chart because my data number is 400000
Do you know chart number of outer suface shown on top?
EXCEL have it.
but this conponent may not be have it.
i have another question.
my data is array (ex : int a[200][200])
how this data display?
thank you very much..
you! number one..
take care..
email : gslee@safety.hoseo.ac.kr

Masaaki
May 31st, 1999, 05:50 PM
Hi.

Because I just starts MSChart ActvieX control, my suggestion is just
one which I posted. However, I think that MSChart supports array
object as Visaul Basic can do.
I explored MSChart at MSDN help, but I found only VB reference.
But VB reference will help us partly because VB made by VC++?

void SetChartData(const VARIANT& newValue);
I guess that this function will deal with your desire, but i'm not yet sure how we will use this function.

HTH.
-Masaaki Onishi-

Masaaki
June 1st, 1999, 01:17 AM
Hi.

At last, I figured out how to use SetChartData().
COleSafeArray is key point here.

/* //This is one dimension array.

int data[5] = {56, 80, 100, 49, 31};
COleSafeArray varArray;
varArray.CreateOneDim(VT_I4, 5, &data , 0);

*/ //This is two dimension array.
int data[2][3] = { {56, 80, 100}, {50,60,40}};

COleSafeArray varArray;

long index[2];
DWORD numElements[]={2,3};
varArray.Create(VT_I4, 2, numElements);
VARIANT v;
VariantInit(&v);
v.vt = VT_I4;

for(int i = 0; i < 2;i++)
for(int j = 0; j < 3; j++)
{
index[0] = i;
index[1] = j;
v.intVal = data[i][j];
varArray.PutElement(index, &v.intVal);
}

m_chart.SetChartData(varArray);

This time, we don't need caring about the propery of Chart control.
I am so sleepy now. 2 AM at Atlanta local time.

HTH.
-Masaaki Onishi-