MDL-65176 analytics: target for students who don't get the minimum grade
[moodle.git] / lib / classes / chart_bar.php
blob034d274cb0a201cd3b3c256080060f75e00ec698
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
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.
8 //
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/>.
17 /**
18 * Chart bar.
20 * @package core
21 * @copyright 2016 Frédéric Massart - FMCorz.net
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 namespace core;
26 defined('MOODLE_INTERNAL') || die();
28 /**
29 * Chart bar class.
31 * @package core
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;
41 /**
42 * Add the horizontal to the parent and return the serialized data.
44 * @return array
46 public function jsonSerialize() { // @codingStandardsIgnoreLine (CONTRIB-6469).
47 $data = parent::jsonSerialize();
48 $data['horizontal'] = $this->get_horizontal();
49 $data['stacked'] = $this->get_stacked();
50 return $data;
53 /**
54 * Set the defaults.
56 protected function set_defaults() {
57 parent::set_defaults();
58 $yaxis = $this->get_yaxis(0, true);
59 $yaxis->set_min(0);
62 /**
63 * Get whether the bars should be displayed horizontally or not.
65 * @return bool
67 public function get_horizontal() {
68 return $this->horizontal;
71 /**
72 * Get whether the bars should be stacked or not.
74 * @return bool
76 public function get_stacked() {
77 return $this->stacked;
80 /**
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;
89 /**
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;