Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mautic.corals.io/app/bundles/CoreBundle/Helper/Chart/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mautic.corals.io/app/bundles/CoreBundle/Helper/Chart/PieChart.php
<?php

namespace Mautic\CoreBundle\Helper\Chart;

class PieChart extends AbstractChart implements ChartInterface
{
    /**
     * Holds the suma of the all dataset values.
     *
     * @var float
     */
    protected $totalCount = 0;

    /**
     * @return array{labels: mixed[], datasets: mixed[]}
     */
    public function render($withCounts = true): array
    {
        $data = ['data' => [], 'backgroundColor' => [], 'hoverBackgroundColor' => []];

        foreach ($this->datasets as $datasetId => $value) {
            $color                          = $this->configureColorHelper($datasetId);
            $data['data'][]                 = $value;
            $data['backgroundColor'][]      = $color->toRgba(0.8);
            $data['hoverBackgroundColor'][] = $color->toRgba(0.9);
            if ($withCounts) {
                $this->labels[$datasetId] = $this->buildFullLabel($this->labels[$datasetId], $value);
            }
        }

        return [
            'labels'   => $this->labels,
            'datasets' => [$data],
        ];
    }

    /**
     * Define a dataset by name and count number. Method will add the rest.
     *
     * @param string $label
     * @param int    $value
     *
     * @return $this
     */
    public function setDataset($label, $value)
    {
        $this->totalCount += $value;
        $this->datasets[] = $value;
        $this->labels[]   = $label;

        return $this;
    }

    /**
     * Adds to the label also the value and the percentage.
     *
     * @param string $label
     * @param int    $value
     *
     * @return string
     */
    public function buildFullLabel($label, $value)
    {
        if (!$this->totalCount) {
            return $label;
        }
        $percentage = round($value / $this->totalCount * 100, 2);

        return $label.'; '.$value.'x, '.$percentage.'%';
    }
}

Spamworldpro Mini