彩票走势图

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

原创|使用教程|编辑:郝浩|2013-04-16 14:46:32.000|阅读 1148 次

概述:工业控制图表控件ProEssentials 一共由5个图表对象组成,今天慧都小编将为大家介绍Graph Control。

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

相关链接:

工业控制图表控件ProEssentials 一共由Pie Chart Object、Polar / Smith Object、3D Scientific Graph Object、Graph Control、Scientific Graph Object这5个图表对象组成,今天慧都小编将为大家介绍Graph Control。Graph Control有X轴和Y轴两个坐标,X轴通常定义数据的时间节点,Y轴显示数值信息。ProEssentials图形图表支持大批量数据的显示,用户可以通过放大或调整对话框查看图表上更详细的信息。

下面是一个简单的示例:


ProEssentials,Graph Control图表

源代码:

void CPEView::CreateSimpleGraph()
{
   //! 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 graph object. //
   // Graph's generally only contain YData because we assume
   // data is plotted equally spaced left to right.

   RECT rect;
   GetClientRect( &rect );
   m_hPE = PEcreate(PECONTROL_GRAPH, WS_VISIBLE, &rect, m_hWnd, 1001);
   if (m_hPE) 
   {
       // 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);

       // Prepare images in memory //
       PEnset(m_hPE, PEP_bPREPAREIMAGES, TRUE);

       // Pass Data //
       PEnset(m_hPE, PEP_nSUBSETS, 4);
       PEnset(m_hPE, PEP_nPOINTS, 12);

       float fY;
       for (int s=0; s<=3; s++)
       {
           for (int p=0; p<=11; p++)
           {
               fY = (((float) (p + 1)) * 50.0F) + ((float) GetRandom(2, 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 3D //
       PEnset(m_hPE, PEP_nDATASHADOWS, PEDS_SHADOWS);

       PEszset(m_hPE, PEP_szMAINTITLE, TEXT("Units Sold per Month"));
       PEszset(m_hPE, PEP_szSUBTITLE, TEXT("")); 
       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_nPLOTTINGMETHOD, PEGPM_AREA);
       PEnset(m_hPE, PEP_nGRIDLINECONTROL, PEGLC_BOTH);
       PEnset(m_hPE, PEP_bALLOWRIBBON, TRUE);
       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" ));

       // point labels //
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 0, TEXT("January" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 1, TEXT("February" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 2, TEXT("March" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 3, TEXT("April" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 4, TEXT("May" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 5, TEXT("June" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 6, TEXT("July" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 7, TEXT("August" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 8, TEXT("September" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 9, TEXT("October" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 10, TEXT("November" ));
       PEvsetcell( m_hPE, PEP_szaPOINTLABELS, 11, TEXT("December" ));

       // 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, PELT_MEDIUMSOLID, 
           PELT_MEDIUMSOLID, PELT_MEDIUMSOLID, PELT_MEDIUMSOLID};
       PEvset(m_hPE, PEP_naSUBSETLINETYPES, nLineTypes, 8);

       // subset point types //
       int nPointTypes[] = { PEPT_DOTSOLID, PEPT_UPTRIANGLESOLID, 
           PEPT_SQUARESOLID, PEPT_DOWNTRIANGLESOLID, PEPT_DOT, 
           PEPT_UPTRIANGLE, PEPT_SQUARE, PEPT_DOWNTRIANGLE };
       PEvset(m_hPE, PEP_naSUBSETPOINTTYPES, nPointTypes, 8);

       // Allow stacked type graphs //
       PEnset(m_hPE, PEP_bNOSTACKEDDATA, FALSE);

       // Various other features //
       PEnset(m_hPE, PEP_bFIXEDFONTS, TRUE);
       PEnset(m_hPE, PEP_bBITMAPGRADIENTMODE, TRUE);
       PEnset(m_hPE, PEP_nQUICKSTYLE, PEQS_MEDIUM_LINE);
       PEnset(m_hPE, PEP_bSIMPLEPOINTLEGEND, TRUE);
       PEnset(m_hPE, PEP_bSIMPLELINELEGEND, TRUE);
       PEnset(m_hPE, PEP_nLEGENDSTYLE, PELS_1_LINE);

       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_nDATAPRECISION, 1);
       PEnset(m_hPE, PEP_nGRAPHPLUSTABLE, PEGPT_BOTH);
       PEnset(m_hPE, PEP_bMARKDATAPOINTS, TRUE);
       PEnset(m_hPE, PEP_nGRIDSTYLE, PEGS_DOT);

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

       PEnset(m_hPE, PEP_nRENDERENGINE, PERE_GDIPLUS);

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

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

标签:

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

文章转载自:慧都控件

为你推荐

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


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP