<commit_before>// @(#)root/graf:$Name:  $:$Id: TPie.cxx,v 1.6 2006/11/23 13:37:14 couet Exp $
// Author: <NAME>, <NAME> 03/11/2006

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TPie.h"

#include <Riostream.h>
#include <TROOT.h>
#include <TPad.h>
#include <TArc.h>
#include <TMath.h>
#include <TStyle.h>
#include <TLatex.h>
#include <TPaveText.h>
#include <TH1.h>

ClassImp(TPie)

//______________________________________________________________________________
//
// Draw a Pie Chart
//
// The macro $ROOTSYS/tutorials/piechart.C produces the following picture:
//Begin_Html
/*
<img src="gif/piechart.gif">
*/
//End_Html
//

static Double_t gX             = 0; // temporary pie X position
static Double_t gY             = 0; // temporary pie Y position
static Double_t gRadius        = 0; // temporary pie Radius of the TPie
static Double_t gRadiusOffset  = 0; // temporary slice's radial offset
static Double_t gAngularOffset = 0; // temporary slice's angular offset
static Bool_t   gIsUpt         = kFALSE; // True is the TPie should be updated


//______________________________________________________________________________
TPie::TPie() : TNamed()
{
   // Default constructor.

   Init(1, 0, 0.5, 0.5, 0.4);
}


//______________________________________________________________________________
TPie::TPie(const char *name, const char *title, Int_t npoints) :
   TNamed(name,title)
{
   // This constructor creates a pie chart when only the number of
   // the slices is known. The number of slices is fixed.

   Init(npoints, 0, 0.5, 0.5, 0.4);
}


//______________________________________________________________________________
TPie::TPie(const char *name,
               const char *title,
               Int_t npoints, Double_t *vals,
               Int_t *colors, const char *lbls[]) : TNamed(name,title)
{
   // 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.

   Init(npoints, 0, 0.5, 0.5, 0.4);
   for (Int_t i=0; i<fNvals; ++i) fVals[i] = vals[i];

   SetFillColors(colors);
   SetLabels(lbls);
}


//______________________________________________________________________________
TPie::TPie(const char *name,
               const char *title,
               Int_t npoints, Float_t *vals,
               Int_t *colors, const char *lbls[]) : TNamed(name,title)
{
   // Normal constructor (Float_t).

   Init(npoints, 0, 0.5, 0.5, 0.4);
   for (Int_t i=0; i<fNvals; ++i) fVals[i] = vals[i];

   SetFillColors(colors);
   SetLabels(lbls);
}


//______________________________________________________________________________
TPie::TPie(const TH1 *h) : TNamed(h->GetName(),h->GetTitle())
{
   // Constructor from a TH1

   TAxis *axis = h->GetXaxis();
   Int_t first = axis->GetFirst();
   Int_t last  = axis->GetLast();
   Int_t np    = last-first+1;
   Init(np, 0, 0.5, 0.5, 0.4);
   for (Int_t i=first; i<=last; ++i) fVals[i-first] = h->GetBinContent(i);
}


//______________________________________________________________________________
TPie::TPie(const TPie &cpy) : TNamed(cpy), TAttText(cpy)
{
   // Copy constructor.

   Init(cpy.fNvals, cpy.fAngularOffset, cpy.fX, cpy.fY, cpy.fRadius);

   for (Int_t i=0;i<fNvals;++i) {
      fVals[i]          = cpy.fVals[i];
      fLineColors[i]    = cpy.fLineColors[i];
      fLineStyles[i]    = cpy.fLineStyles[i];
      fLineWidths[i]    = cpy.fLineWidths[i];
      fFillColors[i]    = cpy.fFillColors[i];
      fFillStyles[i]    = cpy.fFillStyles[i];
      fRadiusOffsets[i] = cpy.fRadiusOffsets[i];
   }
}

//______________________________________________________________________________
TPie::~TPie()<commit_msg>- Set better labels in the constructor from a TH1.<commit_after>// @(#)root/graf:$Name:  $:$Id: TPie.cxx,v 1.7 2006/11/24 13:07:55 couet Exp $
// Author: <NAME>, <NAME> 03/11/2006

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TPie.h"

#include <Riostream.h>
#include <TROOT.h>
#include <TPad.h>
#include <TArc.h>
#include <TMath.h>
#include <TStyle.h>
#include <TLatex.h>
#include <TPaveText.h>
#include <TH1.h>

ClassImp(TPie)

//______________________________________________________________________________
//
// Draw a Pie Chart
//
// The macro $ROOTSYS/tutorials/piechart.C produces the following picture:
//Begin_Html
/*
<img src="gif/piechart.gif">
*/
//End_Html
//

static Double_t gX             = 0; // temporary pie X position
static Double_t gY             = 0; // temporary pie Y position
static Double_t gRadius        = 0; // temporary pie Radius of the TPie
static Double_t gRadiusOffset  = 0; // temporary slice's radial offset
static Double_t gAngularOffset = 0; // temporary slice's angular offset
static Bool_t   gIsUpt         = kFALSE; // True is the TPie should be updated


//______________________________________________________________________________
TPie::TPie() : TNamed()
{
   // Default constructor.

   Init(1, 0, 0.5, 0.5, 0.4);
}


//______________________________________________________________________________
TPie::TPie(const char *name, const char *title, Int_t npoints) :
   TNamed(name,title)
{
   // This constructor creates a pie chart when only the number of
   // the slices is known. The number of slices is fixed.

   Init(npoints, 0, 0.5, 0.5, 0.4);
}


//______________________________________________________________________________
TPie::TPie(const char *name,
               const char *title,
               Int_t npoints, Double_t *vals,
               Int_t *colors, const char *lbls[]) : TNamed(name,title)
{
   // 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.

   Init(npoints, 0, 0.5, 0.5, 0.4);
   for (Int_t i=0; i<fNvals; ++i) fVals[i] = vals[i];

   SetFillColors(colors);
   SetLabels(lbls);
}


//______________________________________________________________________________
TPie::TPie(const char *name,
               const char *title,
               Int_t npoints, Float_t *vals,
               Int_t *colors, const char *lbls[]) : TNamed(name,title)
{
   // Normal constructor (Float_t).

   Init(npoints, 0, 0.5, 0.5, 0.4);
   for (Int_t i=0; i<fNvals; ++i) fVals[i] = vals[i];

   SetFillColors(colors);
   SetLabels(lbls);
}


//______________________________________________________________________________
TPie::TPie(const TH1 *h) : TNamed(h->GetName(),h->GetTitle())
{
   // Constructor from a TH1

   Int_t i;

   TAxis *axis = h->GetXaxis();
   Int_t first = axis->GetFirst();
   Int_t last  = axis->GetLast();
   Int_t np    = last-first+1;
   Init(np, 0, 0.5, 0.5, 0.4);
   for (i=first; i<=last; ++i) fVals[i-first] = h->GetBinContent(i);
   if (axis->GetLabels()) {
      for (i=first; i<=last; ++i) fLabels[i-first] = axis->GetBinLabel(i);
   } else {
      SetLabelFormat("%val");
   }
}


//______________________________________________________________________________
TPie::TPie(const TPie &cpy) : TNamed(cpy), TAttText(cpy)
{
   // Copy constructor.

   Init(cpy.fNvals, cpy.fAngularOffset, cpy.fX, cpy.fY, cpy.fRadius);

   for (Int_t i=0;i<fNvals;++i) {
      fVals[i]          = cpy.fVals[i];
      fLineColors[i]    = cpy.fLineColors[i];
      fLineStyles[i]    = cpy.fLineStyles[i];
      fLineWidths[i]    = cpy.fLineWidths[i];
      fFillColors[i]    = cpy.fFillColors[i];
      fFillStyles[i]    = cpy.fFillStyles[i];
      fRadiusOffsets[i] = cpy.fRadiusOffsets[i];
   }
}

//______________________________________________________________________________
TPie::~TPie()
{'fraction_non_alphanumeric': 0.15102702702702703, 'fraction_numerical': 0.018054054054054053, 'mean_word_length': 2.943307757885763, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5728159', 'n_tokens_mistral': 2973, 'n_tokens_neox': 2818, 'n_words': 771}