Skip to content

Commit

Permalink
chart container cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeseibel committed Dec 23, 2024
1 parent da7f782 commit 4d6115e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
8 changes: 5 additions & 3 deletions coursedashboards/static/coursedashboards/js/course.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ var showCourseData = function (label) {
terms = [],
current_course_panel = (compare_terms(section.year, section.quarter,
window.term.year, window.term.quarter) >= 0),
performanceTemplate;
performanceTemplate,
chart_container;

if (!current_course_panel && !section.loaded) {
fetchCourseData(label);
Expand Down Expand Up @@ -60,8 +61,6 @@ var showCourseData = function (label) {
display_course: section.display_course
}));

renderCoursePercentage1('current-declared-majors-chart', section.current_student_majors, 'major_name', 'percent_students');
renderCoursePercentage1('current-concurrent-courses-chart', section.concurrent_courses, 'course_ref', 'percent_students');

if (current_course_panel) {
var registered_percent = (section.current_enrollment / section.limit_estimate_enrollment) * 100,
Expand All @@ -78,6 +77,9 @@ var showCourseData = function (label) {
}));

renderStudentProfile('repeat', section.current_repeating, section.current_enrollment);

renderCoursePercentage1('current-declared-majors-chart', section.current_student_majors, 'major_name', 'percent_students');
renderCoursePercentage1('current-concurrent-courses-chart', section.concurrent_courses, 'course_ref', 'percent_students');
} else {
performanceTemplate = Handlebars.compile($("#historic-performance-template").html());
$("#current-performance-panel").html(performanceTemplate({
Expand Down
1 change: 0 additions & 1 deletion coursedashboards/static/coursedashboards/js/graphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ function renderCoursePercentage1(container, percentages, name_prop, percent_prop
other = 100,
chart_width = 240;


if (percentages) {
$.each(percentages.slice(0, 9), function () {
data.push([this[name_prop], Math.ceil(this[percent_prop])]);
Expand Down
41 changes: 32 additions & 9 deletions coursedashboards/static/coursedashboards/js/historic.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,19 @@ var showHistoricPerformanceData = function (section_label, data) {
total_students: data.performance.enrollment,
section_count: data.performance.offering_count,
gpa_distribution_time: 'historic'
});
}),
chart_container;;

chart_container = $panel.find('#historic-median-cumulative-gpa');
if (chart_container.length > 0) {
renderGPADisribution(chart_container[0], median_gpa, data.performance.gpas);
}

chart_container = $panel.find('#historic-median-course-gpa');
if (chart_container.length > 0) {
renderGPADisribution(chart_container[0], median_course_grade, data.performance.course_grades);
}

renderGPADisribution('historic-median-cumulative-gpa', median_gpa, data.performance.gpas);
renderGPADisribution('historic-median-course-gpa', median_course_grade, data.performance.course_grades);
bind_events($panel);
};

Expand All @@ -243,9 +252,13 @@ var showHistoricConcurrentCourses = function (section_label, data) {
'historic-concurrent-courses-template',
{
common_courses: data.concurrent_courses
});
}),
chart_container;

renderCoursePercentage1('historic-concurrent-course-chart', data.concurrent_courses, 'course_ref', 'percent_students');
chart_container = $panel.find('#historic-concurrent-course-chart');
if (chart_container.length > 0) {
renderCoursePercentage1(chart_container[0], data.concurrent_courses, 'course_ref', 'percent_students');
}

bind_events($panel);

Expand Down Expand Up @@ -280,9 +293,14 @@ var showHistoricStudentMajors = function (section_label, data) {
'historic-course-major-template',
{
common_majors: data.student_majors,
});
}),
chart_container;

chart_container = $panel.find('#historic-course-major-chart');
if (chart_container.length > 0) {
renderCoursePercentage1(chart_container[0], data.student_majors, 'major_name', 'percent_students');
}

renderCoursePercentage1('historic-course-major-chart', data.student_majors, 'major_name', 'percent_students');
bind_events($panel);
};

Expand All @@ -305,9 +323,14 @@ var showHistoricGraduatedMajors = function (section_label, data) {
'historic-grad-major-template',
{
latest_majors: data.graduated_majors
});
}),
chart_container;

chart_container = $panel.find('#historic-graduated-major-chart');
if (chart_container.length > 0) {
renderCoursePercentage1(chart_container[0], data.graduated_majors, 'major_name', 'percent_students');
}

renderCoursePercentage1('historic-graduated-major-chart', data.graduated_majors, 'major_name', 'percent_students');
bind_events($panel);
};

Expand Down

0 comments on commit 4d6115e

Please sign in to comment.