彩票走势图

工控图表控件ProEssentials使用教程:创建极坐标图表

原创|使用教程|编辑:郝浩|2013-04-07 14:44:20.000|阅读 936 次

概述:本文用工控图表控件ProEssentials介绍如何创建一个简单的极坐标图表。

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

相关链接:

极坐标图表是一种圆形极线图,上面的数据点使用角度和到中心点的距离来表示。 X轴位于圆圈的边界上,Y 轴连接圆心与 X 轴,图表上的每一个数据点对应一对X,Y值。下面我用工控图表控件ProEssentials介绍如何创建一个简单的极坐标图表。

极坐标图表:

极坐标图,Polar Chart,工控图表控件ProEssentials

ProEssentials创建极坐标图表源代码:

void CPEView::CreateSimplePolar()
{
   //! Right button click to show popup menu. //
   //! Double Click to show customization dialog. //
   //! Left-Click and drag to draw zoom box. Use popup memu or 'z' to undo zoom. // 

   // Simple example show the basics of a polar object. //
   // Polar Graph's contain both YData and XData. //

   RECT rect;
   GetClientRect( &rect );

   // Construct Object //
   m_hPE = PEcreate(PECONTROL_PGRAPH, WS_VISIBLE, &rect, m_hWnd, 1001);
	            
   PEnset(m_hPE, PEP_nSUBSETS, 2);
   PEnset(m_hPE, PEP_nPOINTS, 360);

   int p;
   float f1, f2;
   for (p=0; p<360; p++)
   {
       f1 = (float) p;
       f2 = (float) 150 * sin((double) p * 0.054F);
       PEvsetcellEx(m_hPE, PEP_faXDATA, 0, p, &f1);
       PEvsetcellEx(m_hPE, PEP_faYDATA, 0, p, &f2);
   }
       
   for (p=0; p<360; p++)
   {
       f1 = (float) p;
       f2 = (float) 150 * sin(((double) p * 0.044F)) * 2;
       PEvsetcellEx(m_hPE, PEP_faXDATA, 1, p, &f1);
       PEvsetcellEx(m_hPE, PEP_faYDATA, 1, p, &f2);
   }

   PEnset(m_hPE, PEP_nPLOTTINGMETHOD, PEGPM_LINE);
   PEnset(m_hPE, PEP_nALLOWZOOMING, 1);
   PEszset(m_hPE, PEP_szMAINTITLE, TEXT("Polar Chart"));
   PEszset(m_hPE, PEP_szSUBTITLE, TEXT("")); // no subtitle
   float ftmp = .9F;
   PEvset(m_hPE, PEP_fFONTSIZELEGENDCNTL, &ftmp, 1 );
   PEnset(m_hPE, PEP_bPREPAREIMAGES, TRUE);
   PEnset(m_hPE, PEP_bCACHEBMP, TRUE);
   PEnset(m_hPE, PEP_bFOCALRECT, FALSE);

   // Set line types
   int nTypes[] = { PELT_MEDIUMSOLID, PELT_MEDIUMSOLID };
   PEvset(m_hPE, PEP_naSUBSETLINETYPES, nTypes, 2);

   // Set point types
   int nPTypes[] = { PEPT_DOTSOLID, PEPT_PLUS };
   PEvset(m_hPE, PEP_naSUBSETPOINTTYPES, nTypes, 2);

   // subset colors
   DWORD dwArray[2] = { PERGB(128, 198,0,0), PERGB(128, 0, 198, 0) };
   PEvset( m_hPE, PEP_dwaSUBSETCOLORS, dwArray, 2);
		    
   // subset labels
   PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 0, TEXT("Signal #1" ));
   PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 1, TEXT("Signal #2" ));

   double dnull = -99999.0F;
   PEvset(m_hPE, PEP_fNULLDATAVALUEX, &dnull, 1);
   PEvset(m_hPE, PEP_fNULLDATAVALUE, &dnull, 1);

   // Set Various other features //
   PEnset(m_hPE, PEP_bFIXEDFONTS, TRUE);
   PEnset(m_hPE, PEP_bBITMAPGRADIENTMODE, TRUE);
   PEnset(m_hPE, PEP_nQUICKSTYLE, PEQS_MEDIUM_NO_BORDER);
   PEnset(m_hPE, PEP_bSIMPLEPOINTLEGEND, TRUE);
   PEnset(m_hPE, PEP_bSIMPLELINELEGEND, TRUE);
   PEnset(m_hPE, PEP_nLEGENDSTYLE, PELS_1_LINE);
   PEnset(m_hPE, PEP_nZOOMSTYLE, PEZS_RO2_NOT);
   PEnset(m_hPE, PEP_nPOINTSIZE, PEPS_SMALL);

   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_bLINESHADOWS, TRUE);
   PEnset(m_hPE, PEP_nFONTSIZE, PEFS_MEDIUM);
   PEnset(m_hPE, PEP_nGRADIENTBARS, 8);
   PEnset(m_hPE, PEP_nDATASHADOWS, PEDS_SHADOWS);
   float f = 1.2F;
   PEvset(m_hPE, PEP_fFONTSIZEGNCNTL, &f, 1);
   PEnset(m_hPE, PEP_nIMAGEADJUSTBOTTOM, 100);

   // 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