Commit f93a21a0 by Chris Rodriguez

Refactor to work correctly

parent aa6a063d
...@@ -115,29 +115,53 @@ $(function () { ...@@ -115,29 +115,53 @@ $(function () {
var droppedScores = ${ json.dumps(droppedScores) }; var droppedScores = ${ json.dumps(droppedScores) };
var grade_cutoff_ticks = ${ json.dumps(grade_cutoff_ticks) } var grade_cutoff_ticks = ${ json.dumps(grade_cutoff_ticks) }
var a11y = []; var order = [];
// add series var serez = [];
if (detail_tooltips['Completion']) { var c = 0, s, t;
for (var i = 0; i < detail_tooltips['Completion'].length; i++) {
a11y.push(detail_tooltips['Completion'][i]); // loop through ticks and make a new object with only the ticks
} for (var i = 0; i < ticks.length; i++) {
t = {};
t.tick = ticks[i][0];
order.push(t);
} }
if (detail_tooltips['Comprehension']) { // loop through the series and extract the matching tick and the series label
for (var i = 0; i < detail_tooltips['Comprehension'].length; i++) { for (var k = 0; k < series.length; k++) {
a11y.push(detail_tooltips['Comprehension'][i]); if (series[k]['data'].length > 1) {
for (var m = 0; m < series[k]['data'].length; m++) {
s = {};
s.tick = series[k]['data'][m][0];
s.label = series[k]['label'];
serez.push(s);
}
} else {
s = {};
s.tick = series[k]['data'][0][0];
s.label = series[k]['label'];
serez.push(s);
} }
} }
if (detail_tooltips['Dropped Scores']) { // reorder the serez object to match the ticks, which is the correct order
for (var i = 0; i < detail_tooltips['Dropped Scores'].length; i++) { serez.sort(function(a, b) {
a11y.push(detail_tooltips['Dropped Scores'][i]); return a.tick-b.tick;
});
// add a new description property with the additional context
for (var n = 0; n < serez.length; n++) {
if (detail_tooltips[serez[n].label].length > 1) {
serez[n].description = detail_tooltips[serez[n].label][c];
c++;
} else {
serez[n].description = detail_tooltips[serez[n].label][0];
} }
} }
// update the ticks output to include the additional context from serez
for (var i = 0; i < ticks.length; i++) { for (var i = 0; i < ticks.length; i++) {
if (a11y[i]) { if (serez[i]) {
ticks[i][1] = '<span aria-hidden="true">' + ticks[i][1] + '</span> ' + '<span class="sr">' + a11y[i] + '</span>'; ticks[i][1] = '<span aria-hidden="true">' + ticks[i][1] + '</span> ' + '<span class="sr">' + serez[i].description + '</span>';
} }
} }
...@@ -213,6 +237,7 @@ $(function () { ...@@ -213,6 +237,7 @@ $(function () {
$("#x").text(pos.x.toFixed(2)); $("#x").text(pos.x.toFixed(2));
$("#y").text(pos.y.toFixed(2)); $("#y").text(pos.y.toFixed(2));
if (item) { if (item) {
// console.log(item);÷
if (previousPoint != (item.dataIndex, item.seriesIndex)) { if (previousPoint != (item.dataIndex, item.seriesIndex)) {
previousPoint = (item.dataIndex, item.seriesIndex); previousPoint = (item.dataIndex, item.seriesIndex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment