下面这段饼图的代码展示了美国不同州的几种水果产量情况。ProEssentials v7在之前的版本上做了一些改进,在图表上滚动鼠标可以分别查看几种水果的产量图表。双击饼图上的标签,还可以将饼图对应的那一块分离出来。这个饼图还 将那些太小的分片集合分类成*Other,这样可以提高图表数据的可读性。要体验ProEssentials v7的功能,请下载ProEssentials v7。
下面是ProEssentials v7创建简单饼图的源代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
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 ); } //*************************************** |