1.新建一个BCG的对话框,添加一个文本框,并修改属性,添加成员变量,并设置Category为Control。
2.在class CCharPieDlg : public CBCGPDialog修改文本框成员为CBCGPChartCtrlm_wndChart;和添加BOOLm_bShowDataLabels;
3.在BOOL CCharPieDlg::OnInitDialog()添加如下代码
1 m_wndChart.EnableTooltip(); 2 CBCGPChartVisualObject* pChart = m_wndChart.GetChart(); 3 pChart->SetChartType(BCGPChartPie); 4 5 pChart->SetChartTitle(_T("ABCD")); 6 pChart->AddChartData(_T("A"), 2000); 7 pChart->AddChartData(_T("B"), 2000); 8 pChart->AddChartData(_T("C"), 2000); 9 pChart->AddChartData(_T("D"), 2000); 10 m_bShowDataLabels = TRUE; //定义是否展示数据Label 11 OnUpdateChart();
4.添加OnUpdateChart();
1 UpdateData(); 2 CBCGPChartVisualObject* pChart = m_wndChart.GetChart(); 3 pChart->ShowDataLabels(m_bShowDataLabels);//pie细节Label展示 4 pChart->Redraw();