class TPie: public TNamed, public TAttText

 Draw a Pie Chart

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

/* */

Function Members (Methods)

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 = "")MENU
virtual Int_tDistancetoPrimitive(Int_t px, Int_t py)
Int_tDistancetoSlice(Int_t, Int_t)
virtual voidDraw(Option_t* option = "l")MENU
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
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
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
const char*GetEntryLabel(Int_t)
const char*GetFractionFormat()
virtual const char*TObject::GetIconName() const
const char*GetLabelFormat()
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()
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()
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() constMENU
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 = 0.65000000000000002, Double_t y1 = 0.65000000000000002, Double_t x2 = 0.94999999999999996, Double_t y2 = 0.94999999999999996, const char* leg_header = "")
voidMakeSlices(Bool_t force = kFALSE)
voidTObject::MayNotUse(const char* method) const
virtual voidTAttText::Modify()
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
voidTObject::operator delete(void* ptr)
voidTObject::operator delete(void* ptr, void* vp)
voidTObject::operator delete[](void* ptr)
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 = "") constMENU
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.)MENU
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidSetCircle(Double_t x = 0.5, Double_t y = 0.5, Double_t rad = 0.40000000000000002)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
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)
voidSetFractionFormat(const char*)MENU
voidSetHeight(Double_t val = 0.080000000000000002)MENU
voidSetLabelFormat(const char*)MENU
voidSetLabels(const char*[])
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
voidSetPercentFormat(const char*)MENU
virtual voidTAttText::SetTextAlign(Short_t align = 11)
virtual voidTAttText::SetTextAngle(Float_t tangle = 0)MENU
virtual voidTAttText::SetTextAttributes()MENU
virtual voidTAttText::SetTextColor(Color_t tcolor = 1)
virtual voidTAttText::SetTextColorAlpha(Color_t tcolor, Float_t talpha)
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 = "")MENU
virtual voidTObject::SetUniqueID(UInt_t uid)
voidSetValueFormat(const char*)MENU
virtual voidShowMembers(TMemberInspector& insp) const
virtual Int_tTNamed::Sizeof() const
voidSortSlices(Bool_t amode = kTRUE, Float_t merge_thresold = 0.)
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_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
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 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
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidInit(Int_t np, Double_t ao, Double_t x, Double_t y, Double_t r)

Data Members

static TObject::(anonymous)TObject::kBitMask
static TObject::EStatusBitsTObject::kCanDelete
static TObject::EStatusBitsTObject::kCannotPick
static TObject::EStatusBitsTObject::kHasUUID
static TObject::EStatusBitsTObject::kInvalidObject
static TObject::(anonymous)TObject::kIsOnHeap
static TObject::EStatusBitsTObject::kIsReferenced
static TObject::EStatusBitsTObject::kMustCleanup
static TObject::EStatusBitsTObject::kNoContextMenu
static TObject::(anonymous)TObject::kNotDeleted
static TObject::EStatusBitsTObject::kObjInCanvas
static TObject::(anonymous)TObject::kOverwrite
static TObject::(anonymous)TObject::kSingleKey
static TObject::(anonymous)TObject::kWriteDelete
static TObject::(anonymous)TObject::kZombie
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
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

 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* , const char* , Int_t , Double_t* , Int_t* cols = 0, const char*[] lbls = 0)
 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* , const char* , Int_t , Float_t* , Int_t* cols = 0, const char*[] lbls = 0)
 Normal constructor (Float_t).
TPie(const TH1* h)
 Constructor from a TH1
TPie(const TPie& )
 Copy constructor.
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 = 0.65000000000000002, Double_t y1 = 0.65000000000000002, Double_t x2 = 0.94999999999999996, Double_t y2 = 0.94999999999999996, 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.
 "SC"  Paint the the labels with the "S"ame "C"olor as the slices.
 "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
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 = 0.5, Double_t y = 0.5, Double_t rad = 0.40000000000000002)
 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 = 0.080000000000000002)
 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)");
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
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; }
Int_t GetEntries()
{ return fNvals; }
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; }