Files
edx-platform/lms/static/js/histogram.js
Michael Terry a34c8c8233 Drop remaining coffee use
This basically commits the transpiled CoffeeScript JS (with minor
cleanup) and removes coffee build support.

A tiny amount of support for xblocks exists, because external users
may have xblocks with coffee. But no coffee in our tree anyway.
2018-04-13 14:10:40 -04:00

69 lines
1.7 KiB
JavaScript

// Once generated by CoffeeScript 1.9.3, but now lives as pure JS
/* eslint-disable */
(function() {
this.Histogram = (function() {
function Histogram(id, rawData) {
this.id = id;
this.rawData = rawData;
this.xTicks = [];
this.yTicks = [];
this.data = [];
this.calculate();
this.render();
}
Histogram.prototype.calculate = function() {
var count, i, len, log_count, ref, ref1, results, score;
ref = this.rawData;
results = [];
for (i = 0, len = ref.length; i < len; i++) {
ref1 = ref[i], score = ref1[0], count = ref1[1];
if (score === null) {
continue;
}
log_count = Math.log(count + 1);
this.data.push([score, log_count]);
this.xTicks.push([score, score.toString()]);
results.push(this.yTicks.push([log_count, count.toString()]));
}
return results;
};
Histogram.prototype.render = function() {
return $.plot($("#histogram_" + this.id), [
{
data: this.data,
bars: {
show: true,
align: 'center',
lineWidth: 0,
fill: 1.0
},
color: "#b72121"
}
], {
xaxis: {
min: -1,
max: Math.max.apply(Math, $.map(this.xTicks, function(data) {
return data[0] + 1;
})),
ticks: this.xTicks,
tickLength: 0
},
yaxis: {
min: 0.0,
max: Math.max.apply(Math, $.map(this.yTicks, function(data) {
return data[0] * 1.1;
})),
ticks: this.yTicks,
labelWidth: 50
}
});
};
return Histogram;
})();
}).call(this);