close

  
<div><p> /**
 * @fileOverview Plots the distribution of votes for each question
 * i.e.
 * - for each question
 *   - display the count of the number of votes for each judgment type
 */

var marginLeft = 120;
var marginBottom = 12;

var maxSegmentsPerGroup = 5; // up to 5 votes for each kind of judgment
var groupRecords = [
  {
    label: "Skip",
    answer: "skip"
  },
  {
    label: "Broken",
    answer: "broken"
  },
  {
    label: "Poor",
    answer: "bad"
  },
  {
    label: "Good",
    answer: "good"
  }
];
var maxGroup = groupRecords.length;
var users = [];
  
//prepare the data to be plotted
function prepareData(data) {
  var userMap = {};
  for (var i = 0; i  0) {
        nonZeroCounts++;
        answer = k;
      }
    }
  }
  question.concordance = nonZeroCounts = totalVotes - 1;
  question.concordanceAnswer = question.concordance ? maxAnswer : '';
}

function makeConcordanceByAgreementByRatio(ratio) {
  return function(question) {
    var totalVotes = 0;
    var maxVote = 0;
    var maxAnswer = '';
    
    var votes = question.aggregate_votes;
    for (var k in votes) {
      if (votes.hasOwnProperty(k)) {
        var vote = votes[k];
        totalVotes += vote;
        if (maxVote  totalVotes * ratio;
    question.concordanceAnswer = question.concordance ? maxAnswer : '';
  }
}

var concordanceSchemes = [
  concordanceByAbsoluteAgreement,
  makeConcordanceByAgreementByRatio(0.5),
  makeConcordanceByAgreementByRatio(0.6),
  makeConcordanceByAgreementByRatio(0.7),
  makeConcordanceByAgreementByRatio(0.8),
  makeConcordanceByAgreementByRatio(0.9),
  concordanceByOneOff
];

//plot
function visualize(data) {
  var numberOfQuestions = data.length;
  
  var totalSegments = maxSegmentsPerGroup * maxGroup;
  var barSegmentHeight = totalSegments  100 ? 1 : 2;
  var actualBarWidth = Math.max(2, barWidth - gap);
  
  var answerToGroupBottom = {};
  for (var i = 0; i = 0) {
      var question = data[activeQuestion];
      var judgmentMap = question.judgment_map;
      for (var i = 0; i </p>Rendering question ' + questionId + ' ...</div>

Comments

Hide