彩票走势图

工控图表控件ProEssentials使用教程:创建Scientific Graph Control

原创|使用教程|编辑:郝浩|2013-04-10 15:28:10.000|阅读 1200 次

概述:本文为大家展示用工控图表控件ProEssentials创建的一个比较简单的Scientific Graph Control(科学图表控件)。

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

相关链接:

Scientific Graph Control类似于Graph控件,但它是以水平和垂直的双坐标轴来展示信息的。这个组件通常用于表现技术类型的信息,比如电子部件当前的电压与电流的关系。下面为大家展示用工控图表控件ProEssentials创建的一个比较简单的Scientific Graph Control,如下图:

Scientific Graph Control,ProEssentials

Scientific Graph能处理各种格式化的date/time值,ProEssentials date/time能处理世纪到秒的时间。

下面是ProEssentials创建Scientific Graph Control的源代码:

void CPEView::CreateSimpleSGraph()
{
   //! 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 scientific graph object. //
   // Scientific Graph's contain both YData and XData and thus data
   // is not plotted equally spaced as the graph object does.

   RECT rect;
   GetClientRect( &rect );
   m_hPE = PEcreate(PECONTROL_SGRAPH, WS_VISIBLE, &rect, m_hWnd, 1001);
   if( m_hPE )
   {
       float fY;
       float fX;

       // Enable middle mouse dragging //
       PEnset(m_hPE, PEP_bMOUSEDRAGGINGX, TRUE);
       PEnset(m_hPE, PEP_bMOUSEDRAGGINGY, TRUE);

       // Enable Bar Glass Effect //
       PEnset(m_hPE, PEP_bBARGLASSEFFECT, TRUE);

       // Enable Plotting style gradient and bevel features //
       PEnset(m_hPE, PEP_nAREAGRADIENTSTYLE,  PEPGS_RADIAL_BOTTOM_RIGHT);
       PEnset(m_hPE, PEP_nAREABEVELSTYLE, PEBS_MEDIUM_SMOOTH);
       PEnset(m_hPE, PEP_nSPLINEGRADIENTSTYLE,  PEPGS_RADIAL_BOTTOM_RIGHT);
       PEnset(m_hPE, PEP_nSPLINEBEVELSTYLE, PESBS_MEDIUM_SMOOTH);

       // Set number of Subsets and Points //
       PEnset(m_hPE, PEP_nSUBSETS, 4);	
       PEnset(m_hPE, PEP_nPOINTS, 12);	

       for( int s=0; s<=3; s++ )
       {
           for( int p=0; p<=11; p++ )
           {										  
               fX = ((float) (p+1)) * 100.0F + ((float) GetRandom(2, 250)) / 50.0F;
               PEvsetcellEx (m_hPE, PEP_faXDATA, s, p, &fX);
               fY = ((float) (p+1) * 1.0F) + GetRandom(1, 250) + 700.0F - ((float) (s * 140.0F)) + ((float) GetRandom(2, 250)) / 250.0F;
               PEvsetcellEx (m_hPE, PEP_faYDATA, s, p, &fY);
           }
       }

       // Set DataShadows to show shadows
       PEnset(m_hPE, PEP_nDATASHADOWS, PEDS_SHADOWS);

       PEszset(m_hPE, PEP_szMAINTITLE, TEXT("Example Data"));
       PEszset(m_hPE, PEP_szSUBTITLE, TEXT("")); // no subtitle
       PEszset(m_hPE, PEP_szYAXISLABEL, TEXT("Units Sold"));
       PEszset(m_hPE, PEP_szXAXISLABEL, TEXT("Month"));
       PEnset(m_hPE, PEP_bFOCALRECT, FALSE);
       PEnset(m_hPE, PEP_bPREPAREIMAGES, TRUE);
       PEnset(m_hPE, PEP_bCACHEBMP, TRUE);
       PEnset(m_hPE, PEP_nPLOTTINGMETHOD, PEGPM_SPLINE);
       PEnset(m_hPE, PEP_nGRIDLINECONTROL, PEGLC_BOTH);
       PEnset(m_hPE, PEP_nGRIDSTYLE, PEGS_DOT);
       PEnset(m_hPE, PEP_nALLOWZOOMING, PEAZ_HORZANDVERT);
       PEnset(m_hPE, PEP_nZOOMSTYLE, PEZS_RO2_NOT);

       // subset labels
       PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 0, TEXT("Texas"));
       PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 1, TEXT("Florida" ));
       PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 2, TEXT("Washington" ));
       PEvsetcell( m_hPE, PEP_szaSUBSETLABELS, 3, TEXT("California" ));

       // subset colors
       DWORD dwArray[4] = { PERGB(128,198,0,0), PERGB(128, 0, 198, 198 ), PERGB(128, 198,198,0 ), PERGB(128, 0,198,0 ) };
       PEvsetEx( m_hPE, PEP_dwaSUBSETCOLORS, 0, 4, dwArray, 0 );

       // subset line types
       int nLineTypes[] = { PELT_MEDIUMSOLID, PELT_MEDIUMSOLID, PELT_MEDIUMSOLID, PELT_MEDIUMSOLID };
       PEvset(m_hPE, PEP_naSUBSETLINETYPES, nLineTypes, 4);

       // subset point types
       int nPointTypes[] = { PEPT_DOTSOLID, PEPT_UPTRIANGLESOLID, PEPT_SQUARESOLID, PEPT_DOWNTRIANGLESOLID };
       PEvset(m_hPE, PEP_naSUBSETPOINTTYPES, nPointTypes, 4);

       // Version 4.0 Features //
       PEnset(m_hPE, PEP_bFIXEDFONTS, TRUE);
       PEnset(m_hPE, PEP_bSIMPLEPOINTLEGEND, TRUE);
       PEnset(m_hPE, PEP_bSIMPLELINELEGEND, TRUE);
       PEnset(m_hPE, PEP_nLEGENDSTYLE, PELS_1_LINE);
       PEnset(m_hPE, PEP_nMULTIAXISSTYLE, PEMAS_SEPARATE_AXES);

       // Set Various Other Properties //
       PEnset(m_hPE, PEP_bBITMAPGRADIENTMODE, TRUE);
       PEnset(m_hPE, PEP_nQUICKSTYLE, PEQS_MEDIUM_NO_BORDER);

       PEnset(m_hPE, PEP_nGRADIENTBARS, 8);
       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_LARGE);
       PEnset(m_hPE, PEP_bSCROLLINGHORZZOOM, TRUE);
       PEnset(m_hPE, PEP_nDATAPRECISION, 1);

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