
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
#include "mschart.h"
</CODE>
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"
</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!!!