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/>.
22 Example context (json):
28 <div class="chart-area" id="chart-area-{{uniqid}}">
29 <div class="chart-image" role="presentation" aria-describedby="chart-table-data-{{uniqid}}"></div>
30 <div class="chart-table {{^withtable}}accesshide{{/withtable}}">
31 <p class="chart-table-expand">
32 <a href="#" aria-controls="chart-table-data-{{uniqid}}" role="button">
33 {{#str}}showchartdata, moodle{{/str}}
36 <div class="chart-table-data" id="chart-table-data-{{uniqid}}" {{#withtable}}role="complementary" aria-expanded="false"{{/withtable}}></div>
44 'core/chart_output_chartjs',
45 'core/chart_output_htmltable',
46 ], function($, Builder, Output, OutputTable) {
47 var data = {{{chartdata}}},
48 uniqid = "{{uniqid}}",
49 chartArea = $('#chart-area-' + uniqid),
50 chartImage = chartArea.find('.chart-image'),
51 chartTable = chartArea.find('.chart-table-data'),
52 chartLink = chartArea.find('.chart-table-expand a');
53 Builder.make(data).then(function(ChartInst) {
54 new Output(chartImage, ChartInst);
55 new OutputTable(chartTable, ChartInst);
58 chartLink.on('click', function(e) {
60 if (chartTable.is(':visible')) {
62 chartLink.text({{#quote}}{{#str}}showchartdata, moodle{{/str}}{{/quote}});
63 chartTable.attr('aria-expanded', false);
66 chartLink.text({{#quote}}{{#str}}hidechartdata, moodle{{/str}}{{/quote}});
67 chartTable.attr('aria-expanded', true);