CMS  Version 3.9
PieChart Class Reference

Public Member Functions

 PieChart ($id, $width=300, $height=300, $values=null, $labels=null, $palette="standard")
 
 setSize ($width, $height)
 
 setContainerSize ($width, $height="0")
 
 setCenter ($cx, $cy)
 
 setRadius ($r)
 
 setLabelSize ($size)
 
 setStrokeWidth ($s)
 
 setFontFamily ($font)
 
 showLegend ($show, $x=0, $y=0)
 
 showPercentages ($show, $size=16, $distance=0.75)
 
 setTitle ($title, $x=300, $y=25, $size=14)
 
 draw ()
 

Public Attributes

 $width
 
 $height
 
 $containerWidth
 
 $containerHeight
 
 $cx
 
 $cy
 
 $values
 
 $labels
 
 $palette
 
 $labelSize = 12
 
 $strokeWidth = 1
 
 $animate = true
 
 $shadow = true
 
 $emboss = false
 
 $legend = false
 
 $legendX = 0
 
 $legendY = 0
 
 $legendSwatchSize = 20
 
 $legendLineHeight = 30
 
 $percentages = true
 
 $percentagesSize = 16
 
 $percentagesDistance = 0.75
 
 $onSectorOver = "null"
 
 $onSectorOut = "null"
 
 $onSectorClick = "null"
 
 $onLegendOver = "null"
 
 $onLegendOut = "null"
 
 $onLegendClick = "null"
 
 $onSelectionChanged = "null"
 
 $onDrawChart = "null"
 
 $onDrawChartComplete = "null"
 
 $onDrawLegend = "null"
 
 $onDrawLegendComplete = "null"
 
 $scaleToFit = false
 
 $fixedSize = true
 
 $fontFamily = 'Arial, Helvetica'
 
 $canvasBackground = "#FFFFFF"
 
 $selectable = false
 
 $animateSelection = false
 
 $preselected = null
 
 $title = ""
 
 $titleX = 300
 
 $titleY = 25
 
 $titleSize = 14
 

Detailed Description

Definition at line 41 of file pie_chart.inc.

Member Function Documentation

◆ draw()

PieChart::draw ( )

Definition at line 161 of file pie_chart.inc.

162  {
163  global $script;
164  $values = implode(", ", $this->values);
165  $labels = "'".implode("', '", $this->labels) . "'";
166  $animate = $this->animate ? "true" : "false";
167  $shadow = $this->shadow ? "true": "false";
168  $emboss = $this->emboss ? "true" : "false";
169  $legend = $this->legend ? "true" : "false";
170  $percentages = $this->showPercentages ? "true" : "false";
171  $download = $this->enableDownload ? "true" : "false";
172  $selectable = $this->selectable ? "true": "false";
173  $animateSelection = $this->animateSelection ? "true" : "false";
174 
175  if (is_array($this->preselected))
176  {
177  $preselected = ",\n\t\tpreselected: [".implode(",", $this->preselected)."]";
178  }
179  else
180  {
181  $preselected = "";
182  }
183 
184  $containerWidth = is_numeric($this->containerWidth) ? $this->containerWidth . "px" : $this->containerWidth;
185  $containerHeight = is_numeric($this->containerHeight) ? $this->containerHeight . "px" : $this->containerHeight;
186 
187  if ($this->title)
188  {
189  $titleOptions = "\n\t\ttitle: '".jsSafe($this->title)."',\n\t\ttitlex: {$this->titleX},\n\t\ttitley: {$this->titleY},\n\t\ttitleSize: {$this->titleSize},\n";
190  }
191 
192  $script .= <<<ENDSCRIPT
193 <script type="text/javascript">
194 window.addEvent('domready', function ()
195 {
196  var {$this->id} = new PieChart('{$this->id}',
197  {{$titleOptions}
198  width: {$this->width},
199  height: {$this->height},
200  cx: {$this->cx},
201  cy: {$this->cy},
202  radius: {$this->radius},
203  palette: '{$this->palette}',
204  labelSize: {$this->labelSize},
205  fontFamily: '{$this->fontFamily}',
206  strokeWidth: {$this->strokeWidth},
207  animate: {$animate},
208  shadow: {$shadow},
209  emboss: {$emboss},
210  legend: {$legend},
211  legendX: {$this->legendX},
212  legendY: {$this->legendY},
213  legendSwatchSize: {$this->legendSwatchSize},
214  legendLineHeight: {$this->legendLineHeight},
215  percentages: {$percentages},
216  percentagesSize: {$this->percentagesSize},
217  onSectorOver: {$this->onSectorOver},
218  onSectorOut: {$this->onSectorOut},
219  onSectorClick: {$this->onSectorClick},
220  onLegendOver: {$this->onLegendOver},
221  onLegendOut: {$this->onLegendOut},
222  onLegendClick: {$this->onLegendClick},
223  onDrawChart: {$this->onDrawChart},
224  onDrawChartComplete: {$this->onDrawChartComplete},
225  onDrawLegend: {$this->onDrawLegend},
226  onDrawLegendComplete: {$this->onDrawLegendComplete},
227  onSelectionChanged: {$this->onSelectionChanged},
228  enableDownload: {$download},
229  canvasBackground: '{$this->canvasBackground}',
230  selectable: {$selectable}{$preselected},
231  animateSelection: {$animateSelection}
232  });
233  {$this->id}.values = [ $values ];
234  {$this->id}.labels = [ $labels ];
235 
236  {$this->id}.draw();
237 });
238 </script>
239 ENDSCRIPT;
240 
241  if ($this->scaleToFit)
242  {
243  $dimensions = "width: 100%; height: auto";
244  }
245  else if ($this->fixedSize)
246  {
247  $dimensions = "width: {$containerWidth}; height: {$containerHeight};";
248  }
249  else
250  {
251  $dimensions = "";
252  }
253 
254  echo "<div id='{$this->id}' style='$dimensions'></div>";
255  }
$helpTree width
Definition: tree.inc:45
$bookmark title
$containerWidth
Definition: pie_chart.inc:45
$containerHeight
Definition: pie_chart.inc:46
$animateSelection
Definition: pie_chart.inc:81
showPercentages($show, $size=16, $distance=0.75)
Definition: pie_chart.inc:146
PieChart($id, $width=300, $height=300, $values=null, $labels=null, $palette="standard")
Definition: pie_chart.inc:88
$desc height
Definition: event_edit.inc:64
$dial scaleToFit
Definition: test_dial.inc:12
$dial shadow
Definition: test_dial.inc:11
$pie emboss
Definition: test_pie.inc:10

◆ PieChart()

PieChart::PieChart (   $id,
  $width = 300,
  $height = 300,
  $values = null,
  $labels = null,
  $palette = "standard" 
)

Definition at line 88 of file pie_chart.inc.

89  {
90  $this->id = $id;
91  $this->setSize($width, $height);
93  $this->values = $values;
94  $this->labels = $labels;
95  $this->palette = $palette;
96  }
setContainerSize($width, $height="0")
Definition: pie_chart.inc:107
setSize($width, $height)
Definition: pie_chart.inc:98

◆ setCenter()

PieChart::setCenter (   $cx,
  $cy 
)

Definition at line 113 of file pie_chart.inc.

114  {
115  $this->cx = $cx;
116  $this->cy = $cy;
117  }

◆ setContainerSize()

PieChart::setContainerSize (   $width,
  $height = "0" 
)

Definition at line 107 of file pie_chart.inc.

108  {
109  $this->containerWidth = $width;
110  $this->containerHeight = $height;
111  }

◆ setFontFamily()

PieChart::setFontFamily (   $font)

Definition at line 134 of file pie_chart.inc.

135  {
136  $this->fontFamily = $font;
137  }

◆ setLabelSize()

PieChart::setLabelSize (   $size)

Definition at line 124 of file pie_chart.inc.

125  {
126  $this->labelSize = $size;
127  }
$size
Definition: download.inc:47

◆ setRadius()

PieChart::setRadius (   $r)

Definition at line 119 of file pie_chart.inc.

120  {
121  $this->radius = $r;
122  }

◆ setSize()

PieChart::setSize (   $width,
  $height 
)

Definition at line 98 of file pie_chart.inc.

99  {
100  $this->width = $width;
101  $this->height = $height;
102  if (!$this->cx) $this->cx = $this->width / 2;
103  if (!$this->cy) $this->cy = $this->height / 2;
104  if (!$this->radius) $this->radius = min($width, $height) * .4;
105  }

◆ setStrokeWidth()

PieChart::setStrokeWidth (   $s)

Definition at line 129 of file pie_chart.inc.

130  {
131  $this->strokeWidth = $s;
132  }

◆ setTitle()

PieChart::setTitle (   $title,
  $x = 300,
  $y = 25,
  $size = 14 
)

Definition at line 153 of file pie_chart.inc.

154  {
155  $this->title = $title;
156  $this->titleX = $x;
157  $this->titleY = $y;
158  $this->titleSize = $size;
159  }

◆ showLegend()

PieChart::showLegend (   $show,
  $x = 0,
  $y = 0 
)

Definition at line 139 of file pie_chart.inc.

140  {
141  $this->legend = $show;
142  $this->legendX = $x;
143  $this->legendY = $y;
144  }

◆ showPercentages()

PieChart::showPercentages (   $show,
  $size = 16,
  $distance = 0.75 
)

Definition at line 146 of file pie_chart.inc.

147  {
148  $this->percentages = $show;
149  $this->percentagesSize = $size;
150  $this->percentagesDistance = $distance;
151  }

Member Data Documentation

◆ $animate

PieChart::$animate = true

Definition at line 54 of file pie_chart.inc.

◆ $animateSelection

PieChart::$animateSelection = false

Definition at line 81 of file pie_chart.inc.

◆ $canvasBackground

PieChart::$canvasBackground = "#FFFFFF"

Definition at line 79 of file pie_chart.inc.

◆ $containerHeight

PieChart::$containerHeight

Definition at line 46 of file pie_chart.inc.

◆ $containerWidth

PieChart::$containerWidth

Definition at line 45 of file pie_chart.inc.

◆ $cx

PieChart::$cx

Definition at line 47 of file pie_chart.inc.

◆ $cy

PieChart::$cy

Definition at line 48 of file pie_chart.inc.

◆ $emboss

PieChart::$emboss = false

Definition at line 56 of file pie_chart.inc.

◆ $fixedSize

PieChart::$fixedSize = true

Definition at line 77 of file pie_chart.inc.

◆ $fontFamily

PieChart::$fontFamily = 'Arial, Helvetica'

Definition at line 78 of file pie_chart.inc.

◆ $height

PieChart::$height

Definition at line 44 of file pie_chart.inc.

◆ $labels

PieChart::$labels

Definition at line 50 of file pie_chart.inc.

◆ $labelSize

PieChart::$labelSize = 12

Definition at line 52 of file pie_chart.inc.

◆ $legend

PieChart::$legend = false

Definition at line 57 of file pie_chart.inc.

◆ $legendLineHeight

PieChart::$legendLineHeight = 30

Definition at line 61 of file pie_chart.inc.

◆ $legendSwatchSize

PieChart::$legendSwatchSize = 20

Definition at line 60 of file pie_chart.inc.

◆ $legendX

PieChart::$legendX = 0

Definition at line 58 of file pie_chart.inc.

◆ $legendY

PieChart::$legendY = 0

Definition at line 59 of file pie_chart.inc.

◆ $onDrawChart

PieChart::$onDrawChart = "null"

Definition at line 72 of file pie_chart.inc.

◆ $onDrawChartComplete

PieChart::$onDrawChartComplete = "null"

Definition at line 73 of file pie_chart.inc.

◆ $onDrawLegend

PieChart::$onDrawLegend = "null"

Definition at line 74 of file pie_chart.inc.

◆ $onDrawLegendComplete

PieChart::$onDrawLegendComplete = "null"

Definition at line 75 of file pie_chart.inc.

◆ $onLegendClick

PieChart::$onLegendClick = "null"

Definition at line 70 of file pie_chart.inc.

◆ $onLegendOut

PieChart::$onLegendOut = "null"

Definition at line 69 of file pie_chart.inc.

◆ $onLegendOver

PieChart::$onLegendOver = "null"

Definition at line 68 of file pie_chart.inc.

◆ $onSectorClick

PieChart::$onSectorClick = "null"

Definition at line 67 of file pie_chart.inc.

◆ $onSectorOut

PieChart::$onSectorOut = "null"

Definition at line 66 of file pie_chart.inc.

◆ $onSectorOver

PieChart::$onSectorOver = "null"

Definition at line 65 of file pie_chart.inc.

◆ $onSelectionChanged

PieChart::$onSelectionChanged = "null"

Definition at line 71 of file pie_chart.inc.

◆ $palette

PieChart::$palette

Definition at line 51 of file pie_chart.inc.

◆ $percentages

PieChart::$percentages = true

Definition at line 62 of file pie_chart.inc.

◆ $percentagesDistance

PieChart::$percentagesDistance = 0.75

Definition at line 64 of file pie_chart.inc.

◆ $percentagesSize

PieChart::$percentagesSize = 16

Definition at line 63 of file pie_chart.inc.

◆ $preselected

PieChart::$preselected = null

Definition at line 82 of file pie_chart.inc.

◆ $scaleToFit

PieChart::$scaleToFit = false

Definition at line 76 of file pie_chart.inc.

◆ $selectable

PieChart::$selectable = false

Definition at line 80 of file pie_chart.inc.

◆ $shadow

PieChart::$shadow = true

Definition at line 55 of file pie_chart.inc.

◆ $strokeWidth

PieChart::$strokeWidth = 1

Definition at line 53 of file pie_chart.inc.

◆ $title

PieChart::$title = ""

Definition at line 83 of file pie_chart.inc.

◆ $titleSize

PieChart::$titleSize = 14

Definition at line 86 of file pie_chart.inc.

◆ $titleX

PieChart::$titleX = 300

Definition at line 84 of file pie_chart.inc.

◆ $titleY

PieChart::$titleY = 25

Definition at line 85 of file pie_chart.inc.

◆ $values

PieChart::$values

Definition at line 49 of file pie_chart.inc.

◆ $width

PieChart::$width

Definition at line 43 of file pie_chart.inc.


The documentation for this class was generated from the following file: