彩票走势图

工控图表控件ProEssentials使用教程:创建简单饼图

原创|使用教程|编辑:郝浩|2013-04-03 11:27:26.000|阅读 1059 次

概述:本文展示如何用工控图表控件ProEssentials 创建简单的饼图图形。ProEssentials v7的饼图又新添加了一些新功能。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

饼图通常以百分比的形式显示信息,比如产品销售额、产品产量等。下面为大家展示如何用工控图表控件ProEssentials 创建一个简单的饼图图形。

这个饼图展示了美国不同州的几种水果产量情况。ProEssentials v7又在之前的版本上做了一些改进,在图表上滚动鼠标可以分别查看几种水果的产量图表。双击饼图上的标签,还可以将饼图对应的那一块分离出来。这个饼图还将那些太小的分片集合分类成*Other,这样可以提高图表数据的可读性。这里只展示了一张图片,要体验这些功能,请下载ProEssentials v7

ProEssentials v7,工控图表控件,饼图

下面是ProEssentials v7创建简单饼图的源代码:

void CPEView::CreateSimplePie()
{

   RECT rect;
   GetClientRect( &rect );

   // Construct Object //
   m_hPE = PEcreate(PECONTROL_PIE, WS_VISIBLE, &rect, m_hWnd, 1001);
   PEnset(m_hPE, PEP_nSUBSETS, 5);
   PEnset(m_hPE, PEP_nPOINTS, 12);
   int s,p;          
   for (s=0; s<5; s++)
   {
       for (p=0; p<12; p++)
       {
           float f1 = (float) GetRandom(1, 5) + ((float) GetRandom(1, 100) / 100.0F);
           PEvsetcellEx(m_hPE, PEP_faXDATA, s, p, &f1);
       }
   }
   float f1= 0.0F;
   PEvsetcellEx(m_hPE, PEP_faXDATA, 0, 3, &f1);


   // Set Subset labels //
   PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 0, TEXT("Apples" ));
   PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 1, TEXT("Oranges" ));
   PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 2, TEXT("Pears"  ));
   PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 3, TEXT("Plums" ));
   PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 4, TEXT("Peaches" ));

   // Set Slice Labels //
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 0, TEXT("Texas"      ));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 1, TEXT("Oklahoma"   ));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 2, TEXT("Kansas"));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 3, TEXT("New Mexico" ));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 4, TEXT("Colorado"   ));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 5, TEXT("Wyoming"    ));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 6, TEXT("Utah"       ));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 7, TEXT("Arizona"   ));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 8, TEXT("Nebraska"    ));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 9, TEXT("South Dakota"       ));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 10, TEXT("North Dakota"   ));
   PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 11, TEXT("Iowa"    ));

   // Set Slice Colors //
   DWORD c[13];
   c[0] = PERGB( 255, 198, 0, 0);
   c[1] = PERGB( 255, 0, 198, 0);
   c[2] = PERGB( 255, 198, 198, 0);
   c[3] = PERGB( 255, 0, 0, 198);
   c[4] = PERGB( 255, 198, 0, 198);
   c[5] = PERGB( 255, 0, 198, 198);
   c[6] = PERGB( 255, 192, 192, 192);
   c[7] = PERGB( 255, 148, 0, 0);
   c[8] = PERGB( 255, 0, 148, 0);
   c[9] = PERGB( 255, 148, 148, 0);
   c[10] = PERGB( 255,0, 168, 168);
   c[11] = PERGB( 255, 132, 132, 132);
   c[12] = PERGB( 255, 0, 0, 0);
   PEvset(m_hPE, PEP_dwaSUBSETCOLORS, c, 13);

   // Set Main Title
   PEszset(m_hPE, PEP_szMAINTITLE, TEXT("Produce by State"));
   PEszset(m_hPE, PEP_szSUBTITLE, TEXT("")); // no subtitle

   // Set various other properties //
   PEnset(m_hPE, PEP_nDATAPRECISION, 1);				   
   PEnset(m_hPE, PEP_nGROUPINGPERCENT, 4);
   PEnset(m_hPE, PEP_nDATASHADOWS, PEDS_3D);					 
   PEnset(m_hPE, PEP_bDISABLE3DSHADOW, FALSE);
   PEnset(m_hPE, PEP_nAUTOEXPLODE, PEAE_ALLSUBSETS);
   PEnset(m_hPE, PEP_bFOCALRECT, FALSE);
   PEnset(m_hPE, PEP_bPREPAREIMAGES, TRUE);
   PEnset(m_hPE, PEP_bCACHEBMP, TRUE);
   PEnset(m_hPE, PEP_nFONTSIZE, PEFS_MEDIUM);
   PEnset(m_hPE, PEP_bFIXEDFONTS, TRUE);

   PEnset(m_hPE, PEP_bBITMAPGRADIENTMODE, TRUE);
   PEnset(m_hPE, PEP_nQUICKSTYLE, PEQS_LIGHT_NO_BORDER);

   PEnset(m_hPE, PEP_nTEXTSHADOWS, PETS_BOLD_TEXT);
   PEnset(m_hPE, PEP_bMAINTITLEBOLD, TRUE);
   PEnset(m_hPE, PEP_bSUBTITLEBOLD, TRUE);
   PEnset(m_hPE, PEP_bLABELBOLD, TRUE);
   PEnset(m_hPE, PEP_nFONTSIZE, PEFS_LARGE);

   // Improves metafile export //
   PEnset(m_hPE, PEP_nDPIX, 600);
   PEnset(m_hPE, PEP_nDPIY, 600);

   // Set Demo's RenderEngine to Gdi Plus // 
   CMDIFrameWnd* pWnd = (CMDIFrameWnd*) AfxGetApp()->GetMainWnd();
   pWnd->SendMessage(WM_CHANGE_METAFILE, PEPLAYMETAFILEGDIPLUS );

}

//***************************************************************************

标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:慧都控件

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP