mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-55352 core: Label values series should override tooltip
This commit is contained in:
parent
d1a3ea62ef
commit
9698ca2d20
2
lib/amd/build/chart_output_chartjs.min.js
vendored
2
lib/amd/build/chart_output_chartjs.min.js
vendored
@ -1 +1 @@
|
||||
define(["jquery","core/chartjs","core/chart_axis","core/chart_bar","core/chart_output_base","core/chart_line","core/chart_pie","core/chart_series"],function(a,b,c,d,e,f,g,h){function i(){e.prototype.constructor.apply(this,arguments),this._canvas=this._node,"CANVAS"!=this._canvas.prop("tagName")&&(this._canvas=a("<canvas>"),this._node.append(this._canvas)),this._build()}var j=function(a,b){return"axis-"+a+"-"+b};return i.prototype=Object.create(e.prototype),i.prototype._config=null,i.prototype._chartjs=null,i.prototype._canvas=null,i.prototype._build=function(){this._config=this._makeConfig(),this._chartjs=new b(this._canvas[0],this._config)},i.prototype._getChartType=function(){var a=this._chart.getType();return this._chart.getType()===d.prototype.TYPE&&this._chart.getHorizontal()===!0&&(a="horizontalBar"),a},i.prototype._makeAxisConfig=function(a,b,d){var e={id:j(b,d)};return a.getPosition()!==c.prototype.POS_DEFAULT&&(e.position=a.getPosition()),null!==a.getLabel()&&(e.scaleLabel={display:!0,labelString:a.getLabel()}),null!==a.getStepSize()&&(e.ticks=e.ticks||{},e.ticks.stepSize=a.getStepSize()),null!==a.getMax()&&(e.ticks=e.ticks||{},e.ticks.max=a.getMax()),null!==a.getMin()&&(e.ticks=e.ticks||{},e.ticks.min=a.getMin()),e},i.prototype._makeConfig=function(){var a={type:this._getChartType(),data:{labels:this._chart.getLabels(),datasets:this._makeDatasetsConfig()},options:{title:{display:null!==this._chart.getTitle(),text:this._chart.getTitle()}}};return this._chart.getXAxes().forEach(function(b,c){var d=b.getLabels();a.options.scales=a.options.scales||{},a.options.scales.xAxes=a.options.scales.xAxes||[],a.options.scales.xAxes[c]=this._makeAxisConfig(b,"x",c),null!==d&&(a.options.scales.xAxes[c].ticks.callback=function(a,b){return d[b]||""})}.bind(this)),this._chart.getYAxes().forEach(function(b,c){var d=b.getLabels();a.options.scales=a.options.scales||{},a.options.scales.yAxes=a.options.scales.yAxes||[],a.options.scales.yAxes[c]=this._makeAxisConfig(b,"y",c),null!==d&&(a.options.scales.yAxes[c].ticks.callback=function(a){return d[parseInt(a,10)]||""})}.bind(this)),a.options.tooltips={callbacks:{label:this._makeTooltip.bind(this)}},a},i.prototype._makeDatasetsConfig=function(){var a=this._chart.getSeries().map(function(a){var b=a.hasColoredValues()?a.getColors():a.getColor(),c={label:a.getLabel(),data:a.getValues(),type:a.getType(),fill:!1,backgroundColor:b,borderColor:this._chart.getType()==g.prototype.TYPE?null:b,lineTension:this._isSmooth(a)?.3:0};return null!==a.getXAxis()&&(c.xAxisID=j("x",a.getXAxis())),null!==a.getYAxis()&&(c.yAxisID=j("y",a.getYAxis())),c}.bind(this));return a},i.prototype._makeTooltip=function(a,b){var c=this._chart.getSeries()[a.datasetIndex],d=c.getLabel(),e=c.getLabels(),f=b.datasets[a.datasetIndex].data,g=f[a.index],h=d+": "+g;return null!==e&&(h+=" "+e[a.index]),h},i.prototype._isSmooth=function(a){var b=!1;return this._chart.getType()===f.prototype.TYPE?(b=a.getSmooth(),null===b&&(b=this._chart.getSmooth())):a.getType()===h.prototype.TYPE_LINE&&(b=a.getSmooth()),b},i.prototype.update=function(){a.extend(!0,this._config,this._makeConfig()),this._chartjs.update()},i});
|
||||
define(["jquery","core/chartjs","core/chart_axis","core/chart_bar","core/chart_output_base","core/chart_line","core/chart_pie","core/chart_series"],function(a,b,c,d,e,f,g,h){function i(){e.prototype.constructor.apply(this,arguments),this._canvas=this._node,"CANVAS"!=this._canvas.prop("tagName")&&(this._canvas=a("<canvas>"),this._node.append(this._canvas)),this._build()}var j=function(a,b){return"axis-"+a+"-"+b};return i.prototype=Object.create(e.prototype),i.prototype._config=null,i.prototype._chartjs=null,i.prototype._canvas=null,i.prototype._build=function(){this._config=this._makeConfig(),this._chartjs=new b(this._canvas[0],this._config)},i.prototype._getChartType=function(){var a=this._chart.getType();return this._chart.getType()===d.prototype.TYPE&&this._chart.getHorizontal()===!0&&(a="horizontalBar"),a},i.prototype._makeAxisConfig=function(a,b,d){var e={id:j(b,d)};return a.getPosition()!==c.prototype.POS_DEFAULT&&(e.position=a.getPosition()),null!==a.getLabel()&&(e.scaleLabel={display:!0,labelString:a.getLabel()}),null!==a.getStepSize()&&(e.ticks=e.ticks||{},e.ticks.stepSize=a.getStepSize()),null!==a.getMax()&&(e.ticks=e.ticks||{},e.ticks.max=a.getMax()),null!==a.getMin()&&(e.ticks=e.ticks||{},e.ticks.min=a.getMin()),e},i.prototype._makeConfig=function(){var a={type:this._getChartType(),data:{labels:this._chart.getLabels(),datasets:this._makeDatasetsConfig()},options:{title:{display:null!==this._chart.getTitle(),text:this._chart.getTitle()}}};return this._chart.getXAxes().forEach(function(b,c){var d=b.getLabels();a.options.scales=a.options.scales||{},a.options.scales.xAxes=a.options.scales.xAxes||[],a.options.scales.xAxes[c]=this._makeAxisConfig(b,"x",c),null!==d&&(a.options.scales.xAxes[c].ticks.callback=function(a,b){return d[b]||""})}.bind(this)),this._chart.getYAxes().forEach(function(b,c){var d=b.getLabels();a.options.scales=a.options.scales||{},a.options.scales.yAxes=a.options.scales.yAxes||[],a.options.scales.yAxes[c]=this._makeAxisConfig(b,"y",c),null!==d&&(a.options.scales.yAxes[c].ticks.callback=function(a){return d[parseInt(a,10)]||""})}.bind(this)),a.options.tooltips={callbacks:{label:this._makeTooltip.bind(this)}},a},i.prototype._makeDatasetsConfig=function(){var a=this._chart.getSeries().map(function(a){var b=a.hasColoredValues()?a.getColors():a.getColor(),c={label:a.getLabel(),data:a.getValues(),type:a.getType(),fill:!1,backgroundColor:b,borderColor:this._chart.getType()==g.prototype.TYPE?null:b,lineTension:this._isSmooth(a)?.3:0};return null!==a.getXAxis()&&(c.xAxisID=j("x",a.getXAxis())),null!==a.getYAxis()&&(c.yAxisID=j("y",a.getYAxis())),c}.bind(this));return a},i.prototype._makeTooltip=function(a,b){var c=this._chart.getSeries()[a.datasetIndex],d=c.getLabel(),e=c.getLabels(),f=b.datasets[a.datasetIndex].data,g=f[a.index],h=d+": "+g;return null!==e&&(h=e[a.index]),h},i.prototype._isSmooth=function(a){var b=!1;return this._chart.getType()===f.prototype.TYPE?(b=a.getSmooth(),null===b&&(b=this._chart.getSmooth())):a.getType()===h.prototype.TYPE_LINE&&(b=a.getSmooth()),b},i.prototype.update=function(){a.extend(!0,this._config,this._makeConfig()),this._chartjs.update()},i});
|
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;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});
|
||||
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});
|
@ -274,7 +274,7 @@ define([
|
||||
|
||||
// Add serie labels to the tooltip if any.
|
||||
if (serieLabels !== null) {
|
||||
tooltip += ' ' + serieLabels[tooltipItem.index];
|
||||
tooltip = serieLabels[tooltipItem.index];
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
|
@ -102,7 +102,7 @@ define([
|
||||
value = series[serieId].getValues()[rowId];
|
||||
seriesLabels = series[serieId].getLabels();
|
||||
if (seriesLabels !== null) {
|
||||
value += ' ' + series[serieId].getLabels()[rowId];
|
||||
value = series[serieId].getLabels()[rowId];
|
||||
}
|
||||
node.append($('<td>').text(value));
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ class mod_choice_renderer extends plugin_renderer_base {
|
||||
}
|
||||
$data['labels'][$count] = $option->text;
|
||||
$data['series'][$count] = $numberofuser;
|
||||
$data['series_labels'][$count] = '(' . format_float($percentageamount, 1) . '%)';
|
||||
$data['series_labels'][$count] = $numberofuser . ' (' . format_float($percentageamount, 1) . '%)';
|
||||
$count++;
|
||||
$numberofuser = 0;
|
||||
}
|
||||
|
@ -223,14 +223,14 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
$quotient = format_float($val->quotient * 100, 2);
|
||||
$strquotient = '';
|
||||
if ($val->quotient > 0) {
|
||||
$strquotient = '('. $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] = $strquotient;
|
||||
$data['series_labels'][$count] = $val->answercount . $strquotient;
|
||||
$count++;
|
||||
}
|
||||
$chart = new \core\chart_bar();
|
||||
|
Loading…
x
Reference in New Issue
Block a user