24 function set($attr, $val)
26 $this->options[$attr] = $val;
33 foreach ($this->options as $opt => $val)
35 if ($val ===
false) $val =
"false";
36 if ($val ===
true) $val =
"true";
43 $options[] =
"'onClick': {$this->onClick} ";
46 if (count($this->tooltips))
48 $tooltips =
"['".implode(
"', '", array_map(jsSafe, $this->tooltips)).
"']";
49 $options[] =
"'toolTips': $tooltips";
61 foreach($this->values as $value)
63 if ($value ===
"" || !isset($value)) $value =
"null";
70 $out =
"new HistogramSeries('{$this->type}', '" . jsSafe($this->
title) .
"', [{$values}], $options)";
107 $out =
"(new GroupedHistogramSeries('{$this->type}', '". jsSafe($this->
title) .
"', $options))";
108 foreach($this->children as $child)
110 $kid = $child->toScript();
111 $out .=
".addSeries({$kid})";
138 $out =
"(new StackedHistogramSeries('{$this->type}', '". jsSafe($this->
title) .
"', $options))";
139 foreach($this->children as $child)
141 $kid = $child->toScript();
142 $out .=
".addSeries({$kid})";
228 $this->containerWidth =
$width;
229 $this->containerHeight =
$height;
234 $this->chartLeft =
$left;
235 $this->chartTop = $top;
236 $this->chartWidth =
$width;
242 $this->labels = $labels;
247 $this->labelTooltips = $labelTooltips;
252 $this->labelDecorations = $labelDecorations;
257 $this->labelSize =
$size;
262 $this->yAxisLabels = $labels;
267 $this->strokeWidth = $s;
277 $this->legend = $show;
292 foreach($this->series as
$series)
294 foreach(
$series->values as $value)
301 $logMax = intval(log10(
$max));
302 $logMin = intval(log10(
$min));
305 $denom = pow(10,
$log);
309 $max = floor((
$max / $denom) + 1) * $denom;
314 $min = floor((
$min / $denom) - 1) * $denom;
325 $labels =
"'".implode(
"', '", $this->labels) .
"'";
326 $labelTooltips =
"'".implode(
"', '", $this->labelTooltips) .
"'";
328 if ($this->labelDecorations)
330 $decorations = array();
331 foreach($this->labelDecorations as $decoration)
333 $decorations[] = json_encode($decoration);
336 $labelDecorations = implode(
",", $decorations);
341 if (count($this->yAxisLabels))
343 $yaxis =
"'".implode(
"', '", $this->yAxisLabels) .
"'";
344 $yaxis =
"\t{$this->id}.yAxisLabels = [ $yaxis ];";
347 $animate = $this->animate ?
"true" :
"false";
349 $emboss = $this->
emboss?
"true" :
"false";
350 $legend = $this->legend ?
"true" :
"false";
352 $showGrid = $this->showGrid ?
"true" :
"false";
359 foreach($this->series as $s)
361 $data .=
"\t{$this->id}.addSeries(".$s->toScript().
");\n";
364 $jsClass = $this->
morphing ?
"MorphingHistogram" :
"Histogram";
368 $caption = jsSafe($this->
caption);
369 $captionAttrs = json_encode($this->captionAttributes);
370 $captionBlock = <<<ENDSCRIPT
373 captionX: {$this->captionX},
374 captionY: {$this->captionY},
375 captionWidth: {$this->captionWidth},
376 captionAttributes: {$captionAttrs}
382 $script .= <<<ENDSCRIPT
383 <script type=
"text/javascript">
384 window.addEvent(
'domready',
function ()
386 var {$this->
id} =
new $jsClass(
'{$this->id}',
391 chartLeft: {$this->chartLeft},
392 chartTop: {$this->chartTop},
393 chartWidth: {$this->chartWidth},
394 chartHeight: {$this->chartHeight},
395 chartBackground:
'{$this->chartBackground}',
396 palette:
'{$this->palette}',
397 labelSize: {$this->labelSize},
398 labelAngle: {$this->labelAngle},
399 labelAnchor:
'{$this->labelAnchor}',
400 labelOffset: {$this->labelOffset},
401 emptyValueLabel:
'{$this->emptyValueLabel}',
402 strokeWidth: {$this->strokeWidth},
403 gridStrokeWidth: {$this->gridStrokeWidth},
409 legendX: {$this->legendX},
410 legendY: {$this->legendY},
411 legendSwatchSize: {$this->legendSwatchSize},
412 legendLineHeight: {$this->legendLineHeight},
416 startIndex: {$this->startIndex},
417 columnMargin: {$this->columnMargin},
419 titleSize: {$this->titleSize},
421 canvasBackground:
'{$this->canvasBackground}',
422 units:
'{$this->units}',
423 onDrawGrid: {$this->onDrawGrid},
424 onDrawGridComplete: {$this->onDrawGridComplete},
425 onDrawChart: {$this->onDrawChart},
426 onDrawChartComplete: {$this->onDrawChartComplete},
427 onDrawLegend: {$this->onDrawLegend},
428 onDrawLegendComplete: {$this->onDrawLegendComplete}{$captionBlock}
431 {$this->
id}.labels = [ {$labels} ];
432 {$this->
id}.labelTooltips = [ {$labelTooltips} ];
433 {$this->
id}.labelDecorations = [ {$labelDecorations} ];
444 $dimensions =
"width: 100%; height: auto";
448 $dimensions =
"width: {$containerWidth}; height: {$containerHeight};";
453 echo
"<div id='{$this->id}'{$cssClass} style='{$this->cssStyles}'></div>";
__construct($type, $title)
setLabelDecorations($labelDecorations)
positionChart($left, $top, $width, $height)
showLegend($show, $x=0, $y=0)
__construct($id, $width=300, $height=300, $chartLeft=25, $chartTop=25, $chartWidth=250, $chartHeight=250, $palette="standard")
setContainerSize($width, $height="0")
setLabelTooltips($labelTooltips)
showTooltips($tooltips=null)
__construct($type, $title, $values)
__construct($type, $title)