2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
21 * @copyright 2016 Frédéric Massart - FMCorz.net
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') ||
die();
32 * @copyright 2016 Frédéric Massart - FMCorz.net
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 class chart_bar
extends chart_base
{
37 /** @var bool Whether the bars should be displayed horizontally or not. */
38 protected $horizontal = false;
39 /** @var bool Whether the chart should be stacked or not. */
40 protected $stacked = null;
42 * Add the horizontal to the parent and return the serialized data.
46 public function jsonSerialize() { // @codingStandardsIgnoreLine (CONTRIB-6469).
47 $data = parent
::jsonSerialize();
48 $data['horizontal'] = $this->get_horizontal();
49 $data['stacked'] = $this->get_stacked();
56 protected function set_defaults() {
57 parent
::set_defaults();
58 $yaxis = $this->get_yaxis(0, true);
63 * Get whether the bars should be displayed horizontally or not.
67 public function get_horizontal() {
68 return $this->horizontal
;
72 * Get whether the bars should be stacked or not.
76 public function get_stacked() {
77 return $this->stacked
;
81 * Set whether the bars should be displayed horizontally or not.
83 * @param bool $horizontal True if the bars should be displayed horizontally, false otherwise.
85 public function set_horizontal($horizontal) {
86 $this->horizontal
= $horizontal;
90 * Set whether the bars should be stacked or not.
92 * @param bool $stacked True if the chart should be stacked or false otherwise.
94 public function set_stacked($stacked) {
95 $this->stacked
= $stacked;