Click here to Skip to main content
4.11 / 5, 23 votes

1
1 vote, 10.0%
2
2 votes, 20.0%
3
2 votes, 20.0%
4
5 votes, 50.0%
5

Pie Chart Control

By Yuheng Zhao | 18 Aug 2001
This control creates a simple Pie Chart in a dialog

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


Sign Up to vote for this article
Add a reason or comment to your vote:

Comments and Discussions

You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 5 of 5 (Total in Forum: 5) (Refresh)FirstPrevNext
GeneralUse the PieChartCtrl.cpp for Commercial Application Pinmembermayocheng17:47 6 Jan '10  
GeneralUse for commercial app Pinmemberminimal_objects6:07 25 Aug '08  
Generaladding this to an already existing MFC project? Pinmember12:10 1 Feb '07  
GeneralFix to draw complete circle Pinmemberbkowald6:30 27 Oct '04  
Generallets add more to it Pinmemberaeropriest9:20 9 Apr '02  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+PgUp/PgDown to switch pages.

PermaLink | Privacy | Terms of Use
Last Updated: 18 Aug 2001

Copyright 2001 by Yuheng Zhao
Everything else Copyright © CodeProject, 1999-2010
Web21 | Advertise on the Code Project