Click here to Skip to main content
Click here to Skip to main content

Pie Chart Control

By , 18 Aug 2001
 

Sample Image - pie_chart_ctrl.gif

Introduction

This control class CPieChartCtrl is derived from CWnd. The purpose is to create a simple 2D pie chart in a dialog. The code is created and compiled with Visual C++ 5.0 SP3 under Windows 98.

How to use

  1. Use the MS Visual C++ dialog editor to place a custom control on the dialog, and enter "PIE_CHART_CTRL" as the Class name.

  2. Add a CPieChartCtrl class member in the header file
    #include "PieChartCtrl.h"
    ...
    CPieChartCtrl m_wndChart;
  3. Subclass the class member with the control in InitDialog()
    m_wndChart.SubclassDlgItem(IDC_PIECHART1, this); //IDC_PIECHART1 is the control ID
  4. Use these functions to edit to chart
    // SetTitle(CString) - Set the chart title text
    m_wndChart.SetTitle("Chart Title");
    
    // Reset() - Reset the chart and delete all pieces
    m_wndChart.Reset();
    
    // AddPiece(COLORREF colorBack, COLORREF colorText, 
    //            int nAngle, int strInfo = "");
    // Add one piece into the chart
    m_wndChart.AddPiece(colorBack, colorText, nAngle, strInfo);

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Yuheng Zhao
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralUse the PieChartCtrl.cpp for Commercial Applicationmembermayocheng6 Jan '10 - 16:47 
GeneralUse for commercial appmemberminimal_objects25 Aug '08 - 5:07 
Questionadding this to an already existing MFC project?memberMember #35202051 Feb '07 - 11:10 
GeneralFix to draw complete circlememberbkowald27 Oct '04 - 5:30 
Generallets add more to itmemberaeropriest9 Apr '02 - 8:20 
hi,
this pie control works just perfect but i thought to make some additions to it e.g. ability to skin the contol.
 
for this i created the following function
 
SetSkin(short nCursor, short nImageComplete, short nImageIncomplete);
 
now i loaded these images which are full circles of 2 different colors with their background of certain color so that they can be painted tranparently.
 
now in the approach i took, i draw the background image in the OnPaint and then the incomplete image in memory. Over this incomplete image i draw i pie using the standard Pie funtion and then i try to make the pei potion transparent so that the incomplete image is drawn over the background image.
 
but i could't do that ( i just don know why my mind does't work, i tried to mask the potion drawn by pie function )
 
can you help me it.
(im not registered on the site yet so if u reply to this message pls let me know at aero_priest@hotmail.com)
 
thanks n cheers
les keep the good work goingRoll eyes | :rolleyes: Cry | :(( Smile | :)
 
ashok

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 19 Aug 2001
Article Copyright 2001 by Yuheng Zhao
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid