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

2D Multi-Parameter Pie Control

, 7 Jan 2003
Rate this:
Please Sign up or sign in to vote.
A simple 2D Pie Control


The Code Project is an exciting site with impressive teaching and professional exchange capabilities. I have learned much from it and also decided to submit my contribution. Occasionally I was involved in a project to check experimental data for consistency. The data were collected in several binary files, which also contain "holes", i.e. missing data segments. The main idea to simplify the fast check report was to embed this report inside the progress control. So first of all I had found :

I thank these authors for inspiration. It was a starting point, because I needed a more complex structure of the progress control to show report data.

Resolving the problem

Considering 2D pie chart you can easily reveal that it contains 4 parameters, which are potentially able to display 4 independent variables. These are width of angular sectors, their radius, initial offset from the horizontal line (an initial phase), and the color of each angular segment. A small restriction in conversion to the geometrical representation is that the radius and width of angular sectors require positive determined input data, what is sometimes automatically met (for instance, counting number of iterations or loop passing). You may think about the example represented by the figure as a report of processed files, which have their own length (width), the "holes" total length relative to the file length (%) (radius), maximal "hole" length relative to the file length (%) (color), and possibly deviation of the processing time from the mean value (%) (phase). (I have never used the last option, always assuming it as zero, but I believe it can be used in other tasks).

Programming issues

All necessary operations are included in the Cpcontrol class derived from CStatic, which converts processed data into their geometrical representation and displays them in an appropriate window frame. Cpcontrol class is embedded in the standard dialog application, which is responsible for the general data processing and collecting data for the Pie Progress Control. The internal labels of the control can be customized during the process of the dialog initialization.

BOOL CPieProgressCtrlDlg::OnInitDialog()
    // some useful code here    
    //setting for progress pie control
    CRect rect;    
    int lenx=rect.right-rect.left;    
    // keep ratio 2/3 for the control
    strcpy(m_control.m_color,"Max bad segments");    
    strcpy(m_control.m_ctitle,"Current processing info");    
    int fsize=8;
    if(m_control.m_h>80 && m_control.m_h<150) 
    LOGFONT lf; // Used to create the CFont.    
    memset(&lf, 0, sizeof(LOGFONT)); // Clear out structure.    
    lf.lfHeight = fsize; // Request a 12-pixel-high font    
    strcpy(lf.lfFaceName, "Arial"); // with face name "Arial".    
    m_control.m_SmallFont.CreateFontIndirect(&lf); // Create the small font.
    lf.lfHeight = fsize+2;    
    lf.lfHeight = fsize+4;    
    // some other code     

The process of geometrical conversion in the pie progress control is pretty fast and not time consuming as compared with the general data processing. In the above mentioned example an additional delaying function Sleep(500) is used to make an impression this example is visually running.


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

Canada Canada
No Biography provided

Comments and Discussions

GeneralCool PinmemberNorm Almond8-Jan-03 22:54 
GeneralBroken link PinmemberAli Khanlarkhani8-Jan-03 19:24 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.141015.1 | Last Updated 8 Jan 2003
Article Copyright 2003 by valgouss
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid