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

Series Values inside Pie Chart.

, 5 Oct 2003
Rate this:
Please Sign up or sign in to vote.
Display values inside Pie Chart.
<!-- Article Starts - DO NOT ADD HTML/BODY START TAGS--><!-- Article image -->

Sample Image - SeriesValueInsidePieChart.gif

<!-- Add the rest of your HTML here -->

Introduction

This article shows one way of displaying values inside Pie chart.

Using the code

The MSVC ide will include only mschart.h only in the PieChartView.h

//{{AFX_INCLUDES()
#include "mschart.h"
//}}AFX_INCLUDES
</CODE>

Now include all the below show header files in the PieChartView.h file...

//{{AFX_INCLUDES()
#include "mschart.h"
#include "vcplot.h"
#include "vcseriescollection.h"
#include "vcseries.h"
#include "vcdatapoint.h"
#include "vcdatapoints.h"
#include "vcdatapointlabel.h"
#include "font.h"
//}}AFX_INCLUDES
</CODE>

Next in the InitialUpdate() method of FrameView class add the following code.

void CPieChartView::OnInitialUpdate()
{
    CFormView::OnInitialUpdate();
    GetParentFrame()->RecalcLayout();
    ResizeParentToFit();
    
    int count = m_MSChart.GetPlot().GetSeriesCollection().Count();
    CY fontSize;
    fontSize.int64 = 8; 
    for(int i = 1; i< count; i++)
    {
        m_MSChart.GetPlot().GetSeriesCollection().GetItem(i).GetDataPoints().GetItem (-1).GetDataPointLabel().SetLocationType(3);    
        m_MSChart.GetPlot().GetSeriesCollection().GetItem(i).GetDataPoints().GetItem (-1).GetDataPointLabel().SetComponent(2) ;   
        m_MSChart.GetPlot().GetSeriesCollection().GetItem(i).GetDataPoints().GetItem (-1).GetDataPointLabel().SetPercentFormat("0%");   
    }
}
</CODE>

Points of Interest

The same operation in MS Visual Basic looks like this..

 For i = 1 To .Plot.SeriesCollection.Count
         With .Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel
            .LocationType = VtChLabelLocationTypeOutside
            .Component = VtChLabelComponentPercent
            .PercentFormat = "0%"
            .VtFont.Size = 10
         End With
      Next i
</CODE>

Am not able to set the font size in the MSVC version... any one get to know please let me know.

History

None.

Thanks!!

Happying Pie Charting!!!

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

Share

About the Author

ShabuKC
Web Developer
India India
No Biography provided

Comments and Discussions

 
QuestionSetting Custom Text Inside Chart?? Pinmemberchris17531-Mar-06 4:04 

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 | Terms of Use | Mobile
Web01 | 2.8.1411022.1 | Last Updated 6 Oct 2003
Article Copyright 2003 by ShabuKC
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid