2014-02-19 12:59:54 -05:00
|
|
|
<?php
|
2026-03-26 12:46:27 -04:00
|
|
|
|
|
|
|
|
// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2014-02-19 12:59:54 -05:00
|
|
|
|
|
|
|
|
namespace Icinga\Chart\Inline;
|
|
|
|
|
|
|
|
|
|
use Icinga\Chart\PieChart as PieChartRenderer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draw an inline pie-chart directly from the available request parameters.
|
|
|
|
|
*/
|
2014-05-20 19:29:13 -04:00
|
|
|
class PieChart extends Inline
|
|
|
|
|
{
|
2014-12-15 07:55:20 -05:00
|
|
|
protected function getChart()
|
2014-02-19 12:59:54 -05:00
|
|
|
{
|
|
|
|
|
$pie = new PieChartRenderer();
|
2014-08-28 12:25:19 -04:00
|
|
|
$pie->alignTopLeft();
|
2014-03-26 09:56:35 -04:00
|
|
|
$pie->disableLegend();
|
2014-02-19 12:59:54 -05:00
|
|
|
$pie->drawPie(array(
|
|
|
|
|
'data' => $this->data, 'colors' => $this->colors, 'labels' => $this->labels
|
|
|
|
|
));
|
2014-12-15 07:55:20 -05:00
|
|
|
return $pie;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toSvg($output = true)
|
|
|
|
|
{
|
2014-05-20 18:48:06 -04:00
|
|
|
if ($output) {
|
2014-12-15 07:55:20 -05:00
|
|
|
echo $this->getChart()->render();
|
2014-05-20 18:48:06 -04:00
|
|
|
} else {
|
2014-12-15 07:55:20 -05:00
|
|
|
return $this->getChart()->render();
|
2014-05-20 18:48:06 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-15 07:55:20 -05:00
|
|
|
public function toPng($output = true)
|
2014-05-20 18:48:06 -04:00
|
|
|
{
|
2014-12-15 07:55:20 -05:00
|
|
|
if ($output) {
|
|
|
|
|
echo $this->getChart()->toPng($this->width, $this->height);
|
|
|
|
|
} else {
|
|
|
|
|
return $this->getChart()->toPng($this->width, $this->height);
|
2014-05-20 18:48:06 -04:00
|
|
|
}
|
2014-02-19 12:59:54 -05:00
|
|
|
}
|
2014-05-20 19:29:13 -04:00
|
|
|
}
|