Click here to Skip to main content
12,952,124 members (59,493 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked
Posted 5 Oct 2003

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 -->


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

#include "mschart.h"

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

#include "mschart.h"
#include "vcplot.h"
#include "vcseriescollection.h"
#include "vcseries.h"
#include "vcdatapoint.h"
#include "vcdatapoints.h"
#include "vcdatapointlabel.h"
#include "font.h"

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

void CPieChartView::OnInitialUpdate()
    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%");   

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

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




Happying Pie Charting!!!


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

Web Developer
India India
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionSetting Custom Text Inside Chart?? Pin
chris17531-Mar-06 3:04
memberchris17531-Mar-06 3:04 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170525.1 | Last Updated 6 Oct 2003
Article Copyright 2003 by ShabuKC
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid