mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 18:06:51 +02:00
MDL-55665 core: Add support for stacked bar charts
This commit is contained in:
parent
3ca3cc77a2
commit
a5ee89f817
5 changed files with 75 additions and 4 deletions
|
@ -36,7 +36,8 @@ class chart_bar extends chart_base {
|
|||
|
||||
/** @var bool Whether the bars should be displayed horizontally or not. */
|
||||
protected $horizontal = false;
|
||||
|
||||
/** @var bool Whether the chart should be stacked or not. */
|
||||
protected $stacked = null;
|
||||
/**
|
||||
* Add the horizontal to the parent and return the serialized data.
|
||||
*
|
||||
|
@ -45,6 +46,7 @@ class chart_bar extends chart_base {
|
|||
public function jsonSerialize() { // @codingStandardsIgnoreLine (CONTRIB-6469).
|
||||
$data = parent::jsonSerialize();
|
||||
$data['horizontal'] = $this->get_horizontal();
|
||||
$data['stacked'] = $this->get_stacked();
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -67,11 +69,29 @@ class chart_bar extends chart_base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Set whether the bars should be displayed horizontally or not.
|
||||
* Get whether the bars should be stacked or not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function get_stacked() {
|
||||
return $this->stacked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the bars should be displayed horizontally or not.
|
||||
*
|
||||
* @param bool $horizontal True if the bars should be displayed horizontally, false otherwise.
|
||||
*/
|
||||
public function set_horizontal($horizontal) {
|
||||
$this->horizontal = $horizontal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the bars should be stacked or not.
|
||||
*
|
||||
* @param bool $stacked True if the chart should be stacked or false otherwise.
|
||||
*/
|
||||
public function set_stacked($stacked) {
|
||||
$this->stacked = $stacked;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue