哪里能找到图形化显示控件?
比如,以饼状,柱状来显示比例。
如能提供这样的控件,可以加分!!
问题点数:100、回复次数:7Top
1 楼csdnnewman(豆腐干)回复于 2003-06-02 10:56:01 得分 0
据说,用ms chart可以,但应该如何用呢?有没有在vc下用ms chart的相关的资料或代码?
多谢!Top
2 楼winplum(简迪)回复于 2003-06-02 11:24:57 得分 30
强烈推荐你使用Teechart,不过提前声明很庞大,不易掌握,但是几乎无所不能
详情见www.teechart.com官方网站。Top
3 楼csdnnewman(豆腐干)回复于 2003-06-02 16:12:20 得分 0
有没有其他的方法呢?Top
4 楼csdnnewman(豆腐干)回复于 2003-06-04 11:12:49 得分 0
没人知道吗?Top
5 楼Powerdix(大山)回复于 2003-06-04 16:35:32 得分 70
以下文章来自codpreject,由www.vccode.com的版主翻译,
www.vccode.com非常不错的vc网站.
---------------------------------------------------------------------------------
首先,在工程中加入图标控件,步骤:Project->Add Reference->Microsoft Chart Control
接下来,就是填充数据。当我使用Visual Basic时,我一般是通过数据源(data source)给图表传递数据,但是在VC++中,我没有找到数据源的方法。因此,我使用了COleSafeArray类为图表传递数据。
代码如下:
//First, create a safe array
COleSafeArray saRet;
SAFEARRAYBOUND sab[2];
sab[0].cElements = noOfRows; // give this exactly the number
// of rows you display in your
// chart
sab[1].cElements = 5; // number of columns + 1
// (because the first column is
// where we put the row labels -
// in 1.1, 2.1, 3.1, 4,1, etc.
sab[0].lLbound = sab[1].lLbound = 1;
// Use the chart as the backdrop of the legend.
m_ChartControl.SetShowLegend(TRUE);
// Create the safe array...
saRet.Create(VT_BSTR, 2, sab);
long index[2] = {0,0}; // a 2D graph needs a 2D array as
// an index array
BSTR bstr;
index[0]=1;
FILEDETAILS filedetailsstruct; // this is just a datastructure
// I used, pls see attached code
CString cstemp;
//m_filedetails is an STL list of filedetailsstruct
//-----------------------------------------------------
// in this loop, we populate the safe array
//-----------------------------------------------------
for(i=m_filedetails.begin();i!=m_filedetails.end();i++)
{
filedetailsstruct =(FILEDETAILS)*i;
index[1]=1;
bstr = filedetailsstruct.login.AllocSysString(); // Row label
// make sure this cannot be converted to a valid number like
// "54" and is a valid string like "John"
saRet.PutElement(index, bstr);
index[1]=2;
bstr = filedetailsstruct.n9000.AllocSysString();
// Data for column 1
::SysFreeString(bstr);
saRet.PutElement(index, bstr);
index[1]=3;
bstr = filedetailsstruct.n9002.AllocSysString();
// Data for column 2
::SysFreeString(bstr);
saRet.PutElement(index, bstr);
index[1]=4;
bstr = filedetailsstruct.n9004.AllocSysString();
// Data for column 3
::SysFreeString(bstr);
saRet.PutElement(index, bstr);
index[1]=5;
bstr = filedetailsstruct.nCancel.AllocSysString();
// Data for column 4
::SysFreeString(bstr);
saRet.PutElement(index, bstr);
index[0]++;
}
// now hand over the safe array to the chart control
m_ChartControl.SetChartData(saRet.Detach());
我们的图表数据形式如下:
............................
2,1 2,2 2,3 2,4 2,5
1,1 1,2 1,3 1,4 1,5
这里
1,1 -Row label 1
2,1 -Row Label 2
现在为每一列加入标签:
m_ChartControl.SetColumnLabelCount(4);
m_ChartControl.SetColumn(1);
m_ChartControl.SetColumnLabel("Monday") ;
m_ChartControl.SetColumn(2);
m_ChartControl.SetColumnLabel("Wednesday") ;
m_ChartControl.SetColumn(3);
m_ChartControl.SetColumnLabel("Friday") ;
m_ChartControl.SetColumn(4);
m_ChartControl.SetColumnLabel("Saturday") ;
就是这些。Top
6 楼csdnnewman(豆腐干)回复于 2003-06-05 20:32:50 得分 0
谢谢大山Top
7 楼csdnnewman(豆腐干)回复于 2003-06-09 19:21:59 得分 0
有没有ms chart相关的资料呢?Top




