Name Last Update
lib Loading commit data...
tests/node Loading commit data...
.gitignore Loading commit data...
.gitlab-ci.yml Loading commit data...
.npmignore Loading commit data...
CHANGELOG.md Loading commit data...
LICENCE Loading commit data...
README.md Loading commit data...
gulpfile.js Loading commit data...
package.json Loading commit data...

RelativePlacementJS

build status

This library provide a placement system with the relative placement algorithm used in West Coast Swing dance competitions.

Understading relative placement

Relative placement is a placement system where electors (judges) provide there own placement of each candidates.

The algorithm consist to search for each place a majority of votes for a candidate at this placement or a greater placement.

You can refer to this explain from boogiebythebay.org for all details.

Get RelativePlacementJS

npm install relative-placement-js --save

With node:

var RelativePlacement = require('relative-placement-js');

With browser:

<script src="{BASE_PATH}/node_modules/relative-placement-js/dist/relative-placement-es2015.js"></script>
<!-- Or the original ES6 sources -->
<script src="{BASE_PATH}/node_modules/relative-placement-js/lib/relative-placement.js"></script> 

With AngularJS:

angular.module('myApp', ['relative-placement-js']).controller('MyCtrl', [
    '$scope', 'RelativePlacement',
    function($scope, RelativePlacement){

    }
]);

Use RelativePlacementJS

var contest = new RelativePlacement();

contest.addCandidates(['A','B','C']);
contest.addCandidate('D');

contest.addVote(['A','B','C','D']);
contest.addVotes([
    ['A','B','C','D'],
    ['A','C','B','D'],
    ['A','B','D','C'],
    ['B','A','C','D'],
    ['B','A','D','C']
]);

var result = contest.getResult(); // return ['A','B','C','D'];