// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
/**
* Chart output for chart.js.
*
* @package core
* @copyright 2016 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @module core/chart_output_chartjs
*/
define([
'jquery',
'core/chartjs',
'core/chart_axis',
'core/chart_bar',
'core/chart_output_base',
'core/chart_line',
'core/chart_pie',
'core/chart_series'
], function($, Chartjs, Axis, Bar, Base, Line, Pie, Series) {
/**
* Makes an axis ID.
*
* @param {String} xy Accepts 'x' and 'y'.
* @param {Number} index The axis index.
* @return {String}
*/
var makeAxisId = function(xy, index) {
return 'axis-' + xy + '-' + index;
};
/**
* Chart output for Chart.js.
*
* @class
* @alias module:core/chart_output_chartjs
* @extends {module:core/chart_output_base}
*/
function Output() {
Base.prototype.constructor.apply(this, arguments);
// Make sure that we've got a canvas tag.
this._canvas = this._node;
if (this._canvas.prop('tagName') != 'CANVAS') {
this._canvas = $('