1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
<?php
namespace SIW\Elements;
/**
* Class om een piechart te genereren
*
* @copyright 2019 SIW Internationale Vrijwilligersprojecten
* @since 3.0.0
*/
class Pie_Chart extends Chart {
/**
* {@inheritDoc}
*/
protected $type = 'pie';
/**
* {@inheritDoc}
*/
protected $options = [
'height' => 400,
'truncateLegends' => true,
'maxSlices' => 7,
];
/**
* {@inheritDoc}
*/
protected function generate_chart_data() {
$data = [
'labels' => wp_list_pluck( $this->data, 'label' ),
'datasets' => [
[
'values' => wp_list_pluck( $this->data, 'value' ),
]
],
];
return $data;
}
}