mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-54987 core: final charts project polishing
This commit is contained in:
parent
1850e97e37
commit
32917a9561
2
lib/amd/build/chart_base.min.js
vendored
2
lib/amd/build/chart_base.min.js
vendored
@ -1 +1 @@
|
||||
define(["core/chart_series","core/chart_axis"],function(a,b){function c(){this._series=[],this._labels=[],this._xaxes=[],this._yaxes=[],this._setDefaults()}return c.prototype._series=null,c.prototype._labels=null,c.prototype._title=null,c.prototype._xaxes=null,c.prototype._yaxes=null,c.prototype.COLORSET=["#f3c300","#875692","#f38400","#a1caf1","#be0032","#c2b280","#7f180d","#008856","#e68fac","#0067a5"],c.prototype.TYPE=null,c.prototype.addSeries=function(a){this._validateSeries(a),this._series.push(a),null===a.getColor()&&a.setColor(c.prototype.COLORSET[this._series.length%c.prototype.COLORSET.length])},c.prototype.create=function(c,d){var e=new c;return e.setLabels(d.labels),e.setTitle(d.title),d.series.forEach(function(b){e.addSeries(a.prototype.create(b))}),d.axes.x.forEach(function(a,c){e.setXAxis(b.prototype.create(a),c)}),d.axes.y.forEach(function(a,c){e.setYAxis(b.prototype.create(a),c)}),e},c.prototype.__getAxis=function(a,c,d){var e,f="x"===a?this._xaxes:this._yaxes,g=("x"===a?this.setXAxis:this.setYAxis).bind(this);if(c="undefined"==typeof c?0:c,d="undefined"==typeof d?!1:d,e=f[c],"undefined"==typeof e){if(!d)throw new Error("Unknown axis.");e=new b,g(e,c)}return e},c.prototype.getLabels=function(){return this._labels},c.prototype.getSeries=function(){return this._series},c.prototype.getTitle=function(){return this._title},c.prototype.getType=function(){if(!this.TYPE)throw new Error("The TYPE property has not been set.");return this.TYPE},c.prototype.getXAxes=function(){return this._xaxes},c.prototype.getXAxis=function(a,b){return this.__getAxis("x",a,b)},c.prototype.getYAxes=function(){return this._yaxes},c.prototype.getYAxis=function(a,b){return this.__getAxis("y",a,b)},c.prototype._setDefaults=function(){},c.prototype.setLabels=function(a){if(a.length&&this._series.length&&this._series[0].length!=a.length)throw new Error("Series must match label values.");this._labels=a},c.prototype.setTitle=function(a){this._title=a},c.prototype.setXAxis=function(a,b){b="undefined"==typeof b?0:b,this._validateAxis("x",a,b),this._xaxes[b]=a},c.prototype.setYAxis=function(a,b){b="undefined"==typeof b?0:b,this._validateAxis("y",a,b),this._yaxes[b]=a},c.prototype._validateAxis=function(a,b,c){if(c="undefined"==typeof c?0:c,c>0){var d="x"==a?this._xaxes:this._yaxes;if("undefined"==typeof d[c-1])throw new Error("Missing "+a+" axis at index lower than "+c)}},c.prototype._validateSeries=function(a){if(this._series.length&&this._series[0].getCount()!=a.getCount())throw new Error("Series do not have an equal number of values.");if(this._labels.length&&this._labels.length!=a.getCount())throw new Error("Series must match label values.")},c});
|
||||
define(["core/chart_series","core/chart_axis"],function(a,b){function c(){this._series=[],this._labels=[],this._xaxes=[],this._yaxes=[],this._setDefaults()}return c.prototype._series=null,c.prototype._labels=null,c.prototype._title=null,c.prototype._xaxes=null,c.prototype._yaxes=null,c.prototype.COLORSET=["#f3c300","#875692","#f38400","#a1caf1","#be0032","#c2b280","#7f180d","#008856","#e68fac","#0067a5"],c.prototype.TYPE=null,c.prototype.addSeries=function(a){this._validateSeries(a),this._series.push(a),null===a.getColor()&&a.setColor(c.prototype.COLORSET[this._series.length%c.prototype.COLORSET.length])},c.prototype.create=function(c,d){var e=new c;return e.setLabels(d.labels),e.setTitle(d.title),d.series.forEach(function(b){e.addSeries(a.prototype.create(b))}),d.axes.x.forEach(function(a,c){e.setXAxis(b.prototype.create(a),c)}),d.axes.y.forEach(function(a,c){e.setYAxis(b.prototype.create(a),c)}),e},c.prototype.__getAxis=function(a,c,d){var e,f="x"===a?this._xaxes:this._yaxes,g=("x"===a?this.setXAxis:this.setYAxis).bind(this);if(c="undefined"==typeof c?0:c,d="undefined"!=typeof d&&d,e=f[c],"undefined"==typeof e){if(!d)throw new Error("Unknown axis.");e=new b,g(e,c)}return e},c.prototype.getLabels=function(){return this._labels},c.prototype.getSeries=function(){return this._series},c.prototype.getTitle=function(){return this._title},c.prototype.getType=function(){if(!this.TYPE)throw new Error("The TYPE property has not been set.");return this.TYPE},c.prototype.getXAxes=function(){return this._xaxes},c.prototype.getXAxis=function(a,b){return this.__getAxis("x",a,b)},c.prototype.getYAxes=function(){return this._yaxes},c.prototype.getYAxis=function(a,b){return this.__getAxis("y",a,b)},c.prototype._setDefaults=function(){},c.prototype.setLabels=function(a){if(a.length&&this._series.length&&this._series[0].length!=a.length)throw new Error("Series must match label values.");this._labels=a},c.prototype.setTitle=function(a){this._title=a},c.prototype.setXAxis=function(a,b){b="undefined"==typeof b?0:b,this._validateAxis("x",a,b),this._xaxes[b]=a},c.prototype.setYAxis=function(a,b){b="undefined"==typeof b?0:b,this._validateAxis("y",a,b),this._yaxes[b]=a},c.prototype._validateAxis=function(a,b,c){if(c="undefined"==typeof c?0:c,c>0){var d="x"==a?this._xaxes:this._yaxes;if("undefined"==typeof d[c-1])throw new Error("Missing "+a+" axis at index lower than "+c)}},c.prototype._validateSeries=function(a){if(this._series.length&&this._series[0].getCount()!=a.getCount())throw new Error("Series do not have an equal number of values.");if(this._labels.length&&this._labels.length!=a.getCount())throw new Error("Series must match label values.")},c});
|
2
lib/amd/build/chart_output_htmltable.min.js
vendored
2
lib/amd/build/chart_output_htmltable.min.js
vendored
@ -1 +1 @@
|
||||
define(["jquery","core/chart_output_base"],function(a,b){function c(){b.prototype.constructor.apply(this,arguments),this._build()}return c.prototype=Object.create(b.prototype),c.prototype._build=function(){this._node.empty(),this._node.append(this._makeTable())},c.prototype._makeTable=function(){var b,c,d,e=a("<table>"),f=this._chart,g=f.getLabels(),h=g.length>0,i=f.getSeries(),j=i[0].getCount();e.addClass("chart-output-htmltable"),null!==f.getTitle()&&e.append(a("<caption>").text(f.getTitle())),b=a("<tr>"),h&&b.append(a("<td>")),i.forEach(function(c){b.append(a("<th>").text(c.getLabel()).attr("scope","col"))}),e.append(b);for(var k=0;j>k;k++){b=a("<tr>"),g.length>0&&b.append(a("<th>").text(g[k]).attr("scope","row"));for(var l=0;l<i.length;l++)c=i[l].getValues()[k],d=i[l].getLabels(),null!==d&&(c+=" "+i[l].getLabels()[k]),b.append(a("<td>").text(c));e.append(b)}return e},c.prototype.update=function(){this._build()},c});
|
||||
define(["jquery","core/chart_output_base"],function(a,b){function c(){b.prototype.constructor.apply(this,arguments),this._build()}return c.prototype=Object.create(b.prototype),c.prototype._build=function(){this._node.empty(),this._node.append(this._makeTable())},c.prototype._makeTable=function(){var b,c,d,e=a("<table>"),f=this._chart,g=f.getLabels(),h=g.length>0,i=f.getSeries(),j=i[0].getCount();e.addClass("chart-output-htmltable"),null!==f.getTitle()&&e.append(a("<caption>").text(f.getTitle())),b=a("<tr>"),h&&b.append(a("<td>")),i.forEach(function(c){b.append(a("<th>").text(c.getLabel()).attr("scope","col"))}),e.append(b);for(var k=0;k<j;k++){b=a("<tr>"),g.length>0&&b.append(a("<th>").text(g[k]).attr("scope","row"));for(var l=0;l<i.length;l++)c=i[l].getValues()[k],d=i[l].getLabels(),null!==d&&(c+=" "+i[l].getLabels()[k]),b.append(a("<td>").text(c));e.append(b)}return e},c.prototype.update=function(){this._build()},c});
|
10
lib/amd/build/chartjs-lazy.min.js
vendored
10
lib/amd/build/chartjs-lazy.min.js
vendored
File diff suppressed because one or more lines are too long
@ -74,7 +74,7 @@ define(['core/chart_base'], function(Base) {
|
||||
*
|
||||
* It sets the X Axis to zero if the min value is null.
|
||||
*
|
||||
* @param horizontal {Bool} True if the bars should be displayed horizontally, false otherwise.
|
||||
* @param {Bool} horizontal True if the bars should be displayed horizontally, false otherwise.
|
||||
*/
|
||||
Bar.prototype.setHorizontal = function(horizontal) {
|
||||
var axis = this.getXAxis(0, true);
|
||||
|
@ -276,7 +276,7 @@ define([], function() {
|
||||
/**
|
||||
* Set the labels for the values of the series.
|
||||
*
|
||||
* @param labels
|
||||
* @param {String[]} labels the labels of the series values.
|
||||
*/
|
||||
Series.prototype.setLabels = function(labels) {
|
||||
this._validateLabels(labels);
|
||||
@ -289,7 +289,7 @@ define([], function() {
|
||||
*
|
||||
* Only applicable for line chart or a line series, if null it assumes the chart default (not smooth).
|
||||
*
|
||||
* @param smooth
|
||||
* @param {Bool} smooth True if the lines should be smooth, false for tensioned lines.
|
||||
*/
|
||||
Series.prototype.setSmooth = function(smooth) {
|
||||
smooth = typeof smooth === 'undefined' ? null : smooth;
|
||||
|
@ -37,7 +37,7 @@ class chart_bar extends chart_base {
|
||||
/** @var bool Whether the bars should be displayed horizontally or not. */
|
||||
protected $horizontal = false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Add the horizontal to the parent and return the serialized data.
|
||||
*
|
||||
* @return array
|
||||
|
@ -222,7 +222,7 @@ class chart_series implements JsonSerializable {
|
||||
*
|
||||
* Only applicable for line chart or a line series, if null it assumes the chart default (not smooth).
|
||||
*
|
||||
* @param bool true if the line should be smooth, false if not.
|
||||
* @param bool $smooth True if the line should be smooth, false for tensioned lines.
|
||||
*/
|
||||
public function set_smooth($smooth) {
|
||||
$this->smooth = $smooth;
|
||||
|
@ -319,7 +319,7 @@ class mod_choice_renderer extends plugin_renderer_base {
|
||||
$percentageamount = 0;
|
||||
foreach ($choices->options as $optionid => $option) {
|
||||
if($choices->numberofuser > 0) {
|
||||
$percentageamount = ((float)count($option->user)/(float)$choices->numberofuser)*100.0;
|
||||
$percentageamount = ((float)count($option->user) / (float)$choices->numberofuser) * 100.0;
|
||||
}
|
||||
|
||||
$data['labels'][$count] = $option->text;
|
||||
|
@ -221,16 +221,16 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
$data = [];
|
||||
foreach ($analysed_vals as $val) {
|
||||
$quotient = format_float($val->quotient * 100, 2);
|
||||
$str_quotient = '';
|
||||
$strquotient = '';
|
||||
if ($val->quotient > 0) {
|
||||
$str_quotient = ' ('. $quotient . ' %)';
|
||||
$strquotient = ' ('. $quotient . ' %)';
|
||||
}
|
||||
$answertext = format_text(trim($val->answertext), FORMAT_HTML,
|
||||
array('noclean' => true, 'para' => false));
|
||||
|
||||
$data['labels'][$count] = $answertext;
|
||||
$data['series'][$count] = $val->answercount;
|
||||
$data['series_labels'][$count] = $str_quotient;
|
||||
$data['series_labels'][$count] = $strquotient;
|
||||
$count++;
|
||||
}
|
||||
$chart = new \core\chart_bar();
|
||||
|
@ -197,14 +197,14 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
$answertext = format_text(trim($val->answertext), FORMAT_HTML,
|
||||
array('noclean' => true, 'para' => false));
|
||||
if ($val->quotient > 0) {
|
||||
$str_quotient = ' ('.$quotient.' %)';
|
||||
$strquotient = ' ('.$quotient.' %)';
|
||||
} else {
|
||||
$str_quotient = '';
|
||||
$strquotient = '';
|
||||
}
|
||||
|
||||
$data['labels'][$count] = $answertext;
|
||||
$data['series'][$count] = $val->answercount;
|
||||
$data['series_labels'][$count] = $str_quotient;
|
||||
$data['series_labels'][$count] = $strquotient;
|
||||
$count++;
|
||||
}
|
||||
$chart = new \core\chart_bar();
|
||||
|
@ -17,8 +17,7 @@
|
||||
/**
|
||||
* This file contains functions used by the course overview report.
|
||||
*
|
||||
* @package report
|
||||
* @subpackage courseoverview
|
||||
* @package report_courseoverview
|
||||
* @copyright 2016 Simey Lameze <simey@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@ -44,8 +43,8 @@ function report_courseoverview_print_chart($report, $time, $numcourses) {
|
||||
} else {
|
||||
$sql = "SELECT courseid, $param->fields
|
||||
FROM {" . 'stats_' . $param->table . "}
|
||||
WHERE timeend >= $param->timeafter
|
||||
AND stattype = 'activity'
|
||||
WHERE timeend >= $param->timeafter
|
||||
AND stattype = 'activity'
|
||||
AND roleid = 0
|
||||
GROUP BY courseid
|
||||
$param->extras
|
||||
|
@ -71,7 +71,7 @@ function report_log_print_graph($course, $user, $typeormode, $date=0, $logreader
|
||||
if ($typeormode == 'today' || $typeormode == 'userday.png') {
|
||||
$logs = report_log_usertoday_data($course, $user, $date, $logreader);
|
||||
$title = get_string("hitsoncoursetoday", "", $a);
|
||||
} elseif ($typeormode == 'all' || $typeormode == 'usercourse.png') {
|
||||
} else if ($typeormode == 'all' || $typeormode == 'usercourse.png') {
|
||||
$logs = report_log_userall_data($course, $user, $logreader);
|
||||
$title = get_string("hitsoncourse", "", $a);
|
||||
}
|
||||
|
@ -392,11 +392,11 @@ function report_stats_print_chart($courseid, $report, $time, $mode, $userid = 0,
|
||||
$missedlines[] = $stat->timeend;
|
||||
}
|
||||
if ($stat->roleid != 0) {
|
||||
if (!array_key_exists($stat->roleid,$roles)) {
|
||||
if (!array_key_exists($stat->roleid, $roles)) {
|
||||
$roles[$stat->roleid] = $rolenames[$stat->roleid];
|
||||
}
|
||||
} else {
|
||||
if (!array_key_exists($stat->roleid,$roles)) {
|
||||
if (!array_key_exists($stat->roleid, $roles)) {
|
||||
$roles[$stat->roleid] = get_string('all');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user