class TPie: public TNamed, public TAttText


 Draw a Pie Chart

 The macro $ROOTSYS/tutorials/graphics/piechart.C produces the following
 picture:

/* */

Function Members (Methods)

public:
TPie()
TPie(const TH1* h)
TPie(const TPie&)
TPie(const char*, const char*, Int_t)
TPie(const char*, const char*, Int_t, Double_t*, Int_t* cols = 0, const char** lbls = 0)
TPie(const char*, const char*, Int_t, Float_t*, Int_t* cols = 0, const char** lbls = 0)
virtual~TPie()
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual voidTNamed::Copy(TObject& named) const
virtual voidTObject::Delete(Option_t* option = "")
virtual Int_tDistancetoPrimitive(Int_t px, Int_t py)
Int_tDistancetoSlice(Int_t, Int_t)
virtual voidDraw(Option_t* option = "l")
virtual voidTObject::DrawClass() const
virtual TObject*TObject::DrawClone(Option_t* option = "") const
virtual voidTObject::Dump() const
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidExecuteEvent(Int_t, Int_t, Int_t)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
Float_tGetAngle3D()
Double_tGetAngularOffset()
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
Int_tGetEntryFillColor(Int_t)
Int_tGetEntryFillStyle(Int_t)
const char*GetEntryLabel(Int_t)
Int_tGetEntryLineColor(Int_t)
Int_tGetEntryLineStyle(Int_t)
Int_tGetEntryLineWidth(Int_t)
Double_tGetEntryRadiusOffset(Int_t)
Double_tGetEntryVal(Int_t)
const char*GetFractionFormat()
Double_tGetHeight()
virtual const char*TObject::GetIconName() const
const char*GetLabelFormat()
Float_tGetLabelsOffset()
TLegend*GetLegend()
virtual const char*TNamed::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
const char*GetPercentFormat()
Double_tGetRadius()
TPieSlice*GetSlice(Int_t i)
virtual Short_tTAttText::GetTextAlign() const
virtual Float_tTAttText::GetTextAngle() const
virtual Color_tTAttText::GetTextColor() const
virtual Font_tTAttText::GetTextFont() const
virtual Float_tTAttText::GetTextSize() const
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
const char*GetValueFormat()
Double_tGetX()
Double_tGetY()
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() const
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTNamed::ls(Option_t* option = "") const
TLegend*MakeLegend(Double_t x1 = .65, Double_t y1 = .65, Double_t x2 = .95, Double_t y2 = .95, const char* leg_header = "")
voidMakeSlices(Bool_t force = kFALSE)
voidTObject::MayNotUse(const char* method) const
virtual voidTAttText::Modify()
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TPie&operator=(const TPie&)
virtual voidPaint(Option_t*)
virtual voidTObject::Pop()
virtual voidTNamed::Print(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
virtual voidTAttText::ResetAttText(Option_t* toption = "")
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") const
virtual voidSavePrimitive(ostream& out, Option_t* opts = "")
virtual voidTAttText::SaveTextAttributes(ostream& out, const char* name, Int_t alidef = 12, Float_t angdef = 0, Int_t coldef = 1, Int_t fondef = 61, Float_t sizdef = 1)
voidSetAngle3D(Float_t val = 30.)
voidSetAngularOffset(Double_t)
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidSetCircle(Double_t x = .5, Double_t y = .5, Double_t rad = .4)
virtual voidTObject::SetDrawOption(Option_t* option = "")
static voidTObject::SetDtorOnly(void* obj)
voidSetEntryFillColor(Int_t, Int_t)
voidSetEntryFillStyle(Int_t, Int_t)
voidSetEntryLabel(Int_t, const char* text = "Slice")
voidSetEntryLineColor(Int_t, Int_t)
voidSetEntryLineStyle(Int_t, Int_t)
voidSetEntryLineWidth(Int_t, Int_t)
voidSetEntryRadiusOffset(Int_t, Double_t)
voidSetEntryVal(Int_t, Double_t)
voidSetFillColors(Int_t*)
voidSetFractionFormat(const char*)
voidSetHeight(Double_t val = .08)
voidSetLabelFormat(const char*)
voidSetLabels(const char**)
voidSetLabelsOffset(Float_t)
virtual voidTNamed::SetName(const char* name)
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
voidSetPercentFormat(const char*)
voidSetRadius(Double_t)
virtual voidTAttText::SetTextAlign(Short_t align = 11)
virtual voidTAttText::SetTextAngle(Float_t tangle = 0)
virtual voidTAttText::SetTextAttributes()
virtual voidTAttText::SetTextColor(Color_t tcolor = 1)
virtual voidTAttText::SetTextFont(Font_t tfont = 62)
virtual voidTAttText::SetTextSize(Float_t tsize = 1)
virtual voidTAttText::SetTextSizePixels(Int_t npixels)
virtual voidTNamed::SetTitle(const char* title = "")
virtual voidTObject::SetUniqueID(UInt_t uid)
voidSetValueFormat(const char*)
voidSetX(Double_t)
voidSetY(Double_t)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual Int_tTNamed::Sizeof() const
voidSortSlices(Bool_t amode = kTRUE, Float_t merge_thresold = .0)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
private:
voidDrawGhost()
voidInit(Int_t np, Double_t ao, Double_t x, Double_t y, Double_t r)

Data Members

public:
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
protected:
Float_tfAngle3DThe angle of the pseudo-3d view
Double_tfAngularOffsetOffset angular offset for the first slice
TStringfFractionFormatRform numeric format for the fraction of a slice
Double_tfHeightPheight height of the slice in pixel
Bool_tfIs3D! true if the pseudo-3d is enabled
TStringfLabelFormatFormat format of the slices' label
Float_tfLabelsOffsetLabelsOffset offset of label
TStringTNamed::fNameobject identifier
Int_tfNvalsNumber of elements
TStringfPercentFormatPfrom numeric format for the percent of a slice
TPieSlice**fPieSlices[fNvals] Slice array of this pie-chart
Double_tfRadiusRadius Pie radius
Short_tTAttText::fTextAlignText alignment
Float_tTAttText::fTextAngleText angle
Color_tTAttText::fTextColorText color index
Font_tTAttText::fTextFontText font number
Float_tTAttText::fTextSizeText size
TStringTNamed::fTitleobject title
TStringfValueFormatVform numeric format for the value
Double_tfXX coordinate of the pie centre
Double_tfYY coordinate of the pie centre
private:
TLegend*fLegend!Legend for this piechart
Float_t*fSlices!Subdivisions of the slices
Float_tfSum!Sum for the slice values

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TPie()
 Default constructor.
TPie(const char* , const char* , Int_t )
 This constructor creates a pie chart when only the number of
 the slices is known. The number of slices is fixed.
TPie(const char *name, const char *title, Int_t npoints, Double_t *vals, Int_t *colors, const char *lbls[])
 Normal constructor. The 1st and 2nd parameters are the name of the object
 and its title.

 The number of points passed at this point is used to allocate the memory.

 Slices values are given as Double_t.

 The 4th elements is an array containing, in double precision format,
 the value of each slice. It is also possible to specify the filled color
 of each slice. If the color array is not specfied the slices are colored
 using a color sequence in the standard palette.
TPie(const char *name, const char *title, Int_t npoints, Float_t *vals, Int_t *colors, const char *lbls[])
 Normal constructor (Float_t).
TPie(const TH1 *h)
 Constructor from a TH1
TPie(const TPie &cpy)
 Copy constructor.
~TPie()
 Destructor.
Int_t DistancetoPrimitive(Int_t px, Int_t py)
 Evaluate the distance to the chart in gPad.
Int_t DistancetoSlice(Int_t , Int_t )
 Returns the slice number at the pixel position (px,py).
 Returns -1 if no slice is picked.

 Used by DistancetoPrimitive.
void Draw(Option_t* option = "l")
 Draw the pie chart.

 The possible options are listed in the TPie::Paint() method.
void DrawGhost()
 This method is for internal use. It is used by Execute event to draw the
 outline of "this" TPie. Used when the opaque movements are not permitted.
void ExecuteEvent(Int_t , Int_t , Int_t )
 Execute the mouse events.
const char* GetEntryLabel(Int_t )
 Returns the label of the entry number "i".
Int_t GetEntryFillColor(Int_t )
 Return the color of the slice number "i".
Int_t GetEntryFillStyle(Int_t )
 Return the style use to fill the slice number "i".
Int_t GetEntryLineColor(Int_t )
 Return the line color used to outline thi "i" slice
Int_t GetEntryLineStyle(Int_t )
 Return the style used to outline thi "i" slice
Int_t GetEntryLineWidth(Int_t )
 Return the line width used to outline thi "i" slice
Double_t GetEntryRadiusOffset(Int_t )
 Return the radial offset's value for the slice number "i".
Double_t GetEntryVal(Int_t )
 Return the value associated with the slice number "i".
TLegend* GetLegend()
 If created before by Paint option or by MakeLegend method return
 the pointer to the legend, otherwise return 0;
TPieSlice* GetSlice(Int_t i)
 Return the reference to the slice of index 'id'. There are no controls
 of memory corruption, be carefull.
void Init(Int_t np, Double_t ao, Double_t x, Double_t y, Double_t r)
 Common initialization for all constructors.
 This is a private function called to allocate the memory.
TLegend* MakeLegend(Double_t x1 = .65, Double_t y1 = .65, Double_t x2 = .95, Double_t y2 = .95, const char* leg_header = "")
 This method create a legend that explains the contents
 of the slice for this pie-chart.

 The parameter passed reppresents the option passed to shown the slices,
 see TLegend::AddEntry() for futher details.

 The pointer of the TLegend is returned.
void Paint(Option_t* )
 Paint a Pie chart in a canvas.
 The possible option are:

 "R"   Print the labels along the central "R"adius of slices.
 "T"   Print the label in a direction "T"angent to circle that describes
       the TPie.
 "3D"  Draw the pie-chart with a pseudo 3D effect.
 "NOL" No OutLine: Don't draw the slices' outlines, any property over the
       slices' line is ignored.
 ">"   Sort the slices in increasing order.
 "<"   Sort the slices in decreasing order.

 After the use of > or < options the internal order of the TPieSlices
 is changed.

 Other options changing the labels' format are described in
 TPie::SetLabelFormat().
void SavePrimitive(ostream& out, Option_t* opts = "")
 Save primitive as a C++ statement(s) on output stream out
void SetAngle3D(Float_t val = 30.)
 Set the value of for the pseudo 3D view angle, in degree.
 The range of the permitted values is: [0,90]
void SetAngularOffset(Double_t )
 Set the global angular offset for slices in degree [0,360]
void SetCircle(Double_t x = .5, Double_t y = .5, Double_t rad = .4)
 Set the coordinates of the circle that describe the pie:
 - the 1st and the 2nd arguments are the x and y center's coordinates.
 - the 3rd value is the pie-chart's radius.

 All the coordinates are in NDC space.
void SetEntryLabel(Int_t , const char* text = "Slice")
 Set slice number "i" label. The first parameter is the index of the slice,
 the other is the label text.
void SetEntryLineColor(Int_t , Int_t )
 Set the color for the slice's outline. "i" is the slice number.
void SetEntryLineStyle(Int_t , Int_t )
 Set the style for the slice's outline. "i" is the slice number.
void SetEntryLineWidth(Int_t , Int_t )
 Set the width of the slice's outline. "i" is the slice number.
void SetEntryFillColor(Int_t , Int_t )
 Set the color for the slice "i".
void SetEntryFillStyle(Int_t , Int_t )
 Set the fill style for the "i" slice
void SetEntryRadiusOffset(Int_t , Double_t )
 Set the distance, in the direction of the radius of the slice.
void SetEntryVal(Int_t , Double_t )
 Set the value of a slice
void SetFillColors(Int_t* )
 Set the fill colors for all the TPie's slices.
void SetHeight(Double_t val = .08)
 Set the height, in pixel, for the piechart if is drawn using
 the pseudo-3d mode.

 The default value is 20 pixel.
void SetLabelFormat(const char* )
 This method is used to customize the label format. The format string
 must contain one of these modifiers:

 - %txt  : to print the text label associated with the slice
 - %val  : to print the numeric value of the slice
 - %frac : to print the relative fraction of this slice
 - %perc : to print the % of this slice

 ex. : mypie->SetLabelFormat("%txt (%frac)");
void SetFractionFormat(const char* )
 Set numeric format in the label, is used if the label format
 there is the modifier %frac, in this case the value is printed
 using this format.

 The numeric format use the standard C modifier used in stdio library:
 %f, %2.1$, %e... for further documentation you can use the printf
 mapage ("man 3 printf" on linux)

 ex. : mypie->SetLabelFormat("%txt (%frac)");
       mypie->SetFractionFormat("2.1f");
void SetLabels(const char** )
 Set the labels for all the slices.
void SetLabelsOffset(Float_t )
 Set the distance between the label end the external line of the TPie.
void SetPercentFormat(const char* )
 Set the numeric format for the percent value of a slice, default: %3.1f
void SetRadius(Double_t )
 Set the pie chart's radius' value.
void SetValueFormat(const char* )
 Set the numeric format the slices' values.
 Used by %val (see SetLabelFormat()).
void SetX(Double_t )
 Set X value.
void SetY(Double_t )
 Set Y value.
void MakeSlices(Bool_t force = kFALSE)
 Make the slices.
 If they already exist it does nothing unless force=kTRUE.
void SortSlices(Bool_t amode = kTRUE, Float_t merge_thresold = .0)
 This method, mainly intended for internal use, ordered the  slices accoording their values.
 The default (amode=kTRUE) is inscreasing order, but is also possible in decreasing order (amode=kFALSE).

 If the merge_thresold>0 the slice that contains a quantity smaller than merge_thresold are merged
 togheter
Float_t GetAngle3D()
{ return fAngle3D; }
Double_t GetAngularOffset()
{ return fAngularOffset; }
const char * GetFractionFormat()
{ return fFractionFormat.Data(); }
Double_t GetHeight()
{ return fHeight; }
const char * GetLabelFormat()
{ return fLabelFormat.Data(); }
Float_t GetLabelsOffset()
{ return fLabelsOffset; }
const char * GetPercentFormat()
{ return fPercentFormat.Data(); }
Double_t GetRadius()
{ return fRadius;}
const char * GetValueFormat()
{ return fValueFormat.Data(); }
Double_t GetX()
{ return fX; }
Double_t GetY()
{ return fY; }

Author: Guido Volpi, Olivier Couet 03/11/2006
Last update: root/graf:$Id: TPie.h 21606 2008-01-09 10:23:09Z couet $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.