Skip to content

Instantly share code, notes, and snippets.

View beckyconning's full-sized avatar

Becky Conning beckyconning

View GitHub Profile
// A 2D view that renders values as a bar chart on a Raphael.js Paper (drawing context).
var BarChart = function(paper, values, axisMaxValue, barSpacingAsWidthMultiplier) {
// inheritance
var self = Infographic(paper);
// validation
if(typeof values === "undefined") {
return true;
}
var Infographic = function(paperRaphael) {
// inheritance
var self = {};
var elements = [];
// private
var paper;
// validatation
if(typeof paperRaphael === "undefined") {
var values = [3.1, 4, 2];
var elements = [];
var drawValueLabels = function() {
var barSpacingWidth = (barSpacingAsWidthMultiplier * paperWidth);
var barWidthWithoutSpacing = paperWidth / values.length;
var barWidthWithTrailingSpacing = barWidthWithoutSpacing - barSpacingWidth;
var barWidth = barWidthWithTrailingSpacing + (barSpacingWidth / values.length);
values.forEach(function(value, valueIndex) {
rename = proc { |key, value| [rename_map[key] || key, value] }
hidden_strengths = Hash[hidden_strengths.map &rename]
select
ct.name as competency_name,
s.id as section_id,
s.name as section_name,
q.id as question_id,
case when avg(not c.user_id = c.for_user_id then a.score) else null end as other_score ,
case when avg(c.user_id = c.for_user_id then a.score) else null end as subject_score,
case when avg(c.user_id = c.for_user_id then a.score) - avg(case when not c.user_id = c.for_user_id then a.score else null end) else null end as gap
select review_id, completion_for_user_id, reviewer_relationship, competency_name, round(avg(score),2) as score, 'TODO' as gap from(
select
r.id as review_id,
c.for_user_id as completion_for_user_id,
ifnull(ru.relationship, 'Self') as reviewer_relationship,
ct.id as competency_id,
ct.position as competency_position,
ct.name as competency_name,
s.id as section_id,
s.name as section_name,
SELECT
IFNULL(review_users.relationship, 'Self') AS relationship_name,
AVG(reviewer_answers.score) AS reviewers_average_score,
AVG(reviewee_answers.score) AS reviewee_average_score
FROM
review_users,
competencies as competency,
answers as reviewer_answers
Relationship Average Score Reviewee Average Score
Direct Report 2.4965034965035 3.77272727272727
Line Manager 2.4965034965035 3.77272727272727
Other 2.4965034965035 3.77272727272727
Peer 2.4965034965035 3.77272727272727
Self 2.4965034965035 3.77272727272727
select review_id, completion_for_user_id, reviewer_relationship, competency_name, round(avg(score),2) as score, 'TODO' as gap from(
select
r.id as review_id,
c.for_user_id as completion_for_user_id,
ifnull(ru.relationship, 'Self') as reviewer_relationship,
ct.id as competency_id,
ct.position as competency_position,
ct.name as competency_name,
s.id as section_id,
s.name as section_name,
Relationship Average Score Self Average Score
Direct Report 2.8 3.77
Line Manager 3.32 3.77
Other 4.09 3.77
Peer 3.07 3.77
Self 3.77 3.77