首页 > 代码库 > CBCGPChartCtrl

CBCGPChartCtrl

一,新建一个BCG工程CBCGPChartCtrlSingle,基于对话框。

二,在主对话框上增加一个文本框。不要用默认ID,并关联一个CStatic类型变量。手动将类型改成CBCGPCharCtrtl

CBCGPChartCtrl m_chart;

三,CCBCGPChartCtrlSingleDlg::OnInitDialog对m_chart进行初始化。

CBCGPChartVisualObject* pChart = m_chart.GetChart();

pChart->SetChartType(BCGPChartColumn3D, BCGP_CT_STACKED);

pChart->SetChartTitle(_T("阶层"));

CBCGPChartBarSeries* pBarSeries1 = DYNAMIC_DOWNCAST(CBCGPChartBarSeries, pChart->CreateSeries(_T("")));

CBCGPChartBarSeries* pBarSeries2 = DYNAMIC_DOWNCAST(CBCGPChartBarSeries, pChart->CreateSeries(_T("")));

CBCGPChartBarSeries* pBarSeries3 = DYNAMIC_DOWNCAST(CBCGPChartBarSeries, pChart->CreateSeries(_T("")));

CBCGPChartBarSeries* pBarSeries4 = DYNAMIC_DOWNCAST(CBCGPChartBarSeries, pChart->CreateSeries(_T("")));

pBarSeries1->AddDataPoint("价值",40);

pBarSeries1->AddDataPoint("人口",1);

pBarSeries2->AddDataPoint(30);

pBarSeries2->AddDataPoint(80);

pBarSeries3->AddDataPoint(20);

pBarSeries3->AddDataPoint(7);

pBarSeries4->AddDataPoint(10);

pBarSeries4->AddDataPoint(13);

四,Ctrl+F5运行,效果如图。

源码下载:

http://pan.baidu.com/s/1i3zKm01
http://download.csdn.net/detail/he_zhidan/7817771
http://www.pudn.com/downloads645/sourcecode/windows/dialog/detail2609645.html

CBCGPChartCtrl